Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for symlinked install on windows #6

Open
wants to merge 3 commits into
base: rolling
Choose a base branch
from

Conversation

dirk-thomas
Copy link
Contributor

@wjwwood Whenever you have time to try it.

@dirk-thomas dirk-thomas added the in progress Actively being worked on (Kanban column) label Mar 21, 2015
@dirk-thomas dirk-thomas self-assigned this Mar 21, 2015
@dirk-thomas dirk-thomas added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Mar 21, 2015
@tfoote
Copy link
Member

tfoote commented Mar 25, 2015

I tried running the build with

python src\ament\ament_tools\scripts\ament.py build --symlink-install

And I got the following error:

PostBuildEvent:
  setlocal
  C:\ProgramData\chocolatey\lib\cmake.3.1.3\content\cmake-3.1.3-win32-x86\bin\c
  make.exe -DBUILD_TYPE=Debug -P cmake_install.cmake
  if %errorlevel% neq 0 goto :cmEnd
  :cmEnd
  endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
  :cmErrorLevel
  exit /b %1
  :cmDone
  if %errorlevel% neq 0 goto :VCEnd
  :VCEnd
  -- Install configuration: "Debug"
  -- Symlinking: C:/Users/Administrator/work/test/install/local_setup.bash
   - Execute custom install script
  CMake Error at ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:
  287 (message):
    Could not create symlink
    'C:/Users/Administrator/work/test/install/local_setup.bash' pointing to
    'c:/users/administrator/work/test/build/ament_package/ament_package/templat
  e/prefix_level/local_setup.bash'
  Call Stack (most recent call first):
    ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:130 (_ament_c
  make_symlink_create_symlink)
    ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:299 (ament_cm
  ake_symlink_install_files)
    cmake_install.cmake:31 (include)


Build FAILED.

"C:\Users\Administrator\work\test\build\ament_cmake_core\INSTALL.vcxproj" (defa
ult target) (1) ->
(PostBuildEvent target) ->
  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.ta
rgets(132,5): error MSB3073: The command "setlocal\r [C:\Users\Administrator\wo
rk\test\build\ament_cmake_core\INSTALL.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: C:\ProgramData\chocolatey\lib\cmake.3.1.3\content\cm
ake-3.1.3-win32-x86\bin\cmake.exe -DBUILD_TYPE=Debug -P cmake_install.cmake\r [
C:\Users\Administrator\work\test\build\ament_cmake_core\INSTALL.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd\r [C:\Users\Admini
strator\work\test\build\ament_cmake_core\INSTALL.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: :cmEnd\r [C:\Users\Administrator\work\test\build\ame
nt_cmake_core\INSTALL.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :c
mDone\r [C:\Users\Administrator\work\test\build\ament_cmake_core\INSTALL.vcxpro
j]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: :cmErrorLevel\r [C:\Users\Administrator\work\test\bu
ild\ament_cmake_core\INSTALL.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: exit /b %1\r [C:\Users\Administrator\work\test\build
\ament_cmake_core\INSTALL.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: :cmDone\r [C:\Users\Administrator\work\test\build\am
ent_cmake_core\INSTALL.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd\r [C:\Users\Admini
strator\work\test\build\ament_cmake_core\INSTALL.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(132,5): error MSB3073: :VCEnd" exited with code 1. [C:\Users\Administrator\
work\test\build\ament_cmake_core\INSTALL.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.70

<== Command 'C:\Users\Administrator\work\test\build\ament_cmake_core\ament_cmake
__install.bat C:\Program Files (x86)\MSBuild\14.0\bin\amd64\msbuild.EXE C:\Users
\Administrator\work\test\build\ament_cmake_core\INSTALL.vcxproj' failed with exi
t code '1'

@dirk-thomas
Copy link
Contributor Author

Can you please look at the specific install command (ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:287), run it in a shell and check what it does / output / returncode?

@wjwwood
Copy link
Contributor

wjwwood commented Mar 25, 2015

You need elevated permissions to create symlinks on windows as well, see: https://docs.python.org/3.4/library/os.html#os.symlink (note about Windows and SeCreateSymbolicLinkPrivilege)

@dirk-thomas
Copy link
Contributor Author

Sure, but we could detect if the permission is available or not based on the error code. We can always fall back to:

  • a reasonable error / warning message
  • hard links
  • copying the file

But this needs to be debugged on Windows to gather the necessary information:

  • what the error codes when the permissions are not available?
  • are they different than for any other error?
  • if the CMake check IS_SYMLINK still working? also for hard links?

@wjwwood
Copy link
Contributor

wjwwood commented Mar 26, 2015

I just rebased and force pushed this branch so it has the latest changes.

@tfoote
Copy link
Member

tfoote commented Mar 26, 2015

I'm running as Administrator so don't have the permissions issues.

@wjwwood
Copy link
Contributor

wjwwood commented Mar 26, 2015

When running without "Run as administrator..." I get this:

+++ Building 'ament_copyright'
+++ Installing 'ament_copyright'
Traceback (most recent call last):
  File "src\ament\ament_tools\scripts\ament.py", line 111, in <module>
    sys.exit(main() or 0)
  File "C:\dev\ros2\src\ament\ament_tools\ament_tools\commands\ament.py", line 88, in main
    rc = args.main(args)
  File "C:\dev\ros2\src\ament\ament_tools\ament_tools\verbs\build\cli.py", line 138, in main
    iterate_packages(opts, packages, per_package_main)
  File "C:\dev\ros2\src\ament\ament_tools\ament_tools\verbs\build\cli.py", line 190, in iterate_packages
    rc = per_package_callback(opts)
  File "C:\dev\ros2\src\ament\ament_tools\ament_tools\verbs\build_pkg\cli.py", line 284, in main
    handle_build_action(on_install_ret, context)
  File "C:\dev\ros2\src\ament\ament_tools\ament_tools\verbs\build_pkg\cli.py", line 259, in handle_build_action
    build_action.cmd(context)
  File "C:\dev\ros2\src\ament\ament_tools\ament_tools\build_types\ament_python.py", line 393, in _install_action_python
    os.symlink(src, dst)
OSError: symbolic link privilege not held

I'm trying with admin now.

@wjwwood
Copy link
Contributor

wjwwood commented Mar 26, 2015

With admin:

  -- Install configuration: "Debug"
   - Execute custom install script
  -- Symlinking: C:/dev/ros2/install/local_setup.bash
  CMake Error at ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:287 (message):
    Could not create symlink 'C:/dev/ros2/install/local_setup.bash' pointing to
    'c:/dev/ros2/build/ament_package/ament_package/template/prefix_level/local_setup.bash'
  Call Stack (most recent call first):
    ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:130 (_ament_cmake_symlink_create_symlink)
    ament_cmake_symlink_install/ament_cmake_symlink_install.cmake:299 (ament_cmake_symlink_install_files)
    cmake_install.cmake:31 (include)

The IS_SYMLINK check in CMake doesn't appear to work on Windows, so I've
disable the shortcut check on Windows. Also, I've changed the error
checking on Windows and changed the way mklink is executed, instead
executing it with cmd /C.
This still doesn't work because the generator expressions are not
expanded in time to be used by execute_process. We might try using
add_custom_command instead which supposedly works with generator
expressions.
endif()
else()
string(REPLACE "/" "\\" symlink "${symlink}")
string(REPLACE "/" "\\" absolute_file "${absolute_file}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use file(TO_NATIVE_PATH for these kind of conversions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, but those lines may not end up being needed. This pull request isn't really ready for review since it isn't working yet.

@dirk-thomas dirk-thomas removed their assignment Mar 31, 2015
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Mar 31, 2015
@wjwwood
Copy link
Contributor

wjwwood commented Mar 31, 2015

This still doesn't work because the generator expressions are not expanded in time to be used by execute_process. We might try using add_custom_command instead which supposedly works with generator expressions.

However, this is not high priority so we're pushing it back to the backlog.

@dirk-thomas dirk-thomas force-pushed the master branch 2 times, most recently from d9277b7 to 85924cc Compare April 10, 2015 20:06
@clalancette clalancette added the enhancement New feature or request label Jul 14, 2017
@mikaelarguedas
Copy link
Contributor

@wjwwood @dirk-thomas what is the resolution on this? that symlink installation is not possible on Windows without admin privileges and that this PR should be closed?

@dirk-thomas
Copy link
Contributor Author

Imo this could still be implemented as described. When the user has the privilege create symlinks, otherwise either fail with a reasonable error message or fall back to not use symlinks.

@wjwwood
Copy link
Contributor

wjwwood commented Feb 22, 2018

I agree, so in light of that I think my previous comment still applies: currently doesn't work, might be fixed with another alternative, not high enough priority to try for now.

@mikaelarguedas
Copy link
Contributor

sounds good thanks for the follow-up

@hidmic
Copy link
Contributor

hidmic commented Oct 16, 2020

@dirk-thomas is this still a valid PR?

@dirk-thomas
Copy link
Contributor Author

It would still be a good feature to have on Windows. I am not planning to spend any time on it though.

@audrow audrow changed the base branch from master to rolling June 28, 2022 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants