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

VSCode on Windows needs elevated right to be able to create ./lib/STLinkedResources link files #2

Closed
olivierov opened this issue Apr 18, 2021 · 7 comments

Comments

@olivierov
Copy link

When launched without elevated access rights, VSCode on Windows is not able to create ./lib/STLinkedResources link files when the script is executed and generate a Cannot create symlink in directory error.

I don't know if the script can be executed as elevated while it's launched by a non-elevated instance of VSCode...

If it's not possible, could please mention to launch VSCode 'As Administrator' in the README.md?

Thank you

@jbaumann
Copy link
Owner

Could you please check whether the problem is to create the link in the directory (e.g. by creating a link to a file in the parent directory) or whether the problem is that the target file cannot be accessed?
I think that starting the script with admin rights (by elevating it) should only be the last resort.

@olivierov
Copy link
Author

Sorry, I don't know how to do that.
But, even if the target link file is accessible, without elevating VSCode, I have this error:
`SETUP_CUBEMX Error: Cannot create symlink in directory 'lib/STLinkedResources'
While if I run VSCode with Administrator privileges, it works.

@olivierov
Copy link
Author

To avoid this pb, I've changed the property of the shortcut of VSCode

image

@jbaumann
Copy link
Owner

Can you experiment with the access rights and the ownership of the directory? It looks as if there is some problem there that doesn't allow a normal user to create symlinks. To me it looks strange that you cannot create a symlink in a directory that you own...

@olivierov
Copy link
Author

In an administrator cmd console window I'm able to create a symlink using mklink.
In a standard user cmd console window I'm not allowed to create a symlink using mklink. It returns the following error:
You do not have sufficient privilege to perform this operation.

Searching more information, I found this Microsoft page in which we can read that for security reasons, elevating to administrator privileges is mandatory to create symbolic links.

@jbaumann
Copy link
Owner

jbaumann commented May 1, 2021

I now had the time to look at this. The explanation is very clear, Microsoft thinks that creating symbolic links is too dangerous for normal users. Thank you for the link to the Microsoft page explaining this.
I think there are two options:

  • Run VSCode with admin rights. I do not like this option because this way VSCode has by far too many rights.
  • Change the user rights to allow the creation of symbolic links. This seems to be possible, but I do not know how exactly this is done.

@olivierov
Copy link
Author

olivierov commented May 5, 2021

Change the user rights to allow the creation of symbolic links.
This seems to be possible, but I do not know how exactly this is done.

My account has Administrator access right and I cannot create a symbolic link in a 'standard' user context (neither VSCode nor Powershell). I have to run the mlink command in an 'Administrator' context to be allowed to create a symbolic link.

I tried using pyuac which sounds great... but I'm not able to setup it (I don't know Python very much).

@jbaumann jbaumann closed this as completed Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants