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

Actually install the version of node we want via NVM/nodenv instead of just checking #434

Merged
merged 2 commits into from
Jan 16, 2019

Conversation

bachand
Copy link
Contributor

@bachand bachand commented Jan 14, 2019

👋

I am working on updating Airbnb to the latest version of Apollo. I was running into issues with this script.

The issue I faced was that sourcing ~/.nvm/nvm.sh was causing Node to be reset to the version specified in my .nvmrc. The version in there is 6.x.x, which is necessary for other tooling. I couldn't find a way to set Node to 8.x.x outside of this script since sourcing ~/.nvm/nvm.sh would continually reset us back to 6.x.x.

Since we have access to these version managers, let's just set up the version that we need so that the script can be run regardless of what Node versions you have installed. Making this change allowed me to remove the code that checks that the Node version is correct.

The one downside that I can see of this change is that if you had a version like 8.1.0 installed and active, the old script would have run fine since it was just checking the major version. As of this change, we will install and activate the exact version. I think there are pros/cons to each approach. The con of the new approach is that you may have to install a version of node that is very similar to one that you already have. The pro everyone is always running the same version of Node, which makes it easier to debug issues 🤷‍♂️

cc: @ljharb for NVM changes

Copy link

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

nvm stuff LGTM; however, it seems like any script should assume the PATH is set up such that node and npm are the correct versions, and shouldn't get involved in package managers (of which you've chosen here the most popular/common, skipped the next-most-popular/common 2 or 3, and also chosen one of the least popular/common, which seems like an odd support matrix)

# Only major version should be specified here
REQUIRED_NODE_VERSION=8
# Specify fully qualified version here
REQUIRED_NODE_VERSION=8.0.0
Copy link

Choose a reason for hiding this comment

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

I think sticking with the major is probably better; especially considering that 8.0.0 is EOL and only the latest 8 (8.15.0 at this writing) is considered LTS.

Copy link
Contributor Author

@bachand bachand Jan 15, 2019

Choose a reason for hiding this comment

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

Ah good context. Thanks @ljharb. Nodenv was requiring me to specify a fully qualified version. I’ll update this to be 8.15.0 since that is LTS.

@martijnwalraven
Copy link
Contributor

@bachand Thanks for looking into this! I think using these version managers to install the required Node version makes a lot of sense. I'll let you address @ljharb's feedback first, but happy to merge this whenever you're ready.

@apollo-cla
Copy link

@bachand: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
use_correct_node_via_nvm
fi

# Set up the nodenv node version manager if present
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Full transparency: I just installed a clean version of Nodenv and this file doesn't exist, so I am wondering if this check is incorrect. That being said, I've tested the commands here for installing Node 8.15.0 via Nodenv and they work. Determining if in fact there is an issue in this check should be a separate investigation / PR.

@bachand
Copy link
Contributor Author

bachand commented Jan 15, 2019

Thanks for the quick review @martijnwalraven. I have made the change suggested by @ljharb and signed the CLA. This is ready to be merged (from my perspective).

I look forward to working more closely together on Apollo moving forward :)

@martijnwalraven martijnwalraven merged commit 86b3b65 into apollographql:master Jan 16, 2019
@martijnwalraven
Copy link
Contributor

Thanks, looks good to me! Also looking forward to working together.

@bachand
Copy link
Contributor Author

bachand commented Jan 16, 2019

Thanks for merging @martijnwalraven. Do you have a sense of when you'll be creating a new version?

@martijnwalraven
Copy link
Contributor

@bachand I just released version 0.9.5 with these changes.

@bachand
Copy link
Contributor Author

bachand commented Jan 18, 2019

Thanks 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants