Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Node, iojs and npm formula resolution #36343

Closed
wants to merge 8 commits into from
Closed

Conversation

bcomnes
Copy link
Contributor

@bcomnes bcomnes commented Jan 29, 2015

I'm aware of the historical baggage of a separate npm formula, but I think the introduction of iojs warrants at least revisiting this solution taking into what has been learned from the current node formula. I appreciate your consideration in advance. If this is just too wacky, I understand, but I believe its a step forward.

This PR:

  • separates npm into its own formula
  • applies the minor patch needed to make npm compatible with iojs.
  • sets npm's "prefix" to #{HOMEBREW_PREFIX}, replicating existing npm tarball install behavior. (this part is key)
    • this results in npm installing modules into #{HOMEBREW_PREFIX}/lib/node_modules which then link to #{HOMEBREW_PREFIX}/bin
  • takes iojs out of its keg-only status
  • conflicts iojs with node, so they can't be linked at the same time.
    • advanced brew users can unlink and link in and out the version they want, if the choose to have both built at the same time.
  • reduces over all complexity of the three formulae imo.

Issues that still need resolution:

  • the npm formula should depend on node OR iojs. Right now, it only depends on node. I don't know how to do this. Can someone help me wrangle Library/Homebrew/requirements.rb to enable this?
  • [ ] Neither iojs or node "depend" on npm. But it should probably be installed automatically with these unless told not to. Is there a way to do that? Right now I just added a caveat instructing people to brew install npm.
  • Find out if there is any way to happily install npm to the cellar.
  • Fix testing errors

Why this arrangement works well

  • users can either brew install node OR brew install iojs and everything "just works". I believe this will resolve the recent pushback related to iojs formula as this puts the two projects on equal footing.
  • npm can be installed and patched according to the needs of homebrew and a dependency chain can be enforced.
  • users are free to install global npm modules, and these stay out of the way of homebrew's npm cellar.
  • npm is free to update itself (eg npm install -g npm@latest or npm install -g npm@next) and it works as well as it should.
  • brew doctor does not start to complain after npm updates itself.
  • brew can update npm and it works the way one would expect.

Wackiness

  • updating npm with npm installs a second copy of npm into #{HOMEBREW_PREFIX}/lib/node_modules.
  • whichever method (brew update npm or npm install -g npm@latest) is run last will take precedence over which version of npm is used. Users can also use brew unlink npm && brew link npm to put brews npm back in place.
  • Currently, updating npm with npm would undo the npm patch applied by brew. In the future, this wont be such a big issue as the npm devs are committed to keeping compatibility between iojs and node patches won't be needed.

As both a homebrew user and a node user, I don't find this wackiness to be unreasonable.

Current iojs formula discussions

working iojs taps

Past iojs formula discussions

npm formula issues:

Extra thanks for all the info and help from @othiym23, @mistydemeo, @DomT4, @rvagg, @aredridel and @MikeMcQuaid

@MikeMcQuaid
Copy link
Member

the npm formula should depend on node OR iojs. Right now, it only depends on node. I don't know how to do this. Can someone help me wrangle Library/Homebrew/requirements.rb to enable this?

Basically both just need a Requirement that looks for which("node").

Neither iojs or node "depend" on npm. But it should probably be installed automatically with these unless told not to. Is there a way to do that? Right now I just added a caveat instructing people to brew install npm.

Yeh, that's my main objection to this. We don't really support this model and it doesn't really fit with other similar packages. If we can work out a way that node and iojs wouldn't hate then having npm installed to the node Cellar again may be a better possible solution.

@bcomnes
Copy link
Contributor Author

bcomnes commented Jan 29, 2015

I got a bit of tunnel vision working on this last night. I have another idea that might work well, I'll send a parallel PR to this later.

I'll research npm configuration a bit more today.

@bcomnes
Copy link
Contributor Author

bcomnes commented Jan 29, 2015

Symlinking #{Formula["iojs"].opt_lib}/node_modules/npm to #{HOMEBREW_PREFIX}/lib/node_modules/npm didn't work. Link gets overwritten when npm updates itself.

@aredridel
Copy link
Contributor

Wow. That wackiness actually sounds like a good status quo to me. If I tell either brew or npm to do something, it does it.

@bcomnes
Copy link
Contributor Author

bcomnes commented Jan 29, 2015

@aredridel It does leave the possibility for one system or the other to leave a bunch of symlinks in the way of the other, resulting in the need to run a brew prune or brew link --force. Thats what I mean by weirdness.

@bcomnes
Copy link
Contributor Author

bcomnes commented Jan 29, 2015

I back-ported patch changes that I learned from this PR to the existing formula: #36357

@bcomnes bcomnes changed the title Possible node, iojs and npm resolution Node, iojs and npm formula resolution Jan 29, 2015
@bcomnes bcomnes mentioned this pull request Jan 29, 2015
2 tasks
@bcomnes
Copy link
Contributor Author

bcomnes commented Jan 30, 2015

Closing in favor of #36369 for now.

@bcomnes bcomnes closed this Jan 30, 2015
@Homebrew Homebrew locked and limited conversation to collaborators Feb 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants