Nvm-windows: Issue with blank spaces in path

Created on 17 Feb 2015  ·  71Comments  ·  Source: coreybutler/nvm-windows

Hello! I'm having a problem when i'm trying nvm use <node_version>
captura
Sorry for the spanish language in screenshot. It means "c:\Users\Edu" is not recognise as an internal command... bla bla bla.
My user name is "Edu Martin" and my path is "c:\Users\Edu Martin\AppData\Roaming\nvm"
Is it possible to be an error with black spaces in the path?? All settings in my app are standard

Most helpful comment

So a fix to this is to edit your settings.txt and use the alternate Windows folder naming scheme which does not have spaces, which for my case was:

2

(settings.txt is in AppData\Roaming\nvm by default)

All 71 comments

+1

Workaround for me was to uninstall and then reinstall for Public user. Not ideal but happy to be running NVM on windows!

+1 many windows installs have user names with spaces

+1 for this, ran into this same issue with my username

1

So a fix to this is to edit your settings.txt and use the alternate Windows folder naming scheme which does not have spaces, which for my case was:

2

(settings.txt is in AppData\Roaming\nvm by default)

@coreybutler can we please have a fix for this, please please please?

:pray: :pray: :pray: :pray: :pray: :pray: :pray: :pray: :pray: :pray: :pray: :pray: :pray:

here's a gif to try and co-coerce you...

My build environment has changed recently/substantially, so the problem is releasing the binaries (I had a really customized build script). I'd be happy to add the fix to the master branch, it would just require building from source.

I have to head to the UK next week, but when I return to the US I'll address this as soon as I can.

That would be lovely @coreybutler :) Also, maybe we can link the next build (with this patch) to #17 etc?

I was having this problem because it wanted to use "C:\Documents and Settings(my name)\Application Data\nvm" as the root. So what I did was reinstall nvm, specifying "C:\" as the root instead of the default during the install, so it's now storing all the versions of Node in "C:\nvm", which of course has no spaces in the path. Settings.txt confirms this as the root. I just needed to remember to cd to C:\ before using any of the nvm commands, else it threw an error saying it can't find settings.txt. In my case, since C:\ isn't associated with any one user, when I switch to a version of Node using "nvm use <version>" it asks me which user account I want to use to run the program. But it seems to be running fine; I'm getting the "now using node <version>" message.

+1 For anyone wanting to do the workaround editting the settings.txt you can try this from command line to get the correct formatted path

cmd /c for %A in ("C:\Users\My Name With Spaces\AppData\Roaming\nvm") do @echo %~sA

Installing nvm-windows into Program Files also causes this error. Updating settings.txt as below resolves the issue, but it would be nice to get this fixed, or added to the ReadMe as a 'Gotcha'!

root: C:\PROGRA~1\nvm
path: C:\PROGRA~1\nodejs

using a symbolic junction link on windows i found is a suitable workaround to this problem as well
use something like this
mklink /J nvm_home "C:\Users\Chris McGrath\AppData\Roaming\nvm"

then up date settings.txt with the junction address

once i created this link switching started working with out any problems

So this issue has been open for almost a year. Is nvm-windows dead?

@codeimpossible - Not dead, I've just had higher life priorities to deal with. I'll post a note about it in gitter.

@coreybutler just wanted to let you know I use nvm-windows every day and appreciate all of the hard work you put into the project

@kirkouimet Thanks... thrilled to hear it is helpful!

Hi coreybutler, great job with nvm. This is really making my life easier :D

But can you write anywhere info about the space? Something like

"If you have a space in your user name change default directory used by the installer and choose path without a space."

I have never edit wiki on github. I have a little fear what I can do.

@AntiCZ - Good idea. I added a common issues page to address this. I'll continue to add to this as neccessary.

I solve mine using:
cmd /c for %A in ("C:\Users\My Name With Spaces\AppData\Roaming\nvm") do @echo %~sA
by @mhchristensen .
And then change the root in the setting.txt
Thanks a lot :+1:

Without a space in $env:USERPROFILE are people still having problems with the nodejs path having spaces in Program Files? I'm not seeing the same behavior on my Windows 2012R2 VM.

I'm going to test with a user with a space in the name to see if that is causing a cascading failure of some sort. It would be great to get some OS versions and which cmd prompt you are using (PowerShell/CMD/Bash4Windows/GitBash).

Right now I'm refactoring a Chocolatey package somebody created for nvm and hope to publish it soon. It avoids the installer and uses the chocolatey install path which doesn't have spaces, and I haven't had any issues with the node path having spaces in the settings.txt file.

I had almost this same issue, except my user name has an ampersand (&) instead of a space. In this situation, using the alternate folder name didn't help, because even the short name still has the ampersand. However, creating a symbolic link, as @clmcgrath suggested, was a good workaround for me.

Just install it to a directory without anything special. For example: C:\nvm\

Also why the NVM package on Chocolatey is using the C:\ProgramData\nvm path since that is the Program Files equivalent of "All Users" but without spaces.

This can be worked around by using alternate names for folders or files with spaces. For instance, I have nvm installed in "C:\Programs Files\nvm". Go to the folder above the ones with the space and use the /X option to get a directory listing with antique 8.3 names:

cd \
dir /X

I got a line that looks like...

2/15/2017 03:44 PM \

Then just edit the settings.txt file (in \Programs Files\nvm in my case) and edit the offending folder name:

root: C:\Progra\~1\nvm
path: C:\Progra\~1\nodejs

(This is the same solution @markbrownsword gave over a year ago, but his message got a bit misformatted by the markdown engine.)

windows

move to path there without whitespace

or

running cmd as administrator
and then mklink it to the new path there without whitespace.

@coreybutler Any news regarding this issue? I just got hit with it. I'm willing to PR it if you tell me what to look for :)

I've just pre-released v1.1.6, which leverages a new path management system in Go 1.8.3. All of my local tests are working with spaces and special characters in paths, but I can only test on an English install of Windows 10 at the moment. I'm hoping a few folks who have experienced this issue can test it out. Assuming the issue is resolved, I'll release 1.1.6 officially as a fix.

TBH i haven't had this issue happen in a number of releases now , been pretty smooth for a year or so now

@clmcgrath - glad to hear it!

For clarification, my primary curiosity is with non-English installations, which were producing some hidden characters Go recognized as a string terminator.... it was cutting the path off prematurely.

Still doesn't work. I tried changing setting.txt that did't help either.

@chillerfx - Do any commands run, or is it just nvm use failing? Also, what locale is your environment (non-English?)

On my windows 7 OS, 'nvm list' works but 'nvm use ' does not work. My locale is English. Also changing settings.txt to use ~1 due to the space in the username is not working. When this is done nvm list also does not work.

My setup:

nvm v1.1.6
Windows 10 Pro (version 1703, build 15063.540)
Locale: English (UK)

Still having this issue. nvm install latest works but nvm use 8.4.0 fails. My username has a space in it like "John Smith" and the error I get is exit status 1: 'C:\Users\John' is not recognized as an internal or external command, operable program or batch file.

Everything (list, use, install) works when edit my settings file as @ryan-mcguire suggests though.

Can those having issues run nvm root and report what is printed?

nvm root: C:\Users\Jeff Utz\AppData\Roaming\nvm

My setup:

nvm v1.1.6
Windows 10 Pro (1703, build 15063.540)
Locale: English (US)

All commands work with the exception of nvm use ... nvm on will enable nvm but then give the exit status 1 error

Try to use the shortened path name.
To find the shortened path:
C:\Users
dir /x

Don't forget to restart Windows.

error

how to solve error ??please share your ans..

@psiddharth709 - please stop posting the same question in multiple issues.

I dig the c:\nvm solution. I like having my stuff, esp. on Windows in a folder I can easily find it (c:\xammp is my apache server). Did it that way and all is well. Thanks for the hard work.

@coreybutler You can test the issue by installing nvm in any folder with space character. E.g. in C:\Program files\nvm (the error is as shown by XepherX above -- "'C:\Program' is not recognized...").

My guess is the problem is with running elevate.cmd with exec.Command. I'm not sure because I don't know how to debug Go. But when I rename elevate.cmd I get an error about missing file and when I restore elevate.cmd I get the error with "'C:\Program' is not recognized..."

So this does not seem to be a problem with a character set. And the problem occurs both in Windows 7 and Windows 10. Even if cmd is already elevated (Run as administrator).

@coreybutler Unfortunately, still the same issue for me as with everyone else in this issue, even using the 1.1.6 pre-release version.

Thanks everyone! My apologies for the delays in getting a new version out.... I'm still swamped (and hiring).

@Eccenux - you may be onto something there. I'll review the elevate.cmd. Go is compiled, so debugging happens pre-build. I think the elevate command is a more likely culprit, but will confirm first chance I get.

I've had the same issue as @davidrosevear. nvm install worked with 1.1.6, but nvm use did not. Let me know if I can help at all @coreybutler.

I still get this issue

@seanpoulter and anyone else interested in helping out....

I have a great problem - _lots_ of new clients flowing into my consulting company. The problem: abnormally little time to work on anything else. Any extra eyes that could take a look at this issue would be greatly appreciated. I still haven't had a chance to look into @Eccenux's suggestion re: elevate.cmd, but I think that's the starting point. 1.1.6 has a bunch of native go character escaping, so my gut says the problem isn't with Go... but the elevate command doesn't get tested with the rest of the code.

Congrats! That's a great problem to have indeed.

Let's look at a community solution and PR for this one while @coreybutler's busy. I've got a big PR to review on another repo (vscode-jest), so it'll be a bit before I can dive into this one myself.

those shortented file versions don't work and neither does installing R in a path with a space
How can we fix these problems. If we install R in a different directory will it still use the path varaible for anything else?

As it's been a while since the last release here, I decided to publish one containing the fix I submitted just before on my fork in the meantime:
https://github.com/s-h-a-d-o-w/nvm-windows/releases/tag/1.1.7

I resolved by moving it to C:nvm, but I'd like to know if any fixes is planned....

Thanks @s-h-a-d-o-w just installed your version coming from v 1.1.6 with my username being "Cody Swartz" in my path I was getting the same error everyone else was getting and your fix looks clean and to the point. Now nvm use works! 🎉

I just downloaded and installed nvm for windows for the first time today and ran into this issue. I'm running version 1.1.7. Is there something I'm missing here? Shouldn't this have been fixed for v1.1.6 and later?

Also having this problem. Making the whole thing pretty much not usable.

EDIT: Fixed it via the ~1 trick.

So a fix to this is to edit your settings.txt and use the alternate Windows folder naming scheme which does not have spaces, which for my case was:

Just to expand on this more precisely, the conversion is as follows: C:\Users\John Doe -> C:\Users\JOHND~1

The bug still remains. It's not solved. Using nvm 1.17

root: C:\PROGRA1nvm
path: C:\PROGRA1\nodejs

The config above mentioned earlier in this thread is wrong, or does not work for me at least ... ;)
For anyone who stumbles upon this issue.
When you have installed nvm and nodejs in C:\Program Files just use the following config in settings.txt and it should work.

root: C:\PROGRA~1\nvm
path: C:\PROGRA~1\nodejs

@Laslo89 has the right answer, replacing the space with ~ works well

So a fix to this is to edit your settings.txt and use the alternate Windows folder naming scheme which does not have spaces, which for my case was:

2

(settings.txt is in AppData\Roamingnvm by default)

A quick note for those lacking general tech ability like me. If you use dir *. /x in the command prompt it will list out the directories within the current location giving you the 8.3 form name in the middle column. You can then use this to change the settings as outlined above. Though, as mentioned earlier, Program Files becomes PROGRA~1.

which website provide ionic related latest tutorial.? please tell me.....

>

how is this issue still not fixed?! If it is a regression in 1.1.7, maybe think about adding a few integration/unit/regression tests to cover the not-so-uncommon case of spaces in windows (or linux for that matter) path names before releasing it...

Do you guys need support on this or is there already someone actively working on this?

@julian-becker, first off I'd like to call you out your aggressive start:

how is this issue still not fixed?!

It's rude. Folks in the open source community don't owe you any of their time or attention. What makes your spare time any more precious than the maintainers, or ours? It seems like you didn't spend the time to see that @coreybutler has already answered your question here:

I have a great problem - lots of new clients flowing into my consulting company. The problem: abnormally little time to work on anything else.

You also missed the solution and fork that @s-h-a-d-o-w shared.

Second, you've got a great game plan for how this should be done. Do it! If you've got the time, everyone watching this issue will appreciate it being fixed. Have a look at what @s-h-a-d-o-w has done, add the tests, get a PR going, and reach out here for help with the code-review. Someone is self-interested enough to help get'r done. Good luck, and reach out here if you need some help! 👏

get a PR going

To avoid possible confusion and work being done twice, I'd like to note that my fix was already merged, it's just a matter of actually releasing it.

Perfect! I didn't have that much time to read either. 😆

@s-h-a-d-o-w Just ran into this problem again, any idea when it will be released?

@coreybutler Would you mind linking to the release in my fork in a final post here and then locking this thread? I don't think that there is a need to discuss it further...

@coreybutler may it be possible to do the release?

Please release this :)

Using the fork released by s-h-a-d-o-w (see link above) worked for me as the only thing. Big thanks!

I've linked to @s-h-a-d-o-w 's release in common issues.

Sorry it is taking me so long to cut a release. I know it seems straightforward, but time has been brutal for me. Maybe I'll write about it someday.

1.In cmd, go to your home directory and type dir/x to see the shortened name for this folder
2.Then replace your user name with this shortened name in the setting.txt
3.It works

+1 For anyone wanting to do the workaround editting the settings.txt you can try this from command line to get the correct formatted path

cmd /c for %A in ("C:\Users\My Name With Spaces\AppData\Roamingnvm") do @echo %~sA

Thanks a lot this thing saved my life.

Solved!!

For someone who is not able to work with ~1 method by @kirkouimet (Thanks mate)
Open CMD go to the Users folder and Get the Shortened Folder name.

and type

> dir\x

Annotation 2020-05-25 112714

Now later after copying or Noting down the folder name
Annotation 2020-05-25 113201

Hope it helps

Solved!!

For someone who is not able to work with ~1 method by @kirkouimet (Thanks mate)
Open CMD go to the Users folder and Get the Shortened Folder name.

and type

> dir\x

Annotation 2020-05-25 112714

Now later after copying or Noting down the folder name
Annotation 2020-05-25 113201

Hope it helps

Thank you, everyone, that suggested the settings.txt solution but specially Swarag-N for such a thorough explanation. I am glad I landed here and not changed my user profile folder name.
Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flpms picture flpms  ·  4Comments

janpio picture janpio  ·  3Comments

AllainPL picture AllainPL  ·  7Comments

ctsstc picture ctsstc  ·  3Comments

thany picture thany  ·  4Comments