Colcon fails to build Python package: "error in 'egg_base'"
After I ran an apt upgrade
this morning, Colcon fails to build ROS2 Python packages from source with the following error:
$ colcon build --packages-up-to joint_state_publisher
Starting >>> joint_state_publisher
--- stderr: joint_state_publisher
error: error in 'egg_base' option: '../../../build/joint_state_publisher' does not exist or is not a directory
---
Failed <<< joint_state_publisher [0.44s, exited with code 1]
Summary: 0 packages finished [0.76s]
1 package failed: joint_state_publisher
1 package had stderr output: joint_state_publisher
I am using this branch: https://github.com/ros/joint_state_publisher/tree/eloquent
Based on some of the other results from searching for this error (such as this one: https://answers.ros.org/question/309103/what-is-the-correct-layout-of-python-code-when-using-symlink-install-in-ros-2/) I think this might be related to parsing the package's setup.py
file, rather than something necessarily ROS-specific.
Asked by jschornak on 2020-10-23 12:13:37 UTC
Answers
I came across the same issue today, and after digging up a little, I was able to solve this by using the --symlink-install
flag.
How to reproduce the solution:
mkdir -p test_ws/src
cd test_ws/src
ros2 pkg create --build-type ament_python foo
cd ../
colcon build
This obviously builds fine.
Now :
rm -rf build install log
mv src/foo ..
ln -s $(pwd)/../foo src/foo
colcon build
This fails.
But now
rm -rf build install log
colcon build --symlink-install
should build successfully.
Asked by janindu on 2021-06-09 21:58:29 UTC
Comments
I have the same problem. In my case, the issue is caused by the fact that I used symbolic links from the workspace src folder to the actual sources. Without symbolic links, the issue does not seem to occur. Can you confirm if this is the same for you?
Asked by mheidingsfeld on 2020-10-27 10:20:45 UTC
@mheidingsfeld I indeed can confirm this. I just tried copying packages instead of using links and I am not getitng this issue anymore
Asked by viktor.holova on 2020-10-27 11:56:48 UTC
To me this seem to be an issue with colcon and Python packages. It can be easily reproduced with this minimal example:
Asked by mheidingsfeld on 2020-10-27 12:36:31 UTC
@mheidingsfeld I can duplicate your minimal example, and I get the same error as I did previously.
In my original case, my project
src
directory was symlinked to thesrc
directory of a different workspace (an important detail that had slipped my mind, since I'd set up this workspace months and months ago). I made a minimal example to test this situation, and I discovered that if I build the workspace containing the non-symlinked directory first, the workspace containing the symlinked directory succeeds.This works:
Asked by jschornak on 2020-10-28 12:09:50 UTC
This fails:
Asked by jschornak on 2020-10-28 12:11:35 UTC
I am facing the exact same problem, also having a symlinked workspace. I know the setup worked months ago, most likely with an older colcon version.
Asked by potentialdiffer on 2020-10-29 05:16:44 UTC
I create an issue about this here: https://github.com/colcon/colcon-core/issues/404
Asked by jschornak on 2020-10-29 15:58:58 UTC