colcon / colcon-core

Command line tool to build sets of software packages
http://colcon.readthedocs.io
Apache License 2.0
103 stars 46 forks source link

Building ROS2 Foxy Argument List Too Long #485

Closed yameatmeyourdead closed 2 years ago

yameatmeyourdead commented 2 years ago

Building ROS2 Foxy on 5.10.98-1Manjaro Somewhat following this guide from AUR (only change is symlink install rather than merge)

Command that fails $ COLCON_LOG_LEVEL=warn colcon build --symlink-install Results in: AssertionError: Expected ['.', '/home/yameat/ros2_ws/build/ament_lint_common/colcon_command_prefix_build.sh', '&&', 'env'] to pass: /bin/sh: line 1: /usr/bin/env: Argument list too long

log.txt

Note: I changed ulimit to 65536 using $ ulimit -s 65536 thinking it might help. No change In new terminal session $ ulimit -s prints 8192 and running $ . /home/yameat/ros2_ws/build/ament_lint_common/colcon_command_prefix_build.sh && env results in bash: /usr/bin/env: Argument list too long.

cottsay commented 2 years ago

This is a common issue on Windows as well. Using a merge install would almost certainly alleviate this issue, and it is not mutually exclusive with --symlink-install.

yameatmeyourdead commented 2 years ago

Just got around to trying this again. Building with merge install did not alleviate this issue. Same error message as before

cottsay commented 2 years ago

I thought more about this issue, and it's ringing some bells. We had an old issue on systems which stored bash functions in the environment, and I'm wondering if there's a really big one in your environment somewhere. Could you take a look at the colcon-command_prefix_build.sh file and look for any large variables being defined?

yameatmeyourdead commented 2 years ago

Making some progress on the issue. I've found that running $ . /home/yameat/ros2_ws/build/ament_lint_common/colcon_command_prefix_build.sh && env seems to duplicate member strings of the $PATH environment variable, resulting in the environment variables being longer than $MAX_ARG_STRLEN. Selectively ignoring this package results in another ament package failing for the same reason.

yameatmeyourdead commented 2 years ago

Looks like I've solved the issue! monitoring PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash -xl 7>&2 allowed me to notice that my path variable was being exported from /etc/profile while somehow containing itself. Quick and dirty check at the end to remove any references in path to itself fixed the issue and ament_* now builds successfully.

danicannt commented 1 year ago

I am having the same error while trying to compile in some packages and I don't get exactly why. I have checked the Path Variable and it looks like this:

/usr/local/cuda/bin:/opt/ros/galactic/bin:/home/dcanton/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/dcanton/.local/bin