Skip to content

Commit

Permalink
[common] Ensure runfiles meet their promise of being absolute paths (R…
Browse files Browse the repository at this point in the history
…obotLocomotion#17643)

* [common] Ensure runfiles meet their promise of being absolute paths

Add more cwd debug-logging to show what's happening.

Update the hardware_sim demo to set a valid runfiles path.
  • Loading branch information
jwnimmer-tri authored Jul 27, 2022
1 parent dc6db5c commit 6bc95fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions common/find_runfiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ RunfilesSingleton Create() {
result.runfiles.reset(Runfiles::Create(argv0, &bazel_error));
}
drake::log()->debug("FindRunfile mechanism = {}", mechanism);
drake::log()->debug("cwd = {}", filesystem::current_path());

// If there were runfiles, identify the RUNFILES_DIR.
if (result.runfiles) {
Expand All @@ -81,8 +82,10 @@ RunfilesSingleton Create() {
// `bazel-bin/target`.
// TODO(eric.cousineau): Show this in Drake itself. This behavior was
// encountered in Anzu issue 5653, in a Python binary.
result.runfiles_dir =
filesystem::path(key_value.second).lexically_normal().string();
filesystem::path path = key_value.second;
path = filesystem::absolute(path);
path = path.lexically_normal();
result.runfiles_dir = path.string();
break;
}
}
Expand Down
2 changes: 2 additions & 0 deletions examples/hardware_sim/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ sh_binary(
"//manipulation/models/ur3e:prod_models",
"//manipulation/models/wsg_50_description:prod_models",
],
# Use the runfiles of the ":homecart", not of the ":hardware_sim".
env = {"RUNFILES_DIR": "../"},
)

add_lint_tests()

0 comments on commit 6bc95fd

Please sign in to comment.