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

Long loading times fixed by better design #3326

Open
MathematicianOnGithub opened this issue Mar 31, 2024 · 1 comment
Open

Long loading times fixed by better design #3326

MathematicianOnGithub opened this issue Mar 31, 2024 · 1 comment

Comments

@MathematicianOnGithub
Copy link

export PATH="${HOME}/.nvm/versions/node/default/bin:$PATH"
export PATH="${HOME}/.nvm/versions/node/default/lib:$PATH"
export PATH="${HOME}/.nvm/versions/node/default/include:$PATH"
export PATH="${HOME}/.nvm/versions/node/default/share:$PATH"

adding the above to ./nvm/nvm.sh

also removing:

# nvm_process_parameters() {
#   local NVM_AUTO_MODE
#   NVM_AUTO_MODE='use'
#   while [ "$#" -ne 0 ]; do
#     case "$1" in
#       --install) NVM_AUTO_MODE='install' ;;
#       --no-use) NVM_AUTO_MODE='none' ;;
#     esac
#     shift
#   done
#   nvm_auto "${NVM_AUTO_MODE}"
# }
#
# nvm_process_parameters "$@"

opening a shell now doesn't take 10 seconds or more until nvm loads.
which is extremely annoying.

If we do this, a user doesn't have to install node globally through their package manager,
and can be solely installed via nvm.

If a user wants to switch version and opt out of the default, they simply use nvm use.
Not sure why the implementation of nvm use is so frustratingly slow in the first place, it should just source
new paths.

Bonus:
You could pretty much redesign nvm by simply making something more general like a package manager that works for local users rather than global installation. It would pretty much work the same.
e.g.
packagelist:
some-package:1.2.4 http://somemirrorlink
another-package:1.5.4 http://somemirrorlink
...

local-apt ~/.fakeroot install
./.fakeroot
./.fakeroot/usr
./.fakeroot/lib
./.fakeroot/bin

local-apt use ~/.fakeroot

then you can treat nvm as a special case of this.
like:
packagegroup:
lts:whatever: node:1.2.4, npm:1.1.4

local-apt ~/.nvm/fakeroots/lts_whatever install lts:whatever
local-apt use ~/.nvm/fakeroots/lts_whatever

but this implementation ought to be like 100 lines of code or even less, probably like 50 lines of code.

@ljharb
Copy link
Member

ljharb commented Apr 1, 2024

I'm a bit confused.

Nobody should ever be installing node with their package manager.

Additionally, only bin should be in the PATH; not the others.

The speedup you're seeing is just about skipping the nvm use command - if you add --no-use to the sourcing line, with no other changes, you won't see the slowdown.

nvm ONLY works for local users and HAS no global installation, so I'm really confused what you mean here.

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

2 participants