colcon swallows failure details in shell extension
I expect to see useful failure information (e.g. stdout and stderr of the failed command, or even whether the target script exists) but colcon does not expose this info. It instead shows only the python stack trace which contains no actionable details.
Starting >>> test_rclcpp
[2245.139s] colcon.colcon_core.shell ERROR Exception in shell extension 'bat': Expected ['D:\\a\\colcon-cmake\\colcon-cmake\\ros_ws\\build\\test_rclcpp\\colcon_command_prefix_build.bat', '&&', 'set'] to pass
Traceback (most recent call last):
File "c:\hostedtoolcache\windows\python\3.7.8\x64\lib\site-packages\colcon_core\shell\__init__.py", line 289, in get_command_environment
task_name, Path(build_base), dependencies)
File "c:\hostedtoolcache\windows\python\3.7.8\x64\lib\site-packages\colcon_core\shell\bat.py", line 128, in generate_command_environment
env = await get_environment_variables(cmd, cwd=str(build_base))
File "c:\hostedtoolcache\windows\python\3.7.8\x64\lib\site-packages\colcon_core\shell\__init__.py", line 325, in get_environment_variables
output = await check_output(cmd, cwd=cwd, shell=shell)
File "c:\hostedtoolcache\windows\python\3.7.8\x64\lib\site-packages\colcon_core\subprocess.py", line 106, in check_output
assert not rc, 'Expected {args} to pass'.format_map(locals())
AssertionError: Expected ['D:\\a\\colcon-cmake\\colcon-cmake\\ros_ws\\build\\test_rclcpp\\colcon_command_prefix_build.bat', '&&', 'set'] to pass
[2245.139s] colcon.colcon_cmake.task.cmake.build ERROR Could not find a shell extension for the command environment
Failed <<< test_rclcpp [ Exited with code 1 ]
https://github.com/rotu/colcon-cmake/runs/1029201058?check_suite_focus=true#step:17:15262
Please provide reproducible steps.
Run this on a windows runner: https://github.com/rotu/colcon-cmake/actions/runs/224539412/workflow
Please provide more minimal steps which only involve the pieces necessary to reproduce the problem locally.
Sure. Just edit a shell hook to have a syntax error and observe that there is no debug info to speak of. The Python stack trace here should be suppressed as well, since the Python code is working as intended.
I may be naive. It seems that batch scripts don’t have “stack traces” as other languages do. The best solution for batch might just be to run the script with echo on and print the output if the script fails.
I expect to see useful failure information (e.g. stdout and stderr of the failed command, or even whether the target script exists) but colcon does not expose this info.
assert not rc, 'Expected {args} to pass'.format_map(locals())
You seem to be using an older version of colcon-core. The current code already includes the stderr output (even though that might or might not contain valuable information): https://github.com/colcon/colcon-core/blob/caee5e64608912f52e86f79de1cf53b8c34713df/colcon_core/subprocess.py#L109-L110. This has been added in #353.
The Python stack trace here should be suppressed as well, since the Python code is working as intended.
The Python exception is only visible error that something went wrong. I don't see how you could distinguish a failure caused by some colcon code vs. package specific content. And for the former case the stack trace is essential in debugging. If you have a specific proposal how to do better please feel free to describe it (or even better contribute a pull request).
Please re-run your use case with an up-to-date colcon-core package and share the resulting error message to determine if this can be closed.