catkin build fails for projects with the cmake build type
System Info
- Operating System: Docker running ubuntu20.04
- Python Version: 3.8.5
- Version of catkin_tools: catkin_tools 0.5.0
- ROS Distro: ROS NOETIC
Build / Run Issue
[ ] Works with catkin build
[ ] Works with catkin build -p1
Expected Behavior
I have a project listed as <build_type>cmake</build_type> in the ros package.xml. I expect this to build with catkin build package name.
Actual Behavior
I get the following error from catkin_tools:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/catkin_tools/execution/stages.py", line 174, in function_proxy
return function(logger, event_queue, *args, **kwargs)
File "/usr/lib/python3/dist-packages/catkin_tools/jobs/cmake.py", line 193, in generate_setup_file
pythonpath = os.path.join(install_target, get_python_install_dir(context))
File "/usr/lib/python3/dist-packages/catkin_tools/jobs/cmake.py", line 98, in get_python_install_dir
p = subprocess.Popen(
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/catkin_tools/jobs/cmake'
Stage `setupgen` failed with arguments:
context: <catkin_tools.context.Context object at 0x7fad997b21f0>
install_target: /home/user/development/project/install
When i look into the code is see this subprocess command:
p = subprocess.Popen(
cmake_command,
cwd=os.path.join(os.path.dirname(__file__), 'cmake'),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# only our message (containing the install directory) is written to stderr
_, out = p.communicate()
return out.decode().strip()
where the dirname is going to be resolved as:
/usr/lib/python3/dist-packages/catkin_tools/jobs/. Then you will add cmake on the end, and this path does not seem to exist. A work around at the moment is to remove the path join and have the working directory as the jobs folder. This makes everything work again.
Steps to reproduce
- Make a docker with ros noetic and ubuntu20.04
- Add a package with cmake build type
- attempt to build said package with
catkin build
I can see a cmake folder actually does exist in the source. I am looking into why it doesn't end up in the install directory now.
Ok, so installing through apt-get:
apt-get install python3-catkin-tools does not work. The /usr/lib/python3/dist-packages/catkin_tools/jobs/ folder is left without a cmake folder. This causes the command to fail.
If i instead install the master, directly through pip:
pip3 install git+https://github.com/catkin/catkin_tools.git
Then the cmake folder is there and the command works. Should i close this now? Or can it remain open to look into why this is happening with the apt-get install?
Interesting. The 0.6.1 release doesn't seem to have made it into focal. The 0.7.0 version should hopefully be released soon (see #594 and #648). It will also fix your problem. Until then, it is unfortunately necessary to install from the source via pip, as you mentioned.
I reproduced the same error on my environment (focal, noetic, catkin_tools==0.5.0 && 0.6.1).
And I also found that with install space enabled, if you run catkin build again after catkin build and remove install space, some files including setup.bash disappears from install directory:
root@b9269cb9aa5d:~/project# ls install/
_setup_util.py env.sh include lib local_setup.bash local_setup.sh local_setup.zsh python setup.bash setup.sh setup.zsh share
root@b9269cb9aa5d:~/project# rm -rf install/ logs/
root@b9269cb9aa5d:~/project# source /opt/ros/noetic/setup.bash
root@b9269cb9aa5d:~/project# catkin b
==> Expanding alias 'b' from 'catkin b' to 'catkin build'
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Profile: default
Extending: [explicit] /opt/ros/noetic
Workspace: /root/project
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Build Space: [exists] /root/project/build
Devel Space: [exists] /root/project/devel
Install Space: [missing] /root/project/install
Log Space: [missing] /root/project/logs
Source Space: [exists] /root/project/src
DESTDIR: [unused] None
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Devel Space Layout: linked
Install Space Layout: merged
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Additional CMake Args: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
Additional Make Args: None
Additional catkin Make Args: None
Internal Make Job Server: True
Cache Job Environments: False
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Whitelisted Packages: None
Blacklisted Packages: None
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Workspace configuration appears valid.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
[build] Found '1' packages in 0.0 seconds.
Starting >>> sample_pkg
Finished <<< sample_pkg [ 0.5 seconds ]
[build] Summary: All 1 packages succeeded!
[build] Ignored: None.
[build] Warnings: None.
[build] Abandoned: None.
[build] Failed: None.
[build] Runtime: 0.5 seconds total.
root@b9269cb9aa5d:~/project# ls install/
env.sh include lib python setup.sh share
Interesting, I cannot reproduce this issue locally with the current master. The issue looks similar to #621 which was closed in #650. Could you try installing catkin_tools with pip from master (pip3 install git+https://github.com/catkin/catkin_tools.git, maybe uninstall the currently installed version first to be sure) and take a look if the issue persists?
@timonegk Thank you for your comment. I successfully created a docker environment to reproduce the error. Please check the repository (details on README.md) https://github.com/furushchev/check_catkin_tools
In README.md of the repository above:
- In the 11/14 step: Everything is ok (setup.bash and other stuffs are located in the install space)
- In the 14/14 step: I confirmed that there is only
bindirectory in the install space.
Thank you for the reproducible build! I could narrow the issue down and also reproduce it locally. The problem is that the helper files (env.py, setup.bash, etc.) are generated by the package catkin_tools_prebuild that is built when it is not yet in the workspace. In your case, the package is detected as in the workspace because it still exists in the devel directory, and is therefore not queued again. So a quick workaround is to delete the devel folder, too.
But I'm also working on a fix.
The fix is ready in #682. I already tested it in your Docker and added an automatic test, so I'm fairly certain that the issue is fixed. But it would still be helpful if you could verify that the issue no longer occurs with the patch, you can install it via pip3 install git+https://github.com/catkin/catkin_tools.git@fix/regenerate-install-setup.
@timonegk Thank you for the fix! I also confirmed that setup.bash and other stuff that is required for ROS functionality is generated even after removing install workspace and re-building all packages.