ARoefer / rosvenv

ROSVENV - A lightweight virtual environment wrapper for ROS1
MIT License
17 stars 5 forks source link

Conda: Inside Docker container `catkin build` is missing `empy` #10

Open ARoefer opened 5 months ago

ARoefer commented 5 months ago

It seems that the package empy is missing inside the docker container when using Conda. Output of trying to create a new workspace on a Ubuntu 22.04 machine using a docker container:

$ createROSWS test_ws --docker
ROSVENV image exists
Starting docker container "test_ws" with image "rosvenv:latest"...
Found installation of nvidia-container-toolkit. Exposing your GPUs to the container...
96ef3190775c6157098f2ff0b0fffab27205e7d80cebb10af9dbf58a120f8f52
ROS is not sourced. Sourcing it...
Sourced noetic
Creating symlink "/home/user/Desktop/tst_rosvenv/rosvenv/test_ws/src/CMakeLists.txt" pointing to "/opt/ros/noetic/share/catkin/cmake/toplevel.cmake"
Creating conda env
Found activate conda env base. Saved it to workspace.
--------------------------------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/noetic
Workspace:                   /home/user/Desktop/tst_rosvenv/rosvenv/test_ws
--------------------------------------------------------------------------------
Build Space:        [exists] /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/build
Devel Space:        [exists] /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/devel
Install Space:      [unused] /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/install
Log Space:         [missing] /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/logs
Source Space:       [exists] /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/src
DESTDIR:            [unused] None
--------------------------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
--------------------------------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
--------------------------------------------------------------------------------
Buildlisted Packages:        None
Skiplisted Packages:         None
--------------------------------------------------------------------------------
Workspace configuration appears valid.

NOTE: Forcing CMake to run for each package.
--------------------------------------------------------------------------------
[build] No packages were found in the source space '/home/user/Desktop/tst_rosvenv/rosvenv/test_ws/src'
[build] No packages to be built.
[build] Package table is up to date.                                           
Starting  >>> catkin_tools_prebuild                                            
_______________________________________________________________________________
Errors     << catkin_tools_prebuild:cmake /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/logs/catkin_tools_prebuild/build.cmake.000.log
CMake Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message):
  Unable to find either executable 'empy' or Python module 'em'...  try
  installing the package 'python3-empy'
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/all.cmake:164 (include)
  /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:4 (find_package)

cd /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/build/catkin_tools_prebuild; catkin build --get-env catkin_tools_prebuild | catkin env -si  /usr/bin/cmake /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/build/catkin_tools_prebuild --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/user/Desktop/tst_rosvenv/rosvenv/test_ws/devel/.private/catkin_tools_prebuild -DCMAKE_INSTALL_PREFIX=/home/user/Desktop/tst_rosvenv/rosvenv/test_ws/install; cd -

...............................................................................
Failed     << catkin_tools_prebuild:cmake          [ Exited with code 1 ]      
Failed    <<< catkin_tools_prebuild                [ 0.3 seconds ]             
[build] Summary: 0 of 1 packages succeeded.                                    
[build]   Ignored:   None.                                                     
[build]   Warnings:  None.                                                     
[build]   Abandoned: None.                                                     
[build]   Failed:    1 packages failed.                                        
[build] Runtime: 0.3 seconds total.                                            
bash: deactivatePyEnv: command not found
bash: /home/user/Desktop/tst_rosvenv/rosvenv/test_ws/devel/setup.bash: No such file or directory
Found conda env. Sourcing
ROS activated!
ROS-IP: 127.0.0.1
ROS MASTER URI: http://127.0.0.1:11311/

My suspicion is that the Conda env misdirects the search path somehow. This problem does not exist with venv initialized with --system-site-packages as that also looks through the packages that are included in the container.

vonHartz commented 5 months ago

At a quick glance, this seems to be because catkin appears to use the wrong python path.

Some relevant discussions: https://answers.ros.org/question/353111/following-installation-instructions-catkin_make-generates-a-cmake-error/ https://stackoverflow.com/questions/74934600/modulenotfounderror-no-module-named-em-despite-empy-being-installed-when-usin https://github.com/ysl208/iRoPro/issues/59

tld;dr: catkin_make -DPYTHON_EXECUTABLE=<PATH> needs to be set to the proper Python path.

I vaguely remember having a similar issue with catkin_make at some point, but I thought it did not happen with caking build. Need to look into it again..