Skip to content

fix: Resolve runfiles in launch_exec templates#633

Open
furushchev wants to merge 2 commits into
mvukov:mainfrom
furushchev:resolve-runfiles
Open

fix: Resolve runfiles in launch_exec templates#633
furushchev wants to merge 2 commits into
mvukov:mainfrom
furushchev:resolve-runfiles

Conversation

@furushchev

@furushchev furushchev commented May 22, 2026

Copy link
Copy Markdown

The previous implementation used $(rootpath) to embed build-time paths to entry point executables. When launch wrappers were symlinked by other rules (such as bazel_env), these hardcoded paths became invalid, causing "file not found" errors at runtime.

To fix the issue:

  • Replaced $(rootpath) with $(rlocationpath) in template substitutions
  • Added Bazel runfiles library resolution in wrapper scripts:
    • launch_exec.sh.tpl: Use rlocation function
    • launch_exec.py.tpl: Use python.runfiles.Runfiles.Rlocation
  • Added necessary dependencies:
    • py_binary / py_test: Add @rules_python//python/runfiles dependency
    • sh_binary/ sh_test: Enable use_bash_launcher = True for rlocation support

@mvukov mvukov left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK with me, left a few comments to be clarified before the merge.

Comment thread ros2/cc_defs.bzl
name = name,
srcs = [launcher],
data = [target_impl],
use_bash_launcher = True,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that we had a bug before?

Comment thread ros2/launch_exec.py.tpl
@@ -1,5 +1,6 @@
import os
import sys
from python.runfiles import runfiles

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please insert an empty line above as this is an external dep.

Comment thread ros2/launch_exec.sh.tpl
fi
fi

ENTRYPOINT="$(rlocation {entry_point})"

@mvukov mvukov May 25, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you have to depend on a target from rules_sh for this to work? I remember that earlier versions of rules_sh required copy/pasting of a snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants