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

install.cmd set %PATH% Failure #467

Open
1 of 28 tasks
meyerlee opened this issue Aug 11, 2019 · 2 comments
Open
1 of 28 tasks

install.cmd set %PATH% Failure #467

meyerlee opened this issue Aug 11, 2019 · 2 comments

Comments

@meyerlee
Copy link

If this is a question about how to use NVM4W, please use stackoverflow instead.

If this is an issue regarding antivirus, make sure you search the existing issues first.

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'm using NVM4W version:

  • [x ] 1.1.7
  • 1.1.6
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • Older
  • OTHER (Please Specify)

I have already...

  • read the README to be aware of npm gotchas & antivirus issues.
  • reviewed the wiki to make sure my issue hasn't already been resolved.
  • verified I'm using an account with administrative privileges.
  • searched the issues (open and closed) to make sure this isn't a duplicate.
  • made sure this isn't a question about how to use NVM for Windows, since gitter is used for questions and comments.

My issue is related to (check only those which apply):

  • settings.txt
  • proxy support (Have you tried version 1.1.0+?)
  • 32 or 64 bit support (Have you tried version 1.1.3+?)
  • Character escaping (Have you tried version 1.1.6+?)
  • A standard shell environment (terminal/powershell)
  • A non-standard shell environment (Cmder, Hyper, Cygwin, git)
  • [ x] install.cmd

Expected Behavior

PATH="%PATH%;%NVM_HOME%;%NVM_SYMLINK%"

Actual Behavior

PATH="%PATH%;;"

Steps to reproduce the problem:

setx /M ENV read it back immediately, %ENV% will been empty.

Modified:

@echo off
set /P NVM_PATH="Enter the absolute path where the zip file is extracted/copied to: "
set NVM_HOME=%NVM_PATH%
set NVM_SYMLINK=C:\Program Files\nodejs
setx /M NVM_HOME "%NVM_HOME%"
setx /M NVM_SYMLINK "%NVM_SYMLINK%"
setx /M PATH "%PATH%;%NVM_HOME%;%NVM_SYMLINK%"

if exist "%SYSTEMDRIVE%\Program Files (x86)" (
set SYS_ARCH=64
) else (
set SYS_ARCH=32
)
(echo root: %NVM_HOME% && echo path: %NVM_SYMLINK% && echo arch: %SYS_ARCH% && echo proxy: none) > %NVM_HOME%\settings.txt

notepad "%NVM_HOME%\settings.txt"
@echo on

@janstadt
Copy link

janstadt commented Aug 20, 2019

https://stackoverflow.com/a/35352014/4739810

Basically its due to the fact that setx by design, once set, will only persist for the next cmd window opened and not the current window.

I've been fighting with this for a while as well with the no-install on a docker image. What i've had to do is the following to get these variables to stick:

RUN [Environment]::SetEnvironmentVariable('NVM_HOME', 'C:\Users\ContainerAdministrator\AppData\Roaming\nvm', [System.EnvironmentVariableTarget]::Machine);
RUN [Environment]::SetEnvironmentVariable('NVM_SYMLINK', 'C:\Program Files\nodejs', [System.EnvironmentVariableTarget]::Machine);

RUN setx /M PATH $($Env:PATH + '%NVM_HOME%;%NVM_SYMLINK%;')
RUN echo "root:$Env:NVM_HOME`npath:$Env:NVM_SYMLINK`narch:64`nproxy:none" > $Env:NVM_HOME\settings.txt

Probably unrelated, but once i have all my env variables set up on the docker image, i run nvm install 10.15.3 and it seems to install the node stuff in the current working directory (for me it was C:). After installing and calling nvm use followed by nvm list it always tells me No installations recognized. It turns out that the whatever code parses the settings.txt file is incredibly explicit. Notice how i dont have a space between root:$Env. When running through the docker command like so: RUN echo "root: $Env:NVM_HOME`npath: $Env:NVM_SYMLINK`narch: 64`nproxy:none" > $Env:NVM_HOME\settings.txt it produced the following file:

root:
C:\Users\ContainerAdministrator\AppData\Roaming\nvm
path:
C:\Program Files\nodejs
arch:
64
proxy:none

Removing the spaces got them on the sasme line, but it must seem like the parsing logic (somewhere here:

for _, line := range lines {
) is looking for : (colon space).

Edit: I believe this is due to content encoding for echo within the docker commands. I can run that same command with spaces when running inside the docker container just fine.

@meyerlee
Copy link
Author

meyerlee commented Aug 21, 2019 via email

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