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

Using install with catkin build results in devel/setup.bash disabling finding packages in the workspace #577

Open
nsteele opened this issue Oct 25, 2019 · 6 comments

Comments

@nsteele
Copy link

nsteele commented Oct 25, 2019

System Info

Build / Run Issue

If one configures their workspace for installation then sources devel/setup.bash, common rosbash commands no longer work as desired because these commands find packages in the install space before the workspace. This causes a lot of headaches when developing in workspaces that are configured for installation.

Expected Behavior

For example, after running source devel/setup.bash, a command like rosed my-pkg my-launch-file should edit my-launch-file in my-pkg in the workspace (if in fact my-pkg is a package in the workspace).

Actual Behavior

Staying with the above example, what will happen is rosed my-pkg my-launch-file will edit my-launch-file in the install space instead of the workspace.

Steps to Reproduce the Issue

If one configures any workspace for installation and builds i.e.

catkin config --install
catkin clean -b
catkin build

and the workspace has a pkg X, then do the following:

source devel/setup.bash
roscd X

This will change your directory to the X package in the install space, and not the workspace like it should.

Hint

Going a little deeper: when the problem occurs, you'll see that ROS_PACKAGE_PATH lists the install space before the workspace packages. I see that ROS_PACKAGE_PATH is generated from the CMAKE_PREFIX_PATH in devel/_setup_util.py, and that in the __main__ function of _setup_util.py, there is line of the form

CMAKE_PREFIX_PATH= '/path/to/install-space;/opt/ros/melodic;/path/to/devel-space'.split(';')

I think that the install-space path should come last in the line above.

@nalt
Copy link

nalt commented Oct 28, 2019

For me, it does not even add the install space:

$ . devel/setup.bash 
$ echo $ROS_PACKAGE_PATH 
/opt/ros/melodic/share

While in the install space:

$ . install/setup.bash 
$ echo $ROS_PACKAGE_PATH 
.../workspace/install/share:/opt/ros/melodic/share

@nsteele
Copy link
Author

nsteele commented Oct 28, 2019

I was seeing slightly different behavior than @nalt when I tried this in an existing ws of mine, but I can reproduce @nalt 's result when I start with a new ws. Here's how:

mkdir -p test/src
cd test
source /opt/ros/melodic/setup.bash
catkin init
catkin create pkg -p src mypkg
catkin build
source devel/setup.bash
echo $ROS_PACKAGE_PATH # result: /path/to/mypkg:/opt/ros/melodic/share GOOD!
catkin config --install
catkin clean -b # remove only the build space
catkin build
source devel/setup.bash
echo $ROS_PACKAGE_PATH # result: /path/to/mypkg:/opt/ros/melodic/share GOOD!
catkin clean # remove build, devel, and install spaces
catkin build
source devel/setup.bash
echo $ROS_PACKAGE_PATH #result: /opt/ros/melodic/share BAD!

So I can now describe the problem a little more precisely: when the workspace is configured for install, and the devel space is rebuilt, then source devel/setup.bash gives an incorrect $ROS_PACKAGE_PATH. If the workspace is configured for install after the devel space is already built, then source devel/setup.bash will give the correct $ROS_PACKAGE_PATH until the devel space is rebuilt.

@ndepal
Copy link

ndepal commented Aug 4, 2021

Is there no resolution to this? I'm running into this as well with ROS melodic.

@mikepurvis
Copy link
Member

I don't think there's really any sane way to support this. Each package needs an environment to build in, and in --install mode, that environment is the environment of the setup.sh scripts from each dependency' install spaces. So once you're in --install mode, anything devel-related becomes undefined— all the embedded CMake paths, pkgconfig scripts, elf library paths, all of it is all pointing back to the install spaces. Once that's done, the existence of devel is really just an incidental thing, a curious splitting off of portions of what would otherwise go into build in a normal non-catkin CMake build.

Potentially what you want is like an "also install" mode, where you basically get the normal devel build, where each package uses the devel space of its dependencies, but runs make install perhaps as part of a CI validation pipeline or something. There's no explicit support for this in catkin_tools, but I expect you could fake it with --make-args or --catkin-make-args, or even just visiting every build/* directory and manually running make install in there.

@ndepal
Copy link

ndepal commented Aug 6, 2021

Potentially what you want is like an "also install" mode,

That's exactly what I want.

The reason why I want it is because quick testing of e.g. python ROS nodes becomes more cumbersome with --install mode. I can no longer just modify the script and rosrun it, I have to catkin build my_package --no-deps every time to have it be moved to the install space.

@Timple
Copy link

Timple commented Aug 6, 2021

As an alternative you can use colcon build --symlink-install

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

No branches or pull requests

5 participants