Giter Site home page Giter Site logo

Comments (15)

creationix avatar creationix commented on May 8, 2024

That sounds a bit of a chicken and egg problem. On my bash in a vanilla Ubuntu system, I never have trouble sourcing nvm in a clean environment. Do you have anything custom or aliases setup?

from nvm.

mheffner avatar mheffner commented on May 8, 2024

What is the value of $? after sourcing nvm.sh? With the current master, mine is always '13' before I've installed a particular node version. I can also trigger this by simply removing the default alias:

$ source ~/.nvm/nvm.sh 
$ echo $?
0
$ rm ~/.nvm/alias/default 
$ source ~/.nvm/nvm.sh 
Exit 13
$ echo $?
13

Restoring the alias default removes the failure. My recommendation would be to remove the 'return 13' in the case it can't find an installed node version and only error when someone attempts to pick a node version that doesn't exit.

FWIW, the following bashrc function helps diagnose commands that fail by printing the return value of the previous command if not zero:

# Display exit status of previous command on failure
#
function printexitvalue()
{
        local SAVE_EXIT=$?

        if [ $SAVE_EXIT -ne 0 ]; then
           echo "Exit $SAVE_EXIT";
        fi

        return $SAVE_EXIT
}
export PROMPT_COMMAND=printexitvalue

from nvm.

creationix avatar creationix commented on May 8, 2024

Sorry, I didn't see your comment. Did you ever resolve this?

from nvm.

mheffner avatar mheffner commented on May 8, 2024

I believe I worked around it by ignoring the error and preceding with installing a node and setting it as default. I'd imagine the original error is still present though, see earlier comment for how to reproduce.

from nvm.

creationix avatar creationix commented on May 8, 2024

I understand. Nothing is broken, it's just that in your environment, you're able to see the error code that I can't see in a vanilla bash environment. I'll look into fixing it if it bothers more people.

from nvm.

KrofDrakula avatar KrofDrakula commented on May 8, 2024

I think I'm having the same problem; installed a fresh Ubuntu 11.04 system and sourced nvm. Tried nvm install stable: it downloads the source but errors out with the following:

nvm: install v0.4.11 failed!

It does download the source to the current directory, though.

ADDED: I've additionally installed build-essential, openssl and libssl-dev to no avail. Node's ./configure shows all green.

from nvm.

KrofDrakula avatar KrofDrakula commented on May 8, 2024

Okay, installing the latest node from master branch using the following:

./configure
make
sudo make install

And then opening a new shell (while having . ~/.nvm/nvm.sh in my .bashrc) and running nvm install stable from my home directory seems to have done its job.

As a side effect, I've now seen that the nvm install behaves differently; in previous attempts it showed the standard curl messages (progress bars and all), while this time round it showed the familiar hash signs and counted up to 100%. If that helps any, I'm really bad at bash and can't point my finger to any of the parts of the sourced script.

from nvm.

siygle avatar siygle commented on May 8, 2024

I have the same problem when I upgrade my laptop to ubuntu 11.10. I didn't install any nodejs package at first, then I tried to install nodejs through nvm, but it always display "install failed!" (Both v0.4.x & v0.5.x)

I put some debug code and find out that
https://github.com/creationix/nvm/blob/master/nvm.sh#L106-110
The if else not work correctly, so the tarball would be null then program goes fail.

Then I do the same thing just like KrofDrakula did, fetch the node source code and install. After that, nvm could work fine.
Any advice? Thank.

from nvm.

jprichardson avatar jprichardson commented on May 8, 2024

I also have the same problem. On a vanilla Ubuntu 11.10, NVM fails to install v0.4.12. However, it seems to have downloaded the tarball correctly. Any thoughts on the problem?

from nvm.

jprichardson avatar jprichardson commented on May 8, 2024

I figured out the problem... for some reason on Ubuntu 11.10, emulation with curl is happening from the nvm.sh script. Remove that portion in the beginning of the nvm.sh file and source the update. Then make sure that the actual curl binary is installed.

Why any dependence upon wget? Why not just a dependence upon curl? Why bother trying to emulate curl with wget?

from nvm.

creationix avatar creationix commented on May 8, 2024

Desktop Linux doesn't usually have curl installed by default, but it does have wget. I always install curl and I think any serious web developer should have curl, but I'm not sure I should force that opinion on others. Either way, the wget emulation doesn't seem to work so I should probably remove it.

from nvm.

KrofDrakula avatar KrofDrakula commented on May 8, 2024

I'd suggest the script check the availability of curl and get rid of the use of wget altogether. If curl is not available, simply fail with an error message stating that curl needs to be installed as a prerequisite.

EDIT: just tried the suggestion by @jprichardson – installing curl on a vanilla Ubuntu instance (11.04) prior to running nvm install v0.4.12 does the trick, if anyone's still stuck.

from nvm.

creationix avatar creationix commented on May 8, 2024

Fixed in 8dad534

from nvm.

KrofDrakula avatar KrofDrakula commented on May 8, 2024

Awesome, thanks. Informative errors are way cool. :)

from nvm.

jprichardson avatar jprichardson commented on May 8, 2024

Excellent! Thanks for fixing this!

from nvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.