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

Issue with blank spaces in path #41

Closed
emartinpi opened this Issue Feb 17, 2015 · 53 comments

Comments

Projects
None yet
@emartinpi

emartinpi commented Feb 17, 2015

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

@bholloway

This comment has been minimized.

bholloway commented Feb 26, 2015

+1

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

@impaler

This comment has been minimized.

impaler commented Mar 15, 2015

+1 many windows installs have user names with spaces

@kirkouimet

This comment has been minimized.

kirkouimet commented Mar 24, 2015

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

1

@kirkouimet

This comment has been minimized.

kirkouimet commented Mar 24, 2015

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)

@PureKrome

This comment has been minimized.

PureKrome commented Apr 16, 2015

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

🙏 🙏 🙏 🙏 🙏 🙏 🙏 🙏 🙏 🙏 🙏 🙏 🙏

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

@coreybutler

This comment has been minimized.

Owner

coreybutler commented Apr 16, 2015

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.

@PureKrome

This comment has been minimized.

PureKrome commented Apr 17, 2015

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

@CMaso

This comment has been minimized.

CMaso commented Jun 9, 2015

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.

@mhchristensen

This comment has been minimized.

mhchristensen commented Aug 7, 2015

+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

@markbrownsword

This comment has been minimized.

markbrownsword commented Nov 19, 2015

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:\PROGRA1\nvm
path: C:\PROGRA
1\nodejs

@clmcgrath

This comment has been minimized.

Contributor

clmcgrath commented Jan 27, 2016

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

@codeimpossible

This comment has been minimized.

codeimpossible commented Feb 2, 2016

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

@coreybutler

This comment has been minimized.

Owner

coreybutler commented Feb 2, 2016

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

@kirkouimet

This comment has been minimized.

kirkouimet commented Feb 2, 2016

@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

@coreybutler

This comment has been minimized.

Owner

coreybutler commented Feb 2, 2016

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

@AntiCZ

This comment has been minimized.

AntiCZ commented Jul 28, 2016

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.

@coreybutler

This comment has been minimized.

Owner

coreybutler commented Jul 28, 2016

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

@picss

This comment has been minimized.

picss commented Aug 17, 2016

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 👍

@espoelstra

This comment has been minimized.

espoelstra commented Nov 2, 2016

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.

@SamHard

This comment has been minimized.

SamHard commented Nov 19, 2016

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.

@kyleshrader

This comment has been minimized.

kyleshrader commented Dec 13, 2016

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

@JeffUtz

This comment has been minimized.

JeffUtz commented Sep 6, 2017

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

@gabialex

This comment has been minimized.

gabialex commented Sep 9, 2017

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

Don't forget to restart Windows.

@psiddharth709

This comment has been minimized.

psiddharth709 commented Sep 24, 2017

error

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

@coreybutler

This comment has been minimized.

Owner

coreybutler commented Sep 25, 2017

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

@XepherX

This comment has been minimized.

XepherX commented Oct 23, 2017

+1 on this issue. Image of repro
+1 to @kirkouimet for the clever workaround

@angrycodepoet

This comment has been minimized.

angrycodepoet commented Dec 28, 2017

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.

@Eccenux

This comment has been minimized.

Eccenux commented Jan 4, 2018

@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).

@davidrosevear

This comment has been minimized.

davidrosevear commented Jan 15, 2018

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

@coreybutler

This comment has been minimized.

Owner

coreybutler commented Jan 15, 2018

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.

@seanpoulter

This comment has been minimized.

seanpoulter commented Jan 23, 2018

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.

@kriskornel

This comment has been minimized.

kriskornel commented Feb 9, 2018

I still get this issue

@coreybutler

This comment has been minimized.

Owner

coreybutler commented Feb 9, 2018

@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.

@seanpoulter

This comment has been minimized.

seanpoulter commented Feb 10, 2018

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.

@hlbglobal

This comment has been minimized.

hlbglobal commented Mar 21, 2018

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?

s-h-a-d-o-w added a commit to s-h-a-d-o-w/nvm-windows that referenced this issue May 21, 2018

Fixes coreybutler#41 - Issue with blank spaces in path
exec.Command() can't handle spaces, even when quoted.
Command has to be modified using SysProcAttr.
See also:
golang/go#15566

Plus: Minor refactoring - reordering of functions, more consistent capitalization, sorting of imports and whatnot.

s-h-a-d-o-w added a commit to s-h-a-d-o-w/nvm-windows that referenced this issue May 21, 2018

Fixes coreybutler#41 - Issue with blank spaces in path
Forgot some uses of exec.Command() outside of the "use" command.
@s-h-a-d-o-w

This comment has been minimized.

Contributor

s-h-a-d-o-w commented May 21, 2018

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

@tonysamperi

This comment has been minimized.

tonysamperi commented Jun 28, 2018

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

@ctsstc

This comment has been minimized.

ctsstc commented Jul 11, 2018

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! 🎉

s-h-a-d-o-w added a commit to s-h-a-d-o-w/nvm-windows that referenced this issue Aug 3, 2018

Fixes coreybutler#41 - Issue with blank spaces in path
Forgot some uses of exec.Command() outside of the "use" command.

coreybutler added a commit that referenced this issue Aug 11, 2018

Merge pull request #355 from s-h-a-d-o-w/master
Fixes #41 - Issue with blank spaces in path
@jtcotton63

This comment has been minimized.

jtcotton63 commented Sep 19, 2018

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?

@edenprojectde

This comment has been minimized.

edenprojectde commented Oct 29, 2018

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

EDIT: Fixed it via the ~1 trick.

@goranmandiccrs

This comment has been minimized.

goranmandiccrs commented Oct 31, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment