Open leehambley opened 9 years ago
The suggestion to split things up into binaries is in #337.
I wouldn't necessarily say nvm
"suffers" here - you can also just rerun the source line (. $NVM_DIR/nvm.sh
) and that should cover you without having to export each function, right?
The problem is we're building a CI, and we setup an environment (environment includes nvm, gvm, rbenv, rvm, etc) and then we exec ./the/user/test/script
… and we wanted to give them the 100% clean "just run node" experience, if we have to tell them to start sourcing random dot-files, then it takes the shine off the user experience a lot.
I'd be more than happy to let you close this and we can pick up in #337.
Having just read the arguments in #337 it seems people are largely against changing, fear of breaking changes, and how rbenv's shim approach can cause issues (unfortunately two linked tweets are protected/deleted) so I'm not sure what issues that might be, but it's certainly non-trivial.
Right - I'm fine with change, but I'd prefer avoiding breaking changes. The shim approach of rvm
and rbenv
are very intrusive, and that makes testing and support much harder as well.
Why do you need nvm
at all in the exec'd shell? Can you not just do nvm use node
first, and then export the PATH
down?
We rely on the default, so we don't "nvm use" anything, maybe that would be a workaround.
Regarding the breaking change from the shim, I've always found rbenv's shim approach to be really, really neat - but I suppose it depends a little bit on the entry point, there's another thing here though, what's to stop nvm
itself being on the path, working as it does now, but not being a shell function, rather something you can really execute?
If that was the case, nvm.sh
would have to be parsed on every invocation of nvm
- unless all of its other constituent parts were also separate executables.
If that was the case, nvm.sh would have to be parsed on every invocation of nvm - unless all of its other constituent parts were also separate executables.
This is how rbenv works. That part at least seems to work pretty well, although admittedly the shims are a bit of a mess at times (I hated rbenv rehash
)
NVM suffers from the following:
Essentially if you
exec
(either explicitly withexec ./childscript
or implicitly by./childscript
) then NVM becomes unavailable.gvm
andrbenv
solve this by having a shell shim that modifies the path and making sure that the binaries are real binaries, really on the $PATH.Short term suggestion would be to
export -f every_function_in_nvm
(it's a long list):But, with this
childscript
is able to at least run nvm. Unfortunately this means that$ env
becomes essentially useless, as thisexport -f
is a bashism which exports the function body as an environment variable with the same name as the function to allow it to pass throughman (3) execv