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

Installs Node.js and ends the setup process automatically #549

Merged
merged 1 commit into from
Jun 29, 2016

Conversation

xcambar
Copy link
Contributor

@xcambar xcambar commented Oct 13, 2014

Many people around me don't read enough of the README and expect Node.js to be installed after running the install script.

Based on a Gist I've written for my coworkers (https://gist.github.com/xcambar/2f88b912b7d40fe605c5), we thought it could be beneficial to NVM that the install script actually installs Node.js.

This is what this PR does, with a configurable Node.js version (defaulting to stable).

@xcambar
Copy link
Contributor Author

xcambar commented Oct 13, 2014

Just a note: I looked at the build report and couldn't figure out why it did fail.
The test didn't even really fail but the runner declared that it timed out.

@ljharb
Copy link
Member

ljharb commented Oct 13, 2014

Sometimes the tests time out; I'll rerun that one.

I'm pretty hesitant to add extra features to the (mostly untested) install script just to cover people that don't read the instructions. The install script installs nvm - I'm not sure why you'd have an expectation that it would install anything else?

@xcambar
Copy link
Contributor Author

xcambar commented Oct 13, 2014

Well... The whole purpose of NVM is to have Node.js installed, it seems 😉

Anyway, users don't read the instructions, whether they are developers or not... hard truth, but truth nonetheless.

@ljharb
Copy link
Member

ljharb commented Oct 13, 2014

I also don't think we can presume that "stable" is the thing the user wants to install - nor that the user necessarily wants the install script to make a network call or compile something. Think setup for automated test environments, for example.

@xcambar
Copy link
Contributor Author

xcambar commented Oct 14, 2014

You are absolutely right. This is a very good example of why the PR makes the installed version customizable via the $NODE_VERSION environment variable.

I imagined it could be used just the same as NVM already does to select the correct test suite in Travis (https://github.com/creationix/nvm/blob/master/.travis.yml#L12-L31).

Maybe the PR could be turned upside down: The default behaviour of NVM being left unchanged but the presence of the NODE_VERSION environment variable would be used as a switch to automatically install the specified version of Node.js.

@ljharb
Copy link
Member

ljharb commented Oct 14, 2014

That's not a bad idea.

@xcambar
Copy link
Contributor Author

xcambar commented Oct 14, 2014

Done :)

@amessinger
Copy link

I kinda agree with @xcambar in that the main purpose of NVM is to get a NodeJS binary up and running and a given environment.
@ljharb I understand your concern that the step Xavier suggests might be out of the scope of this install script, but to me it is not: it's the first - and most important - use case of NVM.

My 2 cents.

@ljharb
Copy link
Member

ljharb commented Oct 14, 2014

Sure, but this is the install script - it's main purpose is to get nvm installed. Separation of concerns is pretty important, considering you can do $INSTALL_COMMAND && . $NVM_DIR/nvm.sh && nvm install stable && nvm alias default stable on your own already.

@ljharb ljharb added feature requests I want a new feature in nvm! installing node Issues with installing node/io.js versions. labels Oct 14, 2014
@@ -48,6 +51,17 @@ install_nvm_from_git() {
return
}

install_node() {
# Sourcing $PROFILE to take into account the new environment
source $PROFILE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to re-source the entire $PROFILE, or would sourcing $NVM_DIR/nvm.sh be sufficient?

@xcambar
Copy link
Contributor Author

xcambar commented Oct 15, 2014

I've followed your comments.
Hope you'll like it.

@@ -126,6 +146,11 @@ else
else
echo "=> Source string already in $PROFILE"
fi
# Automatically install Node.js
if [ -z "$NODE_VERSION" ]; then
echo "=> Close and reopen your terminal to start using nvm"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually necessary? Doesn't nvm execute hash -r?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only on "use" or "deactivate" - but what might be helpful here is to actually source nvm, rather than relying on the profile to do it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...source nvm, rather than relying on the profile to do it?

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 too, but as it was the former behaviour of the install script, it felt out of scope to remove it without notice.

As we seem to agree on it, I'll add the source.

@xcambar
Copy link
Contributor Author

xcambar commented Oct 17, 2014

Done.

Note that the source is done no matter if the snippet has been found in $PROFILE or not.
It covers the edge case where it may have been found in a file that is actually not sourced at login (eg. legacy .bash_profile while the user moved to zsh). Whatsmore, it doesn't hurt.

@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Dec 21, 2014
@ljharb
Copy link
Member

ljharb commented Dec 21, 2014

Please rebase this on top of master - it's currently not mergeable.

@xcambar
Copy link
Contributor Author

xcambar commented Dec 24, 2014

Will do in the next few days. Sounds good ?

@ljharb
Copy link
Member

ljharb commented Jun 26, 2016

@xcambar do you still have any interest in completing this PR?

@xcambar xcambar force-pushed the complete_install branch from 8aae2c5 to f1af1c1 Compare June 27, 2016 09:59
@xcambar
Copy link
Contributor Author

xcambar commented Jun 27, 2016

Rebased and well.

@@ -42,8 +42,8 @@ or Wget:

<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).</sub>

You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR`, and `PROFILE` variables.
Eg: `curl ... | NVM_DIR="path/to/nvm" bash`
You can customize the install source, directory, profile and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE` and `NODE_VERSION` variables.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an Oxford comma after "profile" and PROFILE

local CURRENT_NVM_NODE

CURRENT_NVM_NODE="$(nvm_version current)"
if [ "$(nvm_version $NODE_VERSION)" == "$CURRENT_NVM_NODE" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NODE_VERSION needs quotes here

@ljharb
Copy link
Member

ljharb commented Jun 28, 2016

LGTM pending the above comments

@xcambar xcambar force-pushed the complete_install branch from f1af1c1 to 35fa736 Compare June 28, 2016 06:58
fi

echo "=> Installing Node.js version $NODE_VERSION"
nvm install $NODE_VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this var needs quotes

@xcambar xcambar force-pushed the complete_install branch from 35fa736 to f5724e4 Compare June 29, 2016 07:08
@@ -255,9 +286,13 @@ nvm_do_install() {
fi
fi

# Sourcing $PROFILE to take into account the new environment
source $NVM_PROFILE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, one more - this needs to be quoted, and it must use . since source isn't as portable

@xcambar xcambar force-pushed the complete_install branch from f5724e4 to a24ff3e Compare June 29, 2016 07:57
@ljharb ljharb removed the needs followup We need some info or action from whoever filed this issue/PR. label Jun 29, 2016
@ljharb ljharb merged commit a24ff3e into nvm-sh:master Jun 29, 2016
@ljharb
Copy link
Member

ljharb commented Jun 29, 2016

Thanks!

@xcambar xcambar deleted the complete_install branch June 29, 2016 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature requests I want a new feature in nvm! installing node Issues with installing node/io.js versions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants