-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
mklink is not reliable on windows 10 #266
Comments
Do you not actually see the symlink after running |
1.Please delete the installation node by window10 uninstall program2.nvm install3.modification Environment Variables window(reference)Chinese interpretation: |
@coreybutler : No I do not see the symlink after running nvm use.
=> The whole point is to run it from powershell. Indeed I run a script that install lots of dependencies and configure the VM. Here is a subset of the script $wc = New-Object System.Net.WebClient
# configure repositories
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Get-Packageprovider -Name chocolatey
Set-PackageSource -Name Chocolatey -Trusted
Install-Package 7zip.install -ProviderName Chocolatey -RequiredVersion 16.02.0.20160811
$env:PATH+=";C:\Program Files\7-Zip"
$source = "https://github.com/coreybutler/nvm-windows/releases/download/1.1.3/nvm-setup.zip"
$archive = Join-Path $env:TEMP ($source.substring($source.lastindexOf('/') + 1))
$wc.DownloadFile($source, $archive)
echo "downloaded at: $archive"
7z x -aoa -y $archive "-o$env:TEMP"
#$uninstallScript = (Join-Path $PSScriptRoot uninstall_cmdline.ps1)
#&$uninstallScript -software "NVM for Windows*" | Out-Null
$nvmSetup = Join-Path $env:TEMP "nvm-setup.exe"
Start-Process $nvmSetup -ArgumentList @("/SILENT", "/SP-", "/SUPPRESSMSGBOXES") -Wait
ri $archive
ri $nvmSetup
$localNvmPath = Join-Path $env:APPDATA "nvm"
$defaultNodejsPath = "C:\Program Files\nodejs"
#Add-Path $localNvmPath
#Add-Env NVM_HOME $localNvmPath
ri $defaultNodejsPath -ErrorAction SilentlyContinue -Recurse -Force
nvm root $env:NVM_HOME
nvm install 4.5.0
nvm use 4.5.0
#create manually symlink if problem with nvm use, see https://github.com/coreybutler/nvm-windows/issues/266
#$nodePath = Join-Path $localNvmPath "v4.5.0"
#if ((-Not (Test-Path $nodePath) -or (-Not (Test-Path $defaultNodejsPath))))
#{
# Start-Process powershell -Verb runAs -ArgumentList "-WindowStyle Hidden", "-Command `"&{ New-Item -Path `'$defaultNodejsPath`' -Value `'$nodePath`' -ItemType SymbolicLink }`"" -Wait -WindowStyle Hidden
#} You should be able to put this script in a ps1 file and execute it as is. I commented Add-Env and Add-Path functions which respectively add variables to the env and folder location to the PATH. I also commented uninstall script call which basically uninstall nvm if any was installed before. I also commented the workaround I found: create the symlink manually. @youzaiyouzai666 : I spawn a fresh VM on Windows 10 Enterprise 64bits, there is no previous node installed. |
The Go version used for the repository development could not be found so the latest installation available was used. In doing so, some compile time errors appeared with regards to filepath and the Unzip function that had to be corrected. The Go exec module wraps the os.StartProcess functionality. The initial argument escaping appears to be correct, however, during the pipe writing when actually starting the process the command is escaped again in quotations making the command invalid. This makes the command fail and no symlink is created. This was verified by printing the resulting argument string by utilizing the same logic that makes the command line argument and escapes it. As this appears to be a Go library issue, a different tactic was attempted. In case of this failure, a backup mechanism has been put in place to use the os module to create the symlink directly. After much deliberation it was decided this backup mechanism should only be attempted when the initial attempt fails. The reasoning behind this is because the initial command request attempts to elevate the command which would give access to create the symbolic link in "Program Files", which is otherwise a protected folder. The os call could fail here due to insufficient permissions. Potentially fixes: coreybutler#281, coreybutler#266, coreybutler#30
Closing due to age. This has not surfaced as a problem since this was filed. If it still impacts anyone, please open a new issue with a reference to this one. |
My Environment
Windows 7 or below (not truly supported due to EOL - see wiki for details)
Windows 8
Windows 8.1
Windows 10
Windows 10 IoT Core
Windows Server 2012
Windows Server 2012 R2
Windows Server 2016
My Windows installation is non-English.
I have already...
My issue is related to (check only those which apply):
Expected Behavior
nvm use <version>
should create symlink at C:\Program Files\nodejs or at value provided in path argument in file settings.txtActual Behavior
The symlink is not always created, even if I run nvm use from an elevated shell.
Steps to reproduce the problem:
I'm prompted by elevate.cmd script, I answer yes, the symlink is not created
I don't know if it's related but I run
nvm use
from powershell.Also It's kinda random, on some windows 10 I have the problem, on others I don't.
I believe a good workaround would be to test if symlink is created after running cmd.exe mklink. If symlink is not present, run powershell command new-item to create the link
The text was updated successfully, but these errors were encountered: