-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Homebrew should no longer manage npm. #27479
Conversation
I want @isaacs or other input on this before we merge it. We can't keep yo-yoing the Homebrew formula on this. |
Totally agree. This workaround of not letting homebrew manage npm is actually his workaround. Well, he tells others to completely opt out of homebrew altogether when it comes to node, but later in the thread everyone realized only npm needs to not be managed by homebrew. |
end | ||
end | ||
def caveats; <<-end.undent | ||
Homebrew has NOT installed npm. If you want npm (you do right?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would absolutely rather we provide a link to a webpage that provides these instructions, so the caveats would be "To install npm, read the instructions at http://blah."
Makes sense to me. Where would be the best place to host such instructions? Or does one already exist? I will say that install script has not changed for quite some time. Idk if that makes a difference or not. |
Presumably the NPM project has a homepage with these instructions on it. They could even make a Homebrew specific page that we could link to. |
Well I've searched around and I cannot find one. If you know of one then please let me know. I've seen the one-liner install script all over the place but I can't find any page dedicated to install instructions that includes the easy one-liner. Should I create one? I'd be more than happy to throw up a permanent page on my domain. Though, is this really worth the hassle? What is your reasoning for not liking the one-line npm install just being displayed right in the caveat? |
That's fine with me. I'm in no way trying to rush anything. Just discussing. I will stay on top of this PR discussion and make any changes in my fork that we decide to make. |
My reasoning is that NPM should provide install instructions, and if they change their install instructions we shouldn't have to update the caveat, since we wouldn't actually be packaging NPM anymore. Surely they have a page with installation instructions somewhere on the Internet. |
@adamv Surely you can find it and link to it then, because I sure can't. Since npm is packaged with node I'd bet most people get it that way so maybe they don't feel it necessary to provide an install page for npm since they have one for node. Anytime I've seen npm installed by itself without node it has always been that curl script. They've maintained that shell script since I can remember and even when they've changed and moved stuff around that shell script has always been there. They just keep redirecting that url to wherever it needs to go (hence the |
This is the best I could find, and it tells users to install node to get npm. There is a "fancy pants" install section below that with the script in it. I suppose it does make sense to just link to the README. Only issue is that it doesn't actually instruct them how to easily DL and run the script; no mention of curl. What do you think @adamv? |
This homepage is indirect as heck but it "works for me" in the sense that I don't use npm myself. |
I think I'll leave it the way it is for now; either that or submit a PR to npm. I don't like that the README doesn't show any simple way to download and install npm. Even if they think to use curl they then have to figure out that they must supply the Most people using brew are power users and are going to want the simple one-liner and it really sucks to force everyone to google when we know what the one-liner is. Also, since it's brew, we only care about the unix install and none of the others. I think this makes the most sense for now. But again, updating the npm README probably makes the most sense. |
I won't be the maintainer who ultimately pulls this, but I'll leave this as a note to future interested maintainers: I'm strongly opposed to directly including the command-line to install NPM in node's caveats, and would very much prefer a link to npm documentation. Said documentation doesn't seem to exist in a usable state, but perhaps that is a sign to npm to improve it. |
This change assumes that the npm PR will be merged.
I found the npm README and sent a PR to change it. I then updated this PR with a link to the README. That should do what you want @adamv. |
#{npm_prefix}/bin | ||
end | ||
end | ||
def caveats; <<-end.undent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use EOS.undent
and put in the ending EOS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. Thank you :)
lib/"node_modules/npm/lib/utils/completion.sh" => "npm" | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This end
needs to remain as the end of def install
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks again.
If you're familiar with the history here, I did once upon a time send a pull request to Homebrew that removed npm entirely. After massive push-back on that, I sent a new pull request that installed npm in a more standard fashion, such that it would not disable features or be unable to upgrade itself. After much back and forth with the Homebrew team, we settled on something that we could all be equally dissatisfied with. That was some time ago, and the current state of the npm brew recipe is to be perpetually broken and weird. So, in short, huge +1 on this from me. Several years overdue. |
@isaacs Ok, thanks. Is this: https://github.com/npm/npm#fancy-install-unix the best link for us? Alternatively, can we rely on https://npmjs.org/install.sh to work for a long time? Thanks again! |
One-line Edit: On inspection of the PR I see you've already done this, and subsequently removed it. |
Think this has been open long enough that we can finally get this fixed? :) |
y'know, 👍. It's a nice compromise, and considering how |
@mistydemeo I stand corrected. I guess I'll revise to say "No developer I know of installs Ruby/Rubygems via Homebrew". Everyone I've ever met uses a version manager (eg RVM, rbenv, chruby, etc) to handle that. |
What about a patch in the formula which prevents npm from updating itself? |
How would you do that though? When I run
It updates all global modules, including npm itself. |
Yeah, I don't think that suggestion would be an improvement for anyone; people want to keep npm up to date (for good reasons). |
Please see the long gory history of this formula, and the discussions around it. What you suggest IS the problem. |
I'm going to actively work on this to see if we can find a solution that allows self-update without patching by installing npm in a different/correct place. |
Installing Node.js and npm using Homebrew can be problematic: Homebrew/legacy-homebrew#27479
In #28075 I've got a PR to install |
Closing since #28075 is the solution we all really wanted. |
Install npm to the expected location using the upstream tarball. This should make everyone happier. Closes #27479.
Now fixed in f900829. |
Install npm to the expected location using the upstream tarball. This should make everyone happier. Closes Homebrew#27479.
Added a simple example of installing npm by itself via curl. This helps solve [an issue](Homebrew/legacy-homebrew#27479) with the node homebrew formula where users will want a simple way to install npm after installing node. Homebrew maintainers would rather see this curl example in the npm README rather than directly in the node formula. It also just helps in general to have an example when users find the npm README and want to use the shell script.
It no longer conflicts with Homebrew (Homebrew/legacy-homebrew#27479). This reverts commit 5a70ba8.
Now that the `npm` related issue (see: Homebrew/legacy-homebrew#27479) has been fixed (see: Homebrew/legacy-homebrew#28075), revert back to using `Homebrew` to install `Node.js` and `npm` on OS X.
Install npm to the expected location using the upstream tarball. This should make everyone happier. Closes Homebrew#27479.
This discussion has been ongoing for a while now and it seems to have come to a consensus. When homebrew installs npm it breaks the ability for npm to update itself. This wouldn't be a big deal if we never let npm update itslef, but the reality is that's not really practical.
With npm you can run
npm update -g
(which is standard practice) and it will update all global node modules, including npm itself. When this happens after homebrew installed npm it completely breaks npm so that it no longer functions at all (unless you usesudo
every time, which obviously isn't ideal). The only way to fix it is to re-install npm. Installing this brew formula without npm and then installing npm separately fixes the issue and allows npm to manage itself appropriately.We came up with two options:
I'm not familiar enough with homebrew or Ruby to even know if it's possible to run the curl script at the end of the node install so I went ahead and did my best to implement option 1. Please feel free to point out any issues with my changes; as I said, I'm not a Ruby developer, so I wouldn't be surprised if I made a few mistakes.
Option 2 would be the best since it would allow brew to install npm initially, but then let it update itself thereafter, but the original issue is obviously a permissions issue; it seems likely that the same issue would occur with this option. If someone reading this thinks it's possible to do that then please do so; I know that lots of us would be very grateful :)