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

Feedback when activating node version #198

Closed
vincer opened this issue Oct 11, 2014 · 5 comments
Closed

Feedback when activating node version #198

vincer opened this issue Oct 11, 2014 · 5 comments

Comments

@vincer
Copy link

vincer commented Oct 11, 2014

Currently there's no feedback to differentiate whether a different node version was activated or not. Nothing is printed to stdout and the return code is 0/success whether the node version changed or not.

At a minimum I'd like something like:

v0.10.32 activated

printed out if a version other than v0.10.32 was active before the command was run.

This would allow other programs (namely Ansible in my use case) to know if a change was affected to the system since it can't rely on the return code.

We could also add a message along the lines of "v0.10.32 already active" if v0.10.32 was already active before the command was run, though I personally don't think this is necessary.

If there's interest in this, I can submit a PR.

@tjwebb
Copy link
Collaborator

tjwebb commented Oct 12, 2014

When have you seen no error output when the version switch didn't complete successfully?

@vincer
Copy link
Author

vincer commented Oct 12, 2014

Sorry, I was unclear. This isn't when there's an error, this is to differentiate the two success cases:

  1. New node version being activated is different from previous.
  2. Node version unchanged as the version passed was already active.

Here is the output currently:

vagrant@vagrant-ubuntu-trusty-64:~$ node --version
v0.10.31
vagrant@vagrant-ubuntu-trusty-64:~$ sudo n 0.10.32
vagrant@vagrant-ubuntu-trusty-64:~$ echo $?
0
vagrant@vagrant-ubuntu-trusty-64:~$ node --version
v0.10.32
vagrant@vagrant-ubuntu-trusty-64:~$ sudo n 0.10.32
vagrant@vagrant-ubuntu-trusty-64:~$ echo $?
0
vagrant@vagrant-ubuntu-trusty-64:~$ node --version
v0.10.32

Note that there is no way to differentiate what happened in the first n 0.10.32 call vs the second one even though the first one actually changed the node version, while the second did nothing.

I'd like to change the first n 0.10.32 call to output 0.10.32 activated while the second call to either print nothing or to return 0.10.32 already active. So, the output would like this:

vagrant@vagrant-ubuntu-trusty-64:~$ node --version
v0.10.31
vagrant@vagrant-ubuntu-trusty-64:~$ sudo n 0.10.32
0.10.32 activated
vagrant@vagrant-ubuntu-trusty-64:~$ echo $?
0
vagrant@vagrant-ubuntu-trusty-64:~$ node --version
v0.10.32
vagrant@vagrant-ubuntu-trusty-64:~$ sudo n 0.10.32
0.10.32 already active
vagrant@vagrant-ubuntu-trusty-64:~$ echo $?
0
vagrant@vagrant-ubuntu-trusty-64:~$ node --version
v0.10.32

@olsonpm
Copy link

olsonpm commented Jan 24, 2015

@tjwebb - If you installed npm via sudo, then anything installed globally requires sudo. If I call n without sudo and change the active version, it doesn't successfully change and there's no feedback. It was really confusing for me before I realized my mistake.

+1 for feedback after selection

@shadowspawn
Copy link
Collaborator

I have been confused by lack of output too, especially when intending to restore the version of npm included with a version of node (and nothing happened because that node was already installed).

Changing the activate routine to always produce output and using same format as during download could look like this.

$ n 8.11.3

     install : node-v8.11.3
       mkdir : /usr/local/n/versions/node/8.11.3
       fetch : https://nodejs.org/dist/v8.11.3/node-v8.11.3-darwin-x64.tar.gz
######################################################################## 100.0%
   activated : v8.11.3

$ n 8.11.3
   unchanged : v8.11.3
$ n 6.14.3
   activated : v6.14.3
$ n    [and pick 8.11.3 from list]
   activated : v8.11.3

@shadowspawn
Copy link
Collaborator

This issue has not had any activity in over six months. I have opened a newer issue #543 with more detail as this was a behaviour I found confusing too. Subscribe to that issue for updates and/or give it a 👍

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

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

No branches or pull requests

4 participants