Emit a .dsv env hook so the plugin path resolves under colcon - #1
Open
MonkeScripts wants to merge 1 commit into
Open
Emit a .dsv env hook so the plugin path resolves under colcon#1MonkeScripts wants to merge 1 commit into
MonkeScripts wants to merge 1 commit into
Conversation
MonkeScripts
force-pushed
the
fix/env-hook-dsv-descriptor
branch
from
August 16, 2026 03:54
18d5d92 to
a04352d
Compare
The hook was a .sh-only file that hardcoded the configure-time install prefix. It worked, but baked an absolute path into the installed hook, so the install tree could not be relocated. Switch to the ament-native form and declare AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_gz_led_plugin so ament_environment_hooks also emits gz_led_plugin.dsv. colcon's setup chain prefers the .dsv when one exists and only falls back to sourcing the .sh otherwise -- and that fallback exports COLCON_CURRENT_PREFIX, never AMENT_CURRENT_PREFIX, which is why a .sh-only hook using ament_prepend_unique_value would silently prepend whichever prefix was sourced last (e.g. /opt/ros/humble/lib). The descriptor's path is relative, so colcon resolves it against the package prefix and the install tree stays relocatable.
MonkeScripts
force-pushed
the
fix/env-hook-dsv-descriptor
branch
from
August 16, 2026 04:02
a04352d to
a57ccb0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The environment hook was a
.sh-only file that hardcoded the configure-time install prefix:That works, but bakes an absolute path into the installed hook, so the install tree cannot be moved, copied into an image, or reused under a different mount without rebuilding.
Fix
Switch to the ament-native hook and declare the DSV descriptor so
ament_environment_hooks()also emitsgz_led_plugin.dsv:This is the same mechanism ament uses for its own
ament_prefix_path/path/library_pathhooks, which all ship both forms.Why the descriptor matters
_local_setup_util_sh.pyprefers a sibling.dsvand only falls back to sourcing the.sh:and that fallback exports
COLCON_CURRENT_PREFIX, neverAMENT_CURRENT_PREFIX:So a
.sh-only hook usingament_prepend_unique_value "$AMENT_CURRENT_PREFIX/lib"would silently prepend whichever prefix was sourced last (e.g./opt/ros/humble/lib). Emitting the.dsvavoids that path entirely.The descriptor value is relative (
lib), which colcon resolves against the package prefix — so the install tree stays relocatable.Verification
Clean rebuild, then loading a world that uses the plugin (headless, isolated
GZ_PARTITION):gz_led_plugin.dsvemitted alongside the.shGZ_SIM_SYSTEM_PLUGIN_PATHhead isinstall/gz_led_plugin/lib; no/opt/ros/humble/libcontaminationlibgz_led_plugin.soresolvable on the pathFailed to load system pluginerrors, 0 LedPlugin errors