Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"colcon build --merge-install" change the environment variable "LD_LIBRARY_PATH" #532

Closed
ipa-rwu opened this issue Nov 8, 2022 · 2 comments

Comments

@ipa-rwu
Copy link

ipa-rwu commented Nov 8, 2022

I also posed this question in answers.ros.org in case anybody has the same issue.

Here is the problem:

After I run the command

colcon build  --merge-install --install-base /opt/ros/$ROS_DISTRO

I found the environment variable "LD_LIBRARY_PATH" changed from
/opt/ros/galactic/lib/x86_64-linux-gnu:/opt/ros/galactic/lib to /opt/ros/galactic/lib. And then it caused it cannot find libraries under /opt/ros/galactic/lib/x86_64-linux-gnu.

Here are steps you can reproduce this error:

  1. You can use docker image "public.ecr.aws/docker/library/ros:galactic"

  2. put demo_nodes_cpp in your "src" folder. This demo needs libconsole_bridge.so.1.0 which is under /opt/ros/galactic/lib/x86_64-linux-gnu

  3. run

colcon build --merge-install --install-base "/opt/ros/galactic"
  1. check the environment variable "LD_LIBRARY_PATH": echo $LD_LIBRARY_PATH.
    You should get /opt/ros/galactic/opt/yaml_cpp_vendor/lib:/opt/ros/galactic/lib/x86_64-linux-gnu:/opt/ros/galactic/lib
  2. save this container as a docker image. You can run
docker ps

to find this container ID. Then run

 docker commit "container ID" "image name"
6. start a container of the new docker image. Then check check  the environment variable "LD_LIBRARY_PATH": `echo $LD_LIBRARY_PATH`

You should get /opt/ros/galactic/lib
7. Run the demo ros2 run demo_nodes_cpp talker. You will get the error /opt/ros/galactic/lib/demo_nodes_cpp/talker: error while loading shared libraries: libconsole_bridge.so.1.0: cannot open shared object file: No such file or directory

There is no issue if only using colcon build. So I suspect the cause of this is from --merge-install.

Thank you for your help!

@cottsay
Copy link
Member

cottsay commented Dec 6, 2022

At first glance, this is probably due to the fact that the hooks installed by the debs in /opt/ros/<rosdistro> are generated by ament, and the hooks generated by colcon might be a little different. Clearly they aren't completely compatible if this sort of bug is popping up.

This isn't really a solution to this exact issue, but installing using colcon on top of the files installed by the debs probably isn't a good idea for reasons other than what you're experiencing here. This is the sort of scenario that overlay workspaces are designed for. You should install the packages to a different location and source that workspace's setup script, which should automatically chain to the /opt/ros/<distro> setup script as well as long as it had already been sourced when the new workspace was created.

@ipa-rwu
Copy link
Author

ipa-rwu commented Feb 7, 2023

Thanks for you answer! I will close the issue.

@ipa-rwu ipa-rwu closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants