pfavr2 / install_ros2_rolling_on_mac_m1

Scripts and patches to install ros2_rolling on Mac M1
Apache License 2.0
26 stars 1 forks source link

Colcon build and Python 3.11 and 3.12 on the same machine - catkin_pkg #4

Open keshavwxyz opened 8 months ago

keshavwxyz commented 8 months ago

everything from the install.sh work except the build command. this is the error I am getting

Starting >>> ament_package
Starting >>> ament_lint
Starting >>> ament_cppcheck
Starting >>> gtest_vendor
Starting >>> fastcdr                                          
Starting >>> iceoryx_hoofs
Starting >>> osrf_pycommon
Starting >>> osrf_testing_tools_cpp
Finished <<< fastcdr [0.95s]                                  
Starting >>> google_benchmark_vendor
Finished <<< gtest_vendor [1.08s]                             
Starting >>> gmock_vendor
Finished <<< gmock_vendor [0.43s]                             
Starting >>> urdfdom_headers
Finished <<< osrf_testing_tools_cpp [1.58s]                   
Finished <<< google_benchmark_vendor [0.70s]                  
Starting >>> ament_pycodestyle
Starting >>> test_osrf_testing_tools_cpp
Finished <<< ament_cppcheck [2.04s]                           
Finished <<< osrf_pycommon [2.01s]
Finished <<< ament_package [2.11s]
Finished <<< ament_lint [2.11s]
Starting >>> ament_cmake_core                                            
Starting >>> ament_flake8
Finished <<< urdfdom_headers [0.83s]                                  
--- stderr: ament_cmake_core                                           
Traceback (most recent call last):
  File "/opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 22, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at cmake/core/ament_package_xml.cmake:95 (message):

  execute_process(/opt/homebrew/Frameworks/Python.framework/Versions/3.12/bin/python3.12
  /opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/cmake/core/package_xml_2_cmake.py
  /opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/package.xml
  /opt/ros/ros2_rolling/build/ament_cmake_core/ament_cmake_core/package.cmake)
  returned error code 1
Call Stack (most recent call first):
  cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  CMakeLists.txt:15 (ament_package_xml)

---
Failed   <<< ament_cmake_core [0.31s, exited with code 1]
Aborted  <<< ament_pycodestyle [1.10s]             
Aborted  <<< ament_flake8 [0.68s]
Aborted  <<< iceoryx_hoofs [2.84s]                 
Aborted  <<< test_osrf_testing_tools_cpp [1.26s]                              

Summary: 10 packages finished [5.30s]
  1 package failed: ament_cmake_core
  4 packages aborted: ament_flake8 ament_pycodestyle iceoryx_hoofs test_osrf_testing_tools_cpp
  1 package had stderr output: ament_cmake_core
  318 packages not processed

and this error is from the commented colcon build command

colcon build \
 --symlink-install \
 --merge-install \
 --packages-skip-by-dep python_qt_binding \
 --cmake-args \
   --no-warn-unused-cli \
   -DBUILD_TESTING=OFF \
   -DINSTALL_EXAMPLES=ON \
   -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \
   -DCMAKE_OSX_ARCHITECTURES="arm64" \
   -DCMAKE_PREFIX_PATH=$(brew --prefix qt@5):$(brew --prefix)

and the error

Starting >>> ament_package
Starting >>> ament_lint
Starting >>> ament_cppcheck
Starting >>> gtest_vendor
Starting >>> fastcdr                                          
Starting >>> iceoryx_hoofs
Starting >>> osrf_pycommon
Starting >>> osrf_testing_tools_cpp
Finished <<< gtest_vendor [1.10s]                             
Starting >>> gmock_vendor
Finished <<< gmock_vendor [0.53s]                             
Starting >>> google_benchmark_vendor
Finished <<< ament_lint [1.92s]                               
Starting >>> ament_flake8
Finished <<< ament_cppcheck [2.02s]                           
Finished <<< osrf_pycommon [2.04s]
Finished <<< ament_package [2.19s]                            
Starting >>> ament_cmake_core
Starting >>> urdfdom_headers
Starting >>> ament_pycodestyle                                
Finished <<< urdfdom_headers [2.30s]                              
--- stderr: ament_cmake_core                                      
Traceback (most recent call last):
  File "/opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 22, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at cmake/core/ament_package_xml.cmake:95 (message):

  execute_process(/opt/homebrew/Frameworks/Python.framework/Versions/3.12/bin/python3.12
  /opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/cmake/core/package_xml_2_cmake.py
  /opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/package.xml
  /opt/ros/ros2_rolling/build/ament_cmake_core/ament_cmake_core/package.cmake)
  returned error code 1
Call Stack (most recent call first):
  cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  CMakeLists.txt:15 (ament_package_xml)

---
Failed   <<< ament_cmake_core [2.64s, exited with code 1]
Aborted  <<< ament_pycodestyle [3.31s]                                       
Aborted  <<< ament_flake8 [3.71s]                                            
Aborted  <<< fastcdr [8.59s]                                                   
Aborted  <<< osrf_testing_tools_cpp [9.49s]         
Aborted  <<< iceoryx_hoofs [11.8s]                  
Aborted  <<< google_benchmark_vendor [16.1s]

Summary: 7 packages finished [20.0s]
  1 package failed: ament_cmake_core
  6 packages aborted: ament_flake8 ament_pycodestyle fastcdr google_benchmark_vendor iceoryx_hoofs osrf_testing_tools_cpp
  3 packages had stderr output: ament_cmake_core google_benchmark_vendor iceoryx_hoofs
  319 packages not processed

during some search I found out this is related to some catkin_pkg. So, I install catkin using this command

pip install catkin_pkg

and this was the notification

Requirement already satisfied: catkin_pkg in /opt/ros/python_venv/lib/python3.11/site-packages (1.0.0)
Requirement already satisfied: docutils in /opt/ros/python_venv/lib/python3.11/site-packages (from catkin_pkg) (0.20.1)
Requirement already satisfied: python-dateutil in /opt/ros/python_venv/lib/python3.11/site-packages (from catkin_pkg) (2.8.2)
Requirement already satisfied: pyparsing in /opt/ros/python_venv/lib/python3.11/site-packages (from catkin_pkg) (2.4.7)
Requirement already satisfied: setuptools in /opt/ros/python_venv/lib/python3.11/site-packages (from catkin_pkg) (59.6.0)
Requirement already satisfied: six>=1.5 in /opt/ros/python_venv/lib/python3.11/site-packages (from python-dateutil->catkin_pkg) (1.16.0)

and colcon command still didn't work with the same error then I tried installing catkin using conda conda install -c conda-forge catkin_pkg empy lark this is conda's result

Collecting package metadata (current_repodata.json): done
Solving environment: done

==> WARNING: A newer version of conda exists. <==
  current version: 23.5.2
  latest version: 23.9.0

Please update conda by running

    $ conda update -n base -c defaults conda

Or to minimize the number of packages updated during conda update use

     conda install conda=23.9.0

# All requested packages already installed.

after updating conda to 23.9.0 using conda install conda=23.9.0 conda catkin install command results were

Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/hat/miniconda3

  added / updated specs:
    - catkin_pkg
    - empy
    - lark

The following packages will be UPDATED:

  openssl              pkgs/main::openssl-3.0.11-h1a28f6b_2 --> conda-forge::openssl-3.1.4-h0d3ecfb_0 

The following packages will be SUPERSEDED by a higher-priority channel:

  ca-certificates    pkgs/main::ca-certificates-2023.08.22~ --> conda-forge::ca-certificates-2023.7.22-hf0a4a13_0 
  certifi            pkgs/main/osx-arm64::certifi-2023.7.2~ --> conda-forge/noarch::certifi-2023.7.22-pyhd8ed1ab_0 

Proceed ([y]/n)? y

Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

the colon build command error is

Starting >>> ament_package
Starting >>> ament_lint
Starting >>> ament_cppcheck
Starting >>> gtest_vendor
Starting >>> fastcdr                                          
Starting >>> iceoryx_hoofs
Starting >>> osrf_pycommon
Starting >>> osrf_testing_tools_cpp
Finished <<< fastcdr [1.04s]                                  
Starting >>> google_benchmark_vendor                          
Finished <<< gtest_vendor [1.22s]                             
Starting >>> gmock_vendor
Finished <<< osrf_testing_tools_cpp [1.61s]                   
Starting >>> urdfdom_headers
Finished <<< google_benchmark_vendor [0.70s]                  
Finished <<< gmock_vendor [0.61s]                             
Starting >>> ament_pycodestyle
Starting >>> test_osrf_testing_tools_cpp
Finished <<< osrf_pycommon [1.89s]                            
Finished <<< ament_package [2.02s]
Finished <<< ament_cppcheck [2.02s]                        
Finished <<< ament_lint [2.07s]
Starting >>> ament_cmake_core
Starting >>> ament_flake8
Finished <<< urdfdom_headers [0.89s]                                     
--- stderr: ament_cmake_core
Traceback (most recent call last):
  File "/opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 22, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at cmake/core/ament_package_xml.cmake:95 (message):

  execute_process(/opt/homebrew/Frameworks/Python.framework/Versions/3.12/bin/python3.12
  /opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/cmake/core/package_xml_2_cmake.py
  /opt/ros/ros2_rolling/src/ament/ament_cmake/ament_cmake_core/package.xml
  /opt/ros/ros2_rolling/build/ament_cmake_core/ament_cmake_core/package.cmake)
  returned error code 1
Call Stack (most recent call first):
  cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  CMakeLists.txt:15 (ament_package_xml)

---
Failed   <<< ament_cmake_core [0.54s, exited with code 1]
Aborted  <<< ament_pycodestyle [0.86s]             
Aborted  <<< ament_flake8 [0.67s]
Aborted  <<< iceoryx_hoofs [2.83s]                 
Aborted  <<< test_osrf_testing_tools_cpp [1.21s]                              

Summary: 10 packages finished [5.42s]
  1 package failed: ament_cmake_core
  4 packages aborted: ament_flake8 ament_pycodestyle iceoryx_hoofs test_osrf_testing_tools_cpp
  1 package had stderr output: ament_cmake_core
  318 packages not processed
pfavr2 commented 8 months ago

Thank you for filing this issue.

I think this is related to Python 3.11 and 3.12 installed simultaneously by brew on you machine?

Please try

brew uninstall python@3.12

And see if it helps?

keshavwxyz commented 8 months ago

Bro I am such an idiot. IT'S WORKING THE BUILD IS WORKING *by the way how did you sort out the problem?

keshavwxyz commented 8 months ago

Now it failed again with rosidl_generator_dds_idl

Starting >>> rosidl_generator_dds_idl          
--- stderr: mimick_vendor                      
/opt/ros/ros2_rolling/build/mimick_vendor/mimick_vendor-prefix/src/mimick_vendor/src/asm/trampoline-aarch64.S:80:19: error: unexpected token in '.section' directive
.section .note.GNU-stack, "", @progbits
                  ^
make[5]: *** [CMakeFiles/mimick.dir/src/asm/trampoline-aarch64.S.o] Error 1
make[4]: *** [CMakeFiles/mimick.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [mimick_vendor-prefix/src/mimick_vendor-stamp/mimick_vendor-build] Error 2
make[1]: *** [CMakeFiles/mimick_vendor.dir/all] Error 2
make: *** [all] Error 2
make: INTERNAL: Exiting with 10 jobserver tokens available; should be 8!
---
Failed   <<< mimick_vendor [10.0s, exited with code 2]
pfavr2 commented 8 months ago

A friend had the same problem so were already looking into it.

Please try ./clean.sh and in a new terminal try ./install.sh again.

Let me know if the problem persists!

makeecat commented 8 months ago

The problem is caused by brew install opencv, which the latest version relies on python@3.12.

pfavr2 commented 8 months ago

A workaraound is to uninstall python3.12 while building ROS2.

I would like a patch to fix the build so that it works regardless. Maybe I can do it later myself when I have time for it.

pfavr2 commented 6 months ago

Workaround:

To temporarily uninstall python3.12 without affecting other packages do:

brew uninstall --ignore-dependencies python@3.12

Then do ./clean.sh; ./install.sh

pfavr2 commented 4 months ago

I've added a check for python@3.12 to the install script. It is not a good solution but works for now.