colcon/colcon-core

Could not find a shell extension for the command environment

allbluelai opened this issue · 4 comments

Hello,
I follow the instructions in ROS2 Foxy Ubuntu source build, but it fails at Build the code in the workspace when I run the command:

colcon build --symlink-install

Result in:

Starting >>> ament_package
Starting >>> ament_lint                        
Starting >>> gtest_vendor                                                      
Starting >>> fastcdr                                           
Finished <<< gtest_vendor [2.19s]                              
Starting >>> gmock_vendor
Finished <<< fastcdr [2.91s]                                   
Starting >>> ament_cppcheck                                    
Finished <<< ament_package [6.21s]                             
Starting >>> ament_cmake_core
Finished <<< gmock_vendor [4.19s]                           
Finished <<< ament_lint [6.87s]                             
Starting >>> cyclonedds
Starting >>> ament_flake8                                       
Finished <<< ament_cppcheck [5.69s]                             
Starting >>> osrf_pycommon
Finished <<< ament_cmake_core [6.24s]                                     
Starting >>> ament_cmake_libraries
Finished <<< ament_flake8 [7.83s]                                    
Starting >>> ament_cmake_export_libraries                            
[34.521s] ERROR:colcon.colcon_core.shell:Exception in shell extension 'sh': Expected ['.', '/home/john/ros2_foxy/build/ament_cmake_libraries/colcon_command_prefix_build.sh', '&&', 'env'] to pass: /bin/sh: 3: /home/john/ros2_foxy/install/ame: not foundre/share/ament_cmake_core/environment/ament_prefix_path.sh: 
/bin/sh: 2: /home/john/ros2_foxy/install/ament_cmake_core/share/ament_cmake_core: not foundt/path.sh: 
/bin/sh: 6: /home/john/ros2_foxy/install/ament_cmake_core/share/ament_cmake_core/environment/path.sh: Syntax error: end of file unexpected (expecting "then")

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/shell/__init__.py", line 306, in get_command_environment
    return await extension.generate_command_environment(
  File "/usr/lib/python3/dist-packages/colcon_core/shell/sh.py", line 154, in generate_command_environment
    env = await get_environment_variables(cmd, cwd=str(build_base))
  File "/usr/lib/python3/dist-packages/colcon_core/shell/__init__.py", line 342, in get_environment_variables
    output = await check_output(cmd, cwd=cwd, shell=shell)
  File "/usr/lib/python3/dist-packages/colcon_core/subprocess.py", line 129, in check_output
    assert not rc, f'Expected {args} to pass: {stderr_data}'
AssertionError: Expected ['.', '/home/john/ros2_foxy/build/ament_cmake_libraries/colcon_command_prefix_build.sh', '&&', 'env'] to pass: /bin/sh: 3: /home/john/ros2_foxy/install/ament_cmake_core/share/ament_cmake_core/environment/ament_prefi: not found
/bin/sh: 2: /home/john/ros2_foxy/install/ament_cmake_core/share/ament_cmake_core: not foundt/path.sh: 
/bin/sh: 6: /home/john/ros2_foxy/install/ament_cmake_core/share/ament_cmake_core/environment/path.sh: Syntax error: end of file unexpected (expecting "then")


[34.524s] ERROR:colcon.colcon_cmake.task.cmake.build:Could not find a shell extension for the command environment
Failed   <<< ament_cmake_libraries [4.00s, exited with code 1]       
Aborted  <<< ament_cmake_export_libraries [1.12s]
Aborted  <<< osrf_pycommon [8.05s]                  
Aborted  <<< cyclonedds [48.3s]                                          

Summary: 8 packages finished [1min 13s]
  1 package failed: ament_cmake_libraries
  3 packages aborted: ament_cmake_export_libraries cyclonedds osrf_pycommon
  299 packages not processed

My machine (installed in VMware) info:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal

And it is a new OS with only ROS2 Foxy being installed (follow the instructions above).

The Python is:

$ python3 --version
Python 3.8.10

How could I build ROS2 foxy from source correctly?

Hi, there's something in your environment variables that the sh shell extension isn't able to parse. Please use the env command to dump your environment variables, redact any sensitive information, and share it with me here so that we can figure out what syntax is giving colcon trouble.

Here you go.
env.txt

Hello, @cottsay
I compiled ROS2 Humble Ubuntu source build on Ubuntu 22.04 and it works just fine.

I think ROS2 Foxy might have a problem.

In ROS2 Humble, I use the following build command:

colcon build --cmake-args -DBUILD_TESTING=OFF --packages-skip-build-finished --continue-on-error

I really don't know what was going wrong here, but I'm glad you were able to move forward. Feel free to reopen this ticket if the problem resurfaces.