ms-iot / ROSOnWindows

ROS on Windows Documentation Repository
https://aka.ms/ros/docs
MIT License
213 stars 49 forks source link

[Foxy] colcon build returns PermissionError WinError5 when trying to build any package. #448

Closed VinHub-Gitcent closed 11 months ago

VinHub-Gitcent commented 12 months ago

I am experiencing problems with colcon build. I am running it in x64 Native Tools Command Prompt for VS 2019 as admin. I get this error for every colcon build i was trying to create.

I am using ROS2 foxy for Windows. View the full Error Message below:

C:\dev\ros2_ws>colcon build --merge-install
[1.895s] root DEBUG Using proactor: IocpProactor
Starting >>> turtlesim
[1.911s] colcon.colcon_ros.prefix_path.catkin WARNING The path 'C:\opt\ros\foxy\x64\tools\vcpkg\installed\x64-windows' in the environment variable CMAKE_PREFIX_PATH doesn't exist
['"C:\\dev\\ros2_ws\\build\\turtlesim\\colcon_command_prefix_build.bat" && set']
--- stderr: turtlesim
Traceback (most recent call last):
  File "c:\opt\ros\foxy\x64\lib\site-packages\colcon_core\executor\__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)
  File "c:\opt\ros\foxy\x64\lib\site-packages\colcon_core\task\__init__.py", line 93, in __call__
    return await task_method(*args, **kwargs)
  File "c:\opt\ros\foxy\x64\lib\site-packages\colcon_ros\task\ament_cmake\build.py", line 59, in build
    rc = await extension.build(
  File "c:\opt\ros\foxy\x64\lib\site-packages\colcon_cmake\task\cmake\build.py", line 87, in build
    rc = await self._reconfigure(args, env)
  File "c:\opt\ros\foxy\x64\lib\site-packages\colcon_cmake\task\cmake\build.py", line 174, in _reconfigure
    completed = await run(
  File "c:\opt\ros\foxy\x64\lib\site-packages\colcon_core\task\__init__.py", line 177, in run
    completed = await colcon_core_subprocess_run(
  File "c:\opt\ros\foxy\x64\lib\site-packages\colcon_core\subprocess.py", line 81, in run
    rc, _, _ = await _async_check_call(
  File "c:\opt\ros\foxy\x64\lib\site-packages\colcon_core\subprocess.py", line 140, in _async_check_call
    process = await create_subprocess(
  File "asyncio\subprocess.py", line 236, in create_subprocess_exec
  File "asyncio\base_events.py", line 1630, in subprocess_exec
  File "asyncio\windows_events.py", line 385, in _make_subprocess_transport
  File "asyncio\base_subprocess.py", line 36, in __init__
  File "asyncio\windows_events.py", line 881, in _start
  File "asyncio\windows_utils.py", line 153, in __init__
  File "subprocess.py", line 854, in __init__
  File "subprocess.py", line 1307, in _execute_child
PermissionError: [WinError 5] Access is denied
---
Failed   <<< turtlesim [0.16s, exited with code 1]

Summary: 0 packages finished [0.42s]
  1 package failed: turtlesim
  1 package had stderr output: turtlesim

This is a really basic operation and should run out of the box when following the installation guide from: https://ms-iot.github.io/ROSOnWindows/GettingStarted/SetupRos2.html

Does Anyone has an idea why this error occures?

ooeygui commented 11 months ago

Hi there, I have not seen this specific issue before. I suspect that this may be blocked by a virus scanner?

VinHub-Gitcent commented 11 months ago

Hi thank you for your reply. I think the virus scanner is not interfering here. I wonder if the Warning:
WARNING The path 'C:\opt\ros\foxy\x64\tools\vcpkg\installed\x64-windows' in the environment variable CMAKE_PREFIX_PATH doesn't exist should occur here. This is what I got from the colcon log file, maybe this helps.

[0.572s] colcon DEBUG Command line arguments: ['c:\\opt\\ros\\foxy\\x64\\Scripts\\colcon', 'build', '--merge-install', '--event-handlers', 'console_direct+']
[0.572s] colcon DEBUG Parsed command line arguments: Namespace(ament_cmake_args=None, base_paths=['.'], build_base='build', catkin_cmake_args=None, catkin_skip_building_tests=False, cmake_args=None, cmake_clean_cache=False, cmake_clean_first=False, cmake_force_configure=False, cmake_target=None, cmake_target_skip_unavailable=False, continue_on_error=False, event_handlers=['console_direct+'], executor='parallel', ignore_user_meta=False, install_base='install', log_base=None, log_level=None, main=<bound method BuildVerb.main of <colcon_core.verb.build.BuildVerb object at 0x000000000406D1C0>>, merge_install=True, metas=['./colcon.meta'], packages_above=None, packages_above_and_dependencies=None, packages_above_depth=None, packages_end=None, packages_ignore=None, packages_ignore_regex=None, packages_select=None, packages_select_build_failed=False, packages_select_by_dep=None, packages_select_regex=None, packages_select_test_failures=False, packages_skip=None, packages_skip_build_finished=False, packages_skip_by_dep=None, packages_skip_regex=None, packages_skip_test_passed=False, packages_skip_up_to=None, packages_start=None, packages_up_to=None, packages_up_to_regex=None, parallel_workers=12, paths=None, symlink_install=False, test_result_base=None, verb_extension=<colcon_core.verb.build.BuildVerb object at 0x000000000406D1C0>, verb_name='build', verb_parser=<colcon_defaults.argument_parser.defaults.DefaultArgumentsDecorator object at 0x000000000406D670>)
[0.625s] colcon.colcon_core.package_discovery Level 1 discover_packages(colcon_meta) check parameters
[0.625s] colcon.colcon_core.package_discovery Level 1 discover_packages(recursive) check parameters
[0.625s] colcon.colcon_core.package_discovery Level 1 discover_packages(ignore) check parameters
[0.625s] colcon.colcon_core.package_discovery Level 1 discover_packages(path) check parameters
[0.625s] colcon.colcon_core.package_discovery Level 1 discover_packages(colcon_meta) discover
[0.625s] colcon.colcon_core.package_discovery Level 1 discover_packages(recursive) discover
[0.625s] colcon.colcon_core.package_discovery INFO Crawling recursively for packages in 'C:\dev\ros2_ws'
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extensions ['ignore', 'ignore_ament_install']
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extension 'ignore'
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extension 'ignore_ament_install'
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extensions ['colcon_pkg']
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extension 'colcon_pkg'
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extensions ['colcon_meta']
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extension 'colcon_meta'
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extensions ['ros']
[0.625s] colcon.colcon_core.package_identification Level 1 _identify(.) by extension 'ros'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(.) by extensions ['cmake', 'python']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(.) by extension 'cmake'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(.) by extension 'python'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(.) by extensions ['python_setup_py']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(.) by extension 'python_setup_py'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(build) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(build) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(build) ignored
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(install) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(install) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(install) ignored
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(log) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(log) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(log) ignored
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extension 'ignore_ament_install'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extensions ['colcon_pkg']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extension 'colcon_pkg'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extensions ['colcon_meta']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extension 'colcon_meta'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extensions ['ros']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extension 'ros'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extensions ['cmake', 'python']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extension 'cmake'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extension 'python'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extensions ['python_setup_py']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src) by extension 'python_setup_py'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extension 'ignore_ament_install'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extensions ['colcon_pkg']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extension 'colcon_pkg'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extensions ['colcon_meta']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extension 'colcon_meta'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extensions ['ros']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extension 'ros'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extensions ['cmake', 'python']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extension 'cmake'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extension 'python'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extensions ['python_setup_py']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials) by extension 'python_setup_py'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\ros_tutorials) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\ros_tutorials) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\ros_tutorials) ignored
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\roscpp_tutorials) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\roscpp_tutorials) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\roscpp_tutorials) ignored
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\rospy_tutorials) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\rospy_tutorials) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\rospy_tutorials) ignored
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extensions ['ignore', 'ignore_ament_install']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extension 'ignore'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extension 'ignore_ament_install'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extensions ['colcon_pkg']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extension 'colcon_pkg'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extensions ['colcon_meta']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extension 'colcon_meta'
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extensions ['ros']
[0.640s] colcon.colcon_core.package_identification Level 1 _identify(src\ros_tutorials\turtlesim) by extension 'ros'
[0.640s] colcon.colcon_core.package_identification DEBUG Package 'src\ros_tutorials\turtlesim' with type 'ros.ament_cmake' and name 'turtlesim'
[0.640s] colcon.colcon_core.package_discovery Level 1 discover_packages(recursive) using defaults
[0.640s] colcon.colcon_core.package_discovery Level 1 discover_packages(ignore) discover
[0.640s] colcon.colcon_core.package_discovery Level 1 discover_packages(ignore) using defaults
[0.640s] colcon.colcon_core.package_discovery Level 1 discover_packages(path) discover
[0.640s] colcon.colcon_core.package_discovery Level 1 discover_packages(path) using defaults
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'cmake_args' from command line to 'None'
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'cmake_target' from command line to 'None'
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'cmake_target_skip_unavailable' from command line to 'False'
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'cmake_clean_cache' from command line to 'False'
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'cmake_clean_first' from command line to 'False'
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'cmake_force_configure' from command line to 'False'
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'ament_cmake_args' from command line to 'None'
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'catkin_cmake_args' from command line to 'None'
[0.672s] colcon.colcon_core.verb Level 5 set package 'turtlesim' build argument 'catkin_skip_building_tests' from command line to 'False'
[0.672s] colcon.colcon_core.verb DEBUG Building package 'turtlesim' with the following arguments: {'ament_cmake_args': None, 'build_base': 'C:\\dev\\ros2_ws\\build\\turtlesim', 'catkin_cmake_args': None, 'catkin_skip_building_tests': False, 'cmake_args': None, 'cmake_clean_cache': False, 'cmake_clean_first': False, 'cmake_force_configure': False, 'cmake_target': None, 'cmake_target_skip_unavailable': False, 'install_base': 'C:\\dev\\ros2_ws\\install', 'merge_install': True, 'path': 'C:\\dev\\ros2_ws\\src\\ros_tutorials\\turtlesim', 'symlink_install': False, 'test_result_base': None}
[0.672s] colcon.colcon_core.executor INFO Executing jobs using 'parallel' executor
[0.687s] colcon.colcon_parallel_executor.executor.parallel DEBUG run_until_complete
[0.687s] colcon.colcon_ros.task.ament_cmake.build INFO Building ROS package in 'C:\dev\ros2_ws\src\ros_tutorials\turtlesim' with build type 'ament_cmake'
[0.687s] colcon.colcon_cmake.task.cmake.build INFO Building CMake package in 'C:\dev\ros2_ws\src\ros_tutorials\turtlesim'
[0.687s] colcon.colcon_core.plugin_system INFO Skipping extension 'colcon_core.shell.sh': Not used on Windows systems
[0.687s] colcon.colcon_core.shell INFO Skip shell extension 'powershell' for command environment: Not usable outside of PowerShell
[0.687s] colcon.colcon_ros.prefix_path.catkin WARNING The path 'C:\opt\ros\foxy\x64\tools\vcpkg\installed\x64-windows' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.787s] colcon.colcon_core.event_handler.log_command DEBUG Invoking command in 'C:\dev\ros2_ws\build\turtlesim': C:\Program Files\CMake\bin C:\dev\ros2_ws\src\ros_tutorials\turtlesim -DCMAKE_INSTALL_PREFIX=C:\dev\ros2_ws\install -G Visual Studio 16 2019
[0.803s] colcon.colcon_parallel_executor.executor.parallel DEBUG run_until_complete finished with '[WinError 5] Access is denied'
[0.803s] colcon.colcon_core.event_reactor DEBUG joining thread
[0.809s] colcon.colcon_core.plugin_system INFO Skipping extension 'colcon_notification.desktop_notification.notify2': 'notify2' not found
[0.809s] colcon.colcon_core.plugin_system INFO Skipping extension 'colcon_notification.desktop_notification.notify_send': Not used on non-Linux systems
[0.809s] colcon.colcon_core.plugin_system INFO Skipping extension 'colcon_notification.desktop_notification.terminal_notifier': Not used on non-Darwin systems
[0.809s] colcon.colcon_notification.desktop_notification INFO Sending desktop notification using 'win32'
[5.869s] colcon.colcon_core.event_reactor DEBUG joined thread
[5.869s] colcon.colcon_core.shell INFO Creating prefix script 'C:\dev\ros2_ws\install\local_setup.ps1'
[5.869s] colcon.colcon_core.shell INFO Creating prefix util module 'C:\dev\ros2_ws\install\_local_setup_util_ps1.py'
[5.884s] colcon.colcon_core.shell INFO Creating prefix chain script 'C:\dev\ros2_ws\install\setup.ps1'
[5.884s] colcon.colcon_core.shell INFO Creating prefix script 'C:\dev\ros2_ws\install\local_setup.bat'
[5.884s] colcon.colcon_core.shell INFO Creating prefix util module 'C:\dev\ros2_ws\install\_local_setup_util_bat.py'
[5.884s] colcon.colcon_core.shell INFO Creating prefix chain script 'C:\dev\ros2_ws\install\setup.bat'

What are your thoughts on this?

ooeygui commented 11 months ago

Thanks for the log. The warning is a red-herring. We preemptively put that in the path, in case a rosdep needs to use vcpkg. If you create that directory, the warning will go away. (We should have done that in setup, but it was broken at some point)

This line is suspect C:\Program Files\CMake\bin C:\dev\ros2_ws\src\ros_tutorials\turtlesim -DCMAKE_INSTALL_PREFIX=C:\dev\ros2_ws\install -G Visual Studio 16 2019

It looks like it is missing cmake.exe - it should be: `C:\Program Files\CMake\bin\cmake.exe C:\dev\ros2_ws\src\ros_tutorials\turtlesim -DCMAKE_INSTALL_PREFIX=C:\dev\ros2_ws\install -G Visual Studio 16 2019

I won't ask you to post the environment as it includes sensitive info. However, I would have expected it to use the one deployed in c:\opt\ros\foxy\x64\cmake.exe. Perhaps you have an environment overriding it?

VinHub-Gitcent commented 11 months ago

Thanks for your reply. I had an existing installation of CMAKE on my system. After uninstalling it and removing from PATH the colcon command works as intended. I still don't get why using another functional installation of Cmake crashes colcon, but the issue can be considered closed I think.

I wonder how I can have a second version of Cmake installed without it interfering with the colcon command of foxy. Maybe you can give me some idea for that.

Thanks again and best regards.

ooeygui commented 11 months ago

Thank you for closing the loop. I suspect that between versions of cmake the environment variable that's used to locate it changed behaviors? Or on Windows the environment variable behaves differently than on linux?

I'm glad it is working.