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

Feature suggestion: have "install" say what it does #543

Closed
shadowspawn opened this issue Dec 16, 2018 · 3 comments
Closed

Feature suggestion: have "install" say what it does #543

shadowspawn opened this issue Dec 16, 2018 · 3 comments

Comments

@shadowspawn
Copy link
Collaborator

shadowspawn commented Dec 16, 2018

(Opening an issue for opportunity for feedback.)

Problem

Running an install does not always do anything, and there is no feedback to inform the user (#198). The install is silently skipped if the active version of node matches the requested version, and an activation is likewise silent so not visibly different.

This might be reasonable if only node was involved, but there is npm too. I personally find this problematic when intending to restore to a shipping combination of node+npm, or trying to recover or give recovery instructions from a broken npm.

Example Scenarios

Uncertain outcome

n lts
# Did anything happen? What version of npm is active now?
  • If you had a different version of node active, you now have the npm that ships with node lts
  • If node lts was already active, then nothing has changed and npm has not changed from whatever you had before (which you may have manually updated, or broken)

Extra steps to get predictable outcome

If you have a broken npm, or want someone to get to a known state, it takes two instructions. For example, change to a dummy version of node so that the second instruction actually does what is intended. (When I found myself doing this I decided it indicated a problem!)

n 8.0.0 # Any other version!
n 10.14.2

Proposed Changes

  • always install (i.e. remove optimization Optimize activate #128 skipping reinstall)
  • include same output for activation as from full install
$ n 10.14.2

     install : node-v10.14.2
       mkdir : /usr/local/n/versions/node/10.14.2
       fetch : https://nodejs.org/dist/v10.14.2/node-v10.14.2-darwin-x64.tar.gz
   installed : v10.14.2

$ n 10.14.2
   installed : v10.14.2

As a bonus and following the same pattern, include extra output if active version of node is different than installed (due to PATH problems). This should help with a common problem case that trips people up and causes help requests (#213 #261 #290 #300 #367 #381 #400 #451).

$ N_PREFIX=~/deleteme n 10.14.1

     install : node-v10.14.1
       mkdir : /Users/john/deleteme/n/versions/node/10.14.1
       fetch : https://nodejs.org/dist/v10.14.1/node-v10.14.1-darwin-x64.tar.gz
   installed : v10.14.1 to /Users/john/deleteme/bin/node
      active : v10.14.2 at /usr/local/bin/node

Alternatives

I considered adding a --force and/or adding a message when skipping the install, but I think always doing the install is simpler and clearer.

Could test both the node and npm versions before skipping the install, but again I prefer keeping it simple.

People do find it confusing what happens with npm. It might might be worth adding npm version to the progress messages too.

@shadowspawn
Copy link
Collaborator Author

If we do retain the optimization skipping the reinstall, n should check the version in its own install location rather than just the active version of node.

@shadowspawn
Copy link
Collaborator Author

Prerelease version available in v5.0.0-next.0

npm install -g n@next

Release notes: https://github.com/tj/n/releases/tag/v5.0.0-next.0

@shadowspawn
Copy link
Collaborator Author

shadowspawn commented Jul 20, 2019

Released v5.0.0

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

No branches or pull requests

1 participant