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

Fresh install of NVM error due to CRLF newlines #728

Closed
phillipsj opened this issue Apr 14, 2015 · 26 comments
Closed

Fresh install of NVM error due to CRLF newlines #728

phillipsj opened this issue Apr 14, 2015 · 26 comments
Labels
OS: ubuntu OS: windows pull request wanted This is a great way to contribute! Help us out :-D

Comments

@phillipsj
Copy link
Contributor

After installation I receive the error. Not very good with BASH.

command not found
command not found
line 11: syntax error near unexpected token '$'{\r''
line 11: 'nvm_has() {
@ljharb
Copy link
Member

ljharb commented Apr 14, 2015

What OS and shell are you using? Can you confirm that you installed nvm using the curl command in the readme?

@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Apr 14, 2015
@phillipsj
Copy link
Contributor Author

Yes I installed using the curl command in the README.

OS: Xubuntu 14.04.2 LTS
Shell: BASH

@ljharb
Copy link
Member

ljharb commented Apr 14, 2015

Thanks - at what step did you receive the error?

@phillipsj
Copy link
Contributor Author

The install went perfect like I have done a dozen times. When I reload my shell to read my bashrc it throws the error when reading nvm.sh.

@ljharb
Copy link
Member

ljharb commented Apr 14, 2015

Hmm, the \r in the error message suggests that there's a Windows line feed. Let me see if I can remove it.
edit: I don't see any \r characters in install.sh or nvm.sh.

@ljharb
Copy link
Member

ljharb commented Apr 14, 2015

@phillipsj on the command line, if you type . $NVM_DIR/nvm.sh, what's the output?

@phillipsj
Copy link
Contributor Author

jamie@xubu:$ $NVM_DIR/nvm.sh
/home/jamie/.nvm/nvm.sh: line 8: $'\r': command not found
/home/jamie/.nvm/nvm.sh: line 10: $'\r': command not found
/home/jamie/.nvm/nvm.sh: line 11: syntax error near unexpected token $'{\r'' 'home/jamie/.nvm/nvm.sh: line 11:nvm_has() {
jamie@xubu:
$ . $NVM_DIR/nvm.sh
: command not found
: command not found
bash: /home/jamie/.nvm/nvm.sh: line 11: syntax error near unexpected token $'{\r'' 'ash: /home/jamie/.nvm/nvm.sh: line 11:nvm_has() {
jamie@xubu:~$

@ljharb
Copy link
Member

ljharb commented Apr 14, 2015

The first command definitely shouldn't work at all, since it's not executable nor does it have a shebang.

The second, however, definitely should. Can you try deleting nvm.sh and rerunning curl https://raw.githubusercontent.com/creationix/nvm/v0.24.1/install.sh | bash?

@phillipsj
Copy link
Contributor Author

Just try reinstalling and I am still getting the same error.

@ljharb
Copy link
Member

ljharb commented Apr 15, 2015

@phillipsj The odd part is that you said you've used nvm before just fine on this machine - what does bash --version output?

@phillipsj
Copy link
Contributor Author

This is a fresh install on a new VM. I will get you a bash version.

@phillipsj
Copy link
Contributor Author

Here is my bash version:
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)

@fititnt
Copy link

fititnt commented Apr 20, 2015

@phillipsj same here. Solved converting Windows end line to Unix endline for file ~/.nvm/nvm.sh (with notepad++ under Wine) and worked.

Ubuntu 14.04 / GNU bash, versão 4.3.11(1)-release (x86_64-pc-linux-gnu)

@ljharb
Copy link
Member

ljharb commented Apr 20, 2015

@fititnt It's hard to me to fix that, so if you can make a PR fixing that I'd be very happy :-)

@fititnt
Copy link

fititnt commented Apr 20, 2015

@ljharb Should be a better way to do it, because is a bit hacky that way. That should work even with \r. Maybe is just a problem with ubuntu or a missing #!/usr/bin/env bash at first line of the file

@ljharb
Copy link
Member

ljharb commented Apr 20, 2015

@fititnt nvm.sh is sourced, not executed, so it doesn't need a shebang. Certainly it might be an issue with ubuntu, but I can't debug that any better :-/

@sixman9
Copy link

sixman9 commented Apr 23, 2015

I'm also finding Windows-style line endings for NVM (wget'd), on my week-old Ubuntu 14.04 install.

Although 'Notepad under Wine' will probably do the job, I'd use the 'dos2unix' command (sudo apt-get install dos2unix on Ubuntu). Here's what I'm doing to the NVM install directory:

for lr in find ~/.nvm -type f; do dos2unix "$lr"; done

This command-line will find NVM's install files and removes '\r' line endings.

Once that's was done, I just closed and re-opened the terminal. All seems well now - I have many NVM-prefixed commands on the terminal now, thanks.

@phillipsj
Copy link
Contributor Author

So I opened it in gedit and did a "Save As" and changed the line ending to unix/linux. GEdit did recognize it as windows line ending file.

@ljharb
Copy link
Member

ljharb commented Apr 23, 2015

I think the issue for me is that I'm both on a Mac, and have my git settings set up to automatically make all line endings Unix.

Could someone with Windows try a pull request that removes all the windows newlines on install.sh and nvm.sh (@phillipsj, @sixman9, @fititnt?)

@phillipsj
Copy link
Contributor Author

I should have the time later tonight and pull it down and submit the request. If someone else can get to it before feel free.

@ljharb
Copy link
Member

ljharb commented Apr 24, 2015

@phillipsj looks like nobody has yet, if you still could that'd be awesome :-)

@ljharb ljharb added OS: windows pull request wanted This is a great way to contribute! Help us out :-D and removed needs followup We need some info or action from whoever filed this issue/PR. labels Apr 24, 2015
@ljharb ljharb changed the title Fresh install of NVM error Fresh install of NVM error due to CRLF newlines Apr 24, 2015
@phillipsj
Copy link
Contributor Author

Yep I will.

@phillipsj
Copy link
Contributor Author

Unfortunately the file names for the test directories are causing problems on a windows box.

@phillipsj
Copy link
Contributor Author

Hopefully forcing the line endings in the gitattributes will work it out of the system. These are the most frustrating issues.

@phillipsj
Copy link
Contributor Author

Submitted a new pull request. with the squash. I must be doing something wrong as I always have this pull requests issue.

@ljharb ljharb closed this as completed in 153ee68 Apr 25, 2015
@ljharb
Copy link
Member

ljharb commented Apr 25, 2015

@phillipsj a force push to the same branch name (not deleting the branch on origin) should update the pull request neatly. nbd tho, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: ubuntu OS: windows pull request wanted This is a great way to contribute! Help us out :-D
Projects
None yet
Development

No branches or pull requests

4 participants