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

Could not create link: A required privilege is not held by the client #24

Open
sethreidnz opened this issue Oct 20, 2019 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@sethreidnz
Copy link
Contributor

When I ran the command to link a project I got an error that appears to be related to permissions on my machine. I ran again as admin and it worked. Not sure of a solution but perhaps it should be documented that this may occur? Or a more helpful error message like "You may need to link the project as administrator"

Ran command:

nulink link -p -l C:\dev\mg-invocation\Kotahi.MG.Invocation\Kotahi.MG.Invocation.csproj -p Kotahi.MG.Invocation
Failed to create symlink, reverting changes to package folders.

Fatal error: Attempted symbolic link action: create
- from path: [C:\Users\sethr\.nuget\packages\kotahi.mg.invocation\1.0.16\lib]
-   to path: [C:\dev\mg-invocation\Kotahi.MG.Invocation\bin\Debug]
Exception: NuLink.Cli.SymbolicLinkException: Attempted symbolic link action: create
- from path: [C:\Users\sethr\.nuget\packages\kotahi.mg.invocation\1.0.16\lib]
-   to path: [C:\dev\mg-invocation\Kotahi.MG.Invocation\bin\Debug] ---> System.IO.IOException: Could not create link: A required privilege is not held by the client
   at Murphy.SymbolicLink.SymbolicLink.create(String target, String path)
   at NuLink.Cli.SymbolicLinkWithDiagnostics.Create(String fromPath, String toPath) in /home/appveyor/projects/nulink-dr8wu/source/NuLink.Cli/SymbolicLinkWithDiagnostics.cs:line 13
   --- End of inner exception stack trace ---
   at NuLink.Cli.SymbolicLinkWithDiagnostics.Create(String fromPath, String toPath) in /home/appveyor/projects/nulink-dr8wu/source/NuLink.Cli/SymbolicLinkWithDiagnostics.cs:line 17
   at NuLink.Cli.LinkCommand.<>c__DisplayClass2_0.<Execute>g__PerformOperation|5() in /home/appveyor/projects/nulink-dr8wu/source/NuLink.Cli/LinkCommand.cs:line 74
   at NuLink.Cli.LinkCommand.Execute(NuLinkCommandOptions options) in /home/appveyor/projects/nulink-dr8wu/source/NuLink.Cli/LinkCommand.cs:line 30
   at NuLink.Cli.Program.ExecuteCommand(String commandName, NuLinkCommandOptions options, Boolean isValid) in /home/appveyor/projects/nulink-dr8wu/source/NuLink.Cli/Program.cs:line 111
@felix-b
Copy link
Member

felix-b commented Oct 21, 2019

Hi @sethreidnz, thanks for using NuLink!
You raise a good point.
Agree, it should be verified on all systems (also Linux and macOS) and documented.
Regarding the error message, I'd like to find a reliable way of determining that insufficient permissions were the root cause of the error (not by comparing exception message, which seems kind of unreliable to me).

@felix-b felix-b added the enhancement New feature or request label Oct 21, 2019
@sethreidnz
Copy link
Contributor Author

Sounds good. I really like this tool, and think that it should be part of nuget. Currently I've got a hectic schedule but if I find some time to think about this I'd be happy to try to improve this tool with you!

@quetzalcoatl
Copy link

Probably it tries to create a hardlink, not a junction - a difference between mklink /d and mklink /j

However, NuLink itself doesn't rely on mklink at all - it uses Murphy.SymbolicLink nuget, code of which seems to be gone, but from decompilation it seems it uses:

  • Win32.CreateSymbolicLink(str,str,0)
  • Win32.CreateSymbolicLink(str,str,1)
  • Win32.DeviceIoControl(......)
  • Win32.CreateFile(.....)
  • Win32.GetFinalPathNameByHandle(....)

I suppose the first 2 ones are this winapi function which frankly seems to always require elevation (so it creates a hardlink "/d", not a junction "/j") unless 'developer mode' is on. Which actually we could rely on, since it's rather common thing for NuLink users to be developers. But still I don't like it. I think a Junction should be enough here.

also FYI:

@quetzalcoatl
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants