Closed bacongobbler closed 6 years ago
GIF:
Here's the end result of my spelunking. When running
PS C:\Users\mafishe> draft init 2>&1 > init.log
Powershell exits after the error pops up in stderr. I failed to pipe stderr to stdout which is why init.log in the GIF does not show the error.
This is the final error message:
PS C:\Users\mafishe> cat .\init.log
Adding plugin https://github.com/Azure/draft-pack-repo...
draft : Error: symlink C:\Users\mafishe\.draft\cache\plugins\https-github.com-Azure-draft-pack-repo
C:\Users\mafishe\.draft\plugins\draft-pack-repo: A required privilege is not held by the client.
At line:1 char:1
+ draft init 2>&1 > .\init.log
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Error: symlink ... by the client.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Error: symlink C:\Users\mafishe\.draft\cache\plugins\https-github.com-Azure-draft-pack-repo
C:\Users\mafishe\.draft\plugins\draft-pack-repo: A required privilege is not held by the client.
My current thinking is that rootCmd.Execute() is exiting non-zero due to the NativeCommandError, causing powershell to exit when it should just return a non-zero exit code as VSCode's integrated terminal is doing. I'll see if I can debug this via gdb.
My power is out so I cannot get the proper error right now, but last night I was testing
draft init
on a windows box and I constantly found my powershell prompt exiting with no logs showing the error. Runningdraft init
from inside Visual Studio Code shows that the error indicated thatdraft plugin install https://github.com/Azure/draft-pack-repo
did not succeed because symbolic links can only be created when running as an administrator (or when the user is given the correct permissions to create symbolic links). According to documentation it is a security risk to grant regular users symlink permissions.Perhaps we should use an alternative solution such as using
os.Rename
to move the downloaded plugin from the cache to the plugin directory. We'd no longer have the advantage of saving the plugin in the cache directory, but it'd be portable across the three targeted OSes (macOS, Windows, Linux)In short, there's two actionable items here to look up:
1) See why
draft init
is causing powershell to close when failing to create symlink (uncaught error/upstream bug?) 2) Find alternative solutions toos.Symlink
for Windows usersI made a short GIF to demonstrate the powershell 🐛. I'll update this report once my power's back up.