-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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 is not compatible with the "PREFIX" environment variable: currently set to "/usr/local" #1645
Comments
UpdateI need to keep moving on this project so I am bypassing the use of rockchalkwushock in mashaeltsova-photography on rework [+] $ git commit -m "Begin Rework"
Found '/Users/rockchalkwushock/Desktop/MEP/mashaeltsova-photography/.nvmrc' with version <8.8.1>
Now using node v8.8.1 (npm v5.4.2)
Found '/Users/rockchalkwushock/Desktop/MEP/mashaeltsova-photography/.nvmrc' with version <8.8.1>
Now using node v8.8.1 (npm v5.4.2)
husky > npm run -s precommit (node v8.8.1) Should |
The issue is that something was setting the As for the nvm output, if your precommit hook is sourcing Either way tho this isn't actionable for nvm itself, so I'm going to close the issue (but we can of course keep discussing) |
Not really sure why this was closed as it is clearly still an issue. 100% default system here, I just bought a new iMac pro... XCode then this was my first installations. I have installed nvm many times on other systems and now I run into this... Nothing in my files or setup that could possibly set PREFIX so its being done somewhere invisible to me
with my
and my .bash_profile
I have reinstalled nvm, i have tried everything. I have never installed node on the system. This appears to happen by doing a Perhaps Node 9.8.0 uses PREFIX? I literally have no idea how that is set but i have about 100 env vars set by default in terminal seemingly by XCode I would also point out that OSX's default Terminal.app does not work however iTerm does work. |
Since this is being launched by react-native - it does appear it might be related to that in some way? Not really sure it works sometimes but not others at this point |
@bradennapier Seems like Xcode launching Terminal from |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I had this issue trying to use I got around it by running: PREFIX= nvm use --delete-prefix stable This didn't unset the |
@goodevilgenius note that that will cause nvm to not actually work properly - which is the reason that the prefix is blocked in the first place. Why is the prefix needed? |
@ljharb The prefix is needed in Termux. It's a Linux environment made to work on top of an existing version of Android. It's not a I can install |
@goodevilgenius PREFIX is used to change the location of |
@ljharb That's fine for So, by doing But, I can't just add |
@goodevilgenius ohhh i gotcha, it's a collision in the environment variable name :-( that's very unfortunate. The problem is that PREFIX will also change how |
|
@goodevilgenius Please file a separate issue for tracking Termux specifically. |
This comment has been minimized.
This comment has been minimized.
Having the same issue. With no solution at all |
I uninstalled Termux and the issue went away so there's definitely a conflict that needs to be worked out. |
@goodevilgenius I have the same problem, is there new resolution pls? |
@luxueyan I never found a solution. I just installed node from |
@goodevilgenius I’d be happy to help if you filed a separate issue; node shouldn’t be installed from apt. |
@ljharb What would be the point of creating a separate issue? This issue already states the problem. You said:
Termux isn't going to stop using a |
Ah, fair enough. |
@goodevilgenius Now my resolution is installing a ubuntu using atilo:https://github.com/YadominJinta/atilo and then install nvm in ubuntu. |
Agree that this appears to be an actual issue. Could a possible solution be to use a more specific environment variable name instead of |
@mjumbewu no, unfortunately it's node itself that uses "PREFIX", and the nature of a node version manager is that it needs to own the prefix location, so there's simply no working around it. In other words, if both Termux and node aren't going to change, then Termux just isn't compatible with using a node version manager. I'm still not clear on why Termux couldn't change the name of their env var - is there an issue on their project I could read about it? |
FYI, I am having this issue with any regular MacOS terminal now. I am using react native as someone posted before and my PREFIX variable returns '/usr/local'. Not sure which tool is setting it now. @goodevilgenius workaround worked for me tho. |
@ntelkedzhiev 's solution worked. Small grammar police thing to note, the command is Thank you @ntelkedzhiev ! |
Thanks a lot. I had to reinstall nvm to have access to npm somehow. |
When I try to configure husky pre commit hook to I try to create
My solutionWhen I try to add node to
where - |
I fixed this by editing Paste this after line 6 (after the comment section) # LICENSE file in the root directory of this source tree. -> this is line 5 of original file
source ~/.nvm/nvm.sh
[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh # This loads NVM
unset PREFIX
PREFIX= nvm use --delete-prefix stable
nvm use default |
this is my solution
|
What a great suffering trying to get NVM and Termux work in harmony now, because of the "great" naming decisions that were made on Termux and Nodes end. To answer your questions few years after:
Originally posted by @agnostic-apollo in termux/termux-app#2096 (comment) What I don't get, though: If this cannot be fixed in NVM and Node is at fault, how is it that Node runs when installed from the Termux package manager? Is there really nothing we can do about it? What if I create aliases for |
Since node isn't officially distributed on the Termux package manager, i'm assuming it's been patched somehow. There's really nothing we can do about it, unless termux's PREFIX variable can work when pointed to the default location of |
will never gonna happen, it points to the This is really a huge F for both parties. I was trying to give I wasn't sure about the "mistakes were made" statement from Ryan Dahl until I faced this limitation yesterday. Termux has blood on their hands as well, I mean, it could've been obvious that Now running their |
I have added support in termux-app to export As for solving issues of termux and other platforms where If I am not mistaken, the patches should be pretty simple to set https://docs.npmjs.com/cli/v8/commands/npm-root https://docs.npmjs.com/cli/v9/commands/npm-prefix https://github.com/search?q=org%3Anpm+env.PREFIX&type=code https://github.com/search?q=org%3Anodejs+%24PREFIX&type=code https://github.com/search?q=org%3Anpm+%24PREFIX&type=code&p=2 https://github.com/nodejs/node/blob/67a9ed3f7f3c02cd908f98ac375bf1041a64ec70/Makefile#L189 |
There are far more installations of npm than termux, without any doubt, so the easiest would be patching termux. |
This comment was marked as spam.
This comment was marked as spam.
@agnostic-apollo first of all, thank you for stepping in explaining the matter in your own words. I think that deprecating Patching npm would be great too, but you'd have to update unmaintained decade-old versions of it, since the latest npm is not compatible with older node versions in my experience. I have to agree with @ljharb's statement about the numbers, but I can absolutely understand that these are not pleasant conclusions for maintaining Termux. @ljharb I think changing this in Termux is still harder though. If I understand you correctly, npm just reads this variable and nvm provides it. Termux cannot change it easily, because there are far more scripts in the wild that rely on this variable. On the flip-side npm could just read a different variable and fallback to I opened a discussion at npm about it. |
The https://github.com/nodejs/node/blob/67a9ed3f7f3c02cd908f98ac375bf1041a64ec70/Makefile#L189
Sure. But why would that matter? Users can use the new version if they want the fix and it will behave just as before without any breaking changes, and But I guess, if termux internal packages are patched, then it should allow users who want to unset And adding a alternate variable (like
You are very welcome.
Yeah, I agree. I didn't add the
Termux only provides latest and LTS node, so using latest npm and latest/LTS node should work just fine. Old versions get removed from our repos and mirrors due to space issues and shared lib linking issues against old dependencies. There are user hosted repos that provide old versions, but everyone knows that all fixes don't get backported and often updated versions must be used for fixes. https://github.com/termux/termux-packages/tree/master/packages/nodejs https://github.com/termux/termux-packages/tree/master/packages/nodejs-lts For a patch, currently function getGlobalPrefix () {
if (process.env.PREFIX) {
return process.env.PREFIX
} else if (process.platform === 'win32') {
// c:\node\node.exe --> prefix=c:\node\
return path.dirname(process.execPath)
} else {
// /usr/local/bin/node --> prefix=/usr/local
let pref = path.dirname(path.dirname(process.execPath))
// destdir only is respected on Unix
if (process.env.DESTDIR) {
pref = path.join(process.env.DESTDIR, pref)
}
return pref
}
} And it can use function getGlobalPrefix () {
if (process.env.NPM_PREFIX) {
return process.env.NPM_PREFIX
} else if (process.env.PREFIX && process.env.NPM_IGNORE_LEGACY_PREFIX != "1") {
return process.env.PREFIX
} else if (process.platform === 'win32') {
... Then termux and other |
@thunder-coding Tagging you (termux nodejs packages maintainer) here since you would know better about potential issues than me and may be able to suggest a different design. |
But the issue is not with node latest or LTS from the Termux repos, the issue is with nvm and Termux as nvm requires to set
I couldn't agree more to this.
I've looked into the versions of node/npm and luckily, older LTS versions of node are shipped with newer versions of npm, which would boil down to 3 versions requiring to be patched to get as far as node v12 back:
I doubt npm 6.14 will be patched though, since node 14 is out of support, but it would be nice to see. |
I see, I don't know the details of nvm, so I am probably missing things regarding the issue. But wouldn't providing the latest version of
It would be needed if user wants to engage the current third condition and
|
nvm is a version manager for node and npm that allows to install any versions of node/npm at the same time by switching between environments. Every node version has a specific npm version that it ships with. Simply fixing the issue in the latest npm version will fix the issue in the future, but older projects that require older node versions still won't run in Termux.
Yes you are right, I missed that final |
I understand that part, but since termux doesn't keep old versions of node, so there wouldn't exist users using it, unless they stick to old versions or are using custom repos to get them. A way should be looked into getting out of this mess for future versions, instead of doing nothing since old versions may never get fixed. Moreover, if users want old versions fixed, they can always send pull requests so that nvm maintainers don't need to fix old versions themselves. There is also the issue that node provided by termux is patched to work for termux and standard node wouldn't work. |
@agnostic-apollo nvm provides all old versions of node, so nvm users on termux will forever have this problem (unless termux is able to change) |
Right, sorry. I guess then suggested fix would only be useful for npm, but not for nvm. Standard node provided by nvm wouldn't work for termux either if its not patched for termux or conditional patches get merged in upstream. |
Exactly. If this had been fixed when it was first reported to termux (years ago, long before you took over) then it might be reasonable to tell termux users "just confine yourselves to node > n", but that |
nvm itself installs old versions of node/npm. It does not leverage pkg or apt, so Termux would absolutely keep old versions of node installed by nvm, as @ljharb said.
It would be useful if you patch a couple of major versions of npm and publish new minor versions of all (LTS) versions of node to ship with the new npm. This wouldn't fix the entire problem, but would enable at least the latest LTS versions to function in Termux with nvm, which would be a big win, already. Even if we fix it today for future versions of node / npm only, it would be at least no problem in half or full a decade. |
Is there any chance nvm can maintain a set of patches for existing users to apply and build node/nvm themselves? Such patches should probably be kept by nvm (because nvm would be applying them, though perhaps they should be kept in a community patch repo), however it should be entirely possible to simply copy them from termux build scripts. While it's not ideal to be building your own nodejs for each install, I already use |
I don't think it makes any sense for nvm to maintain patches, unless it's something that can be done transparently for a wide swath of environments. |
https://github.com/Schniz/fnm Performance motivated — since my shell startup time was being greatly slowed by nvm. Also resolves [this](nvm-sh/nvm#1645 (comment)) incompatibility warning in macOS Terminal, where I was still looking for a workaround.
https://github.com/Schniz/fnm Performance motivated — since my shell startup time was being greatly slowed by nvm. Also resolves [this](nvm-sh/nvm#1645 (comment)) incompatibility warning in macOS Terminal, where I was still looking for a workaround.
Operating system and version:
nvm debug
output:nvm ls
output:nvm
? (e.g. install script in readme, homebrew):install_script
When trying to commit to
git
usinghusky
&lint-staged
I am getting the following output:Commit and push up as I have been doing with no issues. Had zero problems on Saturday. No updates were ran in between then and now. I have since upgraded
nvm
from0.33.4
to0.33.6
and upgradednode
8.8.0
to8.8.1
.git
has always been installed withhomebrew
and has caused me not issues before when working withnvm
..bashrc
,.bash_profile
,.zshrc
, etc) that modifies thePATH
?The text was updated successfully, but these errors were encountered: