-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
NVM_NOUSE on install.sh to pass --no-use to nvm.sh #2132
base: master
Are you sure you want to change the base?
Conversation
I suppose this is low-impact and makes some sense - although |
My use case is that I am wrapping nvm in another tool. I don’t want nvm to do anything on install other than install. So this was one part I could not figure out how to do with the current implementation. To me it makes sense to have this control even if you don’t intent to push users to it. |
I suppose adding it tested, but not documented, seems reasonable. |
To follow up on this, is the only thing blocking it tests? Anything else? |
I think tests (and a rebase ofc) are the only thing. |
This would also make special integrations simpler, e.g. on a CI system where you don’t want to modify local state but instead handle the PATH "by hand". I have the situation right now, that |
@lstrojny this PR won't solve that for you; please file a new issue and we can explore why |
Actually this is why I originally opened this PR. I am doing exactly what @lstrojny mentions. I cannot remember the exact details without digging back into this code, but what is described sounds familiar. |
So I did look a bit at this again, and here is an illustrative implementation which relies on this PR: https://github.com/wesleytodd/nvmjs/blob/master/index.js#L68 The point here is that the |
@wesleytodd i'm confused; the install script doesn't install a version of node, only sourcing the profile files does; but either way I'm still happy to merge this with tests. |
So this I have a build that installs NVM script in the "container" which worked fine until someone added a So I end up with failed builds: => Downloading nvm from git to '/app/.nvm'
W: Cloning into '/app/.nvm'...
=> => Compressing and cleaning up git repository
=> Appending nvm source string to /app/.bash_profile
=> Appending bash_completion source string to /app/.bash_profile
W: N/A: version "node -> N/A" is not yet installed.
W:
W: You need to run "nvm install node" to install it before using it.
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
W: N/A: version "node -> N/A" is not yet installed.
W:
W: You need to run "nvm install node" to install it before using it.
E: Error building project: Step failed with status code 3.
E: Error: Unable to build application, aborting. I thought adding
But turns out it actually fails inside the Unless there's some other way to install the node version that it finds inside the |
@dan2k3k4 you can run |
So when would I run that when the issue happens when it's installing nvm? It's the install.sh script that fails for me since it tries to run nvm use during that setup |
ah, gotcha. in that case you would need this PR (which is still awaiting tests). if you'd like to contribute tests, please comment with a link to your branch (not another PR) and i'll pull them in :-) |
@ljharb what type of tests? I see there's a I then see |
The tests don't have to have anything to do with docker (that's just the motivating use case); they need to ensure that |
Ok, I've tried in: Branch I'm not familiar with testing this way so I'm not sure if I went in the right direction or not. I tried to base it on how the other scripts in the same directory were done, and I tried to remove NVM too. I have no idea if it works. |
Testing is hard for this! It is actually why I did not get back to this. And in a typical software engineer fashion, instead of doing the hard thing I spent more time than I would have just learning it and wrote a new thing which might enable us to use "normal" JS testing. I brought it up with @ljharb in a slack convo, but I will post it here since this came up again. Here is a JS wrapper which would enable us to test NVM via a JS interface. I haven't finished it because @ljharb expressed some concerns about the theory of "js testing bash to install js". But if we can get agreement on a good path forward I will be happy to do more leg work to get it done. |
Installs nvm via the install.sh script, then removes nvm, and reinstalls with `NVM_NOUSE` variable set to true.
@dan2k3k4 this is a great start :-) the thing that seems missing is that there's nothing testing that "use" is not called. Perhaps adding one check that use is called to the normal case, and then an opposite assertion in the NOUSE case? |
Hey @ljharb and @wesleytodd - I haven't had time in the past week to check this as I was busy with launching the https://celebratedrupal.org site. The place where I had errors is in the: I'm not really sure what needs to be done for checking if the use is called. Is there any artefact written anywhere after |
@dan2k3k4 |
c6cfc3a
to
c20db2a
Compare
Similar to my other PR (#2131) I figured I would see if this idea was good and I can flesh out the PR more if it is good.
This adds a
NVM_NOUSE
environment variable to theinstall.sh
script so you can still use the install script but also pass--no-use
.Example:
Thoughts?