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

Add :node special dependency #1408

Closed
wants to merge 2 commits into from

Conversation

torifat
Copy link

@torifat torifat commented Oct 30, 2016

screenshot 2016-10-30 19 46 31

@@ -17,3 +17,4 @@
TuntapDependency = TuntapRequirement
X11Dependency = X11Requirement
ConflictsWithBinaryOsxfuse = NonBinaryOsxfuseRequirement
NodeRequirement = NodeRequirement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to add a compatibility layer for a new requirement.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for pointing it out 😄

fatal true
default_formula "node"
satisfy { which("node") }
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this to a separate node_requirement.rb file and, like the JavaRequirement, support using a version argument. This should perhaps be compulsory like the `RubyRequirement.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Thanks 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should perhaps be compulsory like the RubyRequirement.

I wouldn't recommend this, personally.

@torifat torifat force-pushed the feature/dependency-node branch 2 times, most recently from 1ec0125 to e9789e3 Compare November 2, 2016 18:58
@torifat
Copy link
Author

torifat commented Nov 2, 2016

@MikeMcQuaid I'm not good at Ruby. Can you please guide me here? I have implemented the version checking and it's working.

But, brew still trying to install node even if return value of satisfy build_env: false do is true.

screenshot 2016-11-03 02 35 09

@DomT4
Copy link
Member

DomT4 commented Nov 2, 2016

But, brew still trying to install node even if return value of satisfy build_env: false do is true.

Are you pouring the bottle of a formula to check? If so, that's expected and correct behaviour. To avoid the default_formula you'd need to build from source, brew install blah -s, etc.

@torifat
Copy link
Author

torifat commented Nov 2, 2016

@DomT4 ah, thanks. So, the current code should work fine. Though I forgot to remove require "language/node" which is not needed there anymore.

Update: It's working 😄 Thanks again.

@torifat
Copy link
Author

torifat commented Nov 3, 2016

Any idea why this test fails only in Jenkins?

NodeRequirementTests#test_satisfied [/Users/brew/Jenkins/pr-brew/version/any_sierra/Library/Homebrew/test/test_node_requirement.rb:29]:
Expected #<NodeRequirement: "node" [] version="4.0">
 to be satisfied?.

@torifat torifat force-pushed the feature/dependency-node branch 2 times, most recently from 4bbeec1 to 8b70786 Compare November 3, 2016 13:43
@reitermarkus reitermarkus dismissed their stale review November 4, 2016 00:14

Has been addressed.

@torifat
Copy link
Author

torifat commented Nov 5, 2016

@MikeMcQuaid Can you have a look here, please?

@MikeMcQuaid
Copy link
Member

Any idea why this test fails only in Jenkins?

Likely because there's no Node installed there. You may need to do some mocking.

As @DomT4 mentions above some things that are worth considering on this once it's 💚:

  1. can something that uses npm install from node at build-time use iojs or a (very) different node version at runtime?
  2. as-is all bottled formulae using depends_on :node will end up being depends_on "node" by default. This could be worked around if 1) is resolved.

@torifat
Copy link
Author

torifat commented Nov 5, 2016

Likely because there's no Node installed there. You may need to do some mocking.

But, I have mocked node and it works locally & in travis too.

https://github.com/Homebrew/brew/pull/1408/files#diff-595241f18c3635cda19d357a78dc5c52R6

  1. As long as it meets the version requirement it should work.

@Daniel15
Copy link

Daniel15 commented Nov 5, 2016

can something that uses npm install from node at build-time use iojs or a (very) different node version at runtime?

This works most of the time, the main exception is when using native modules, where it only works if you install the package on a version of Node.js that's binary (ABI) compatible with the version you use at runtime. In that case, I think generally some package installed using npm 6.x should run on any other 6.x version of npm.

The vast majority of npm packages are non-native packages that just contain JavaScript code so it doesn't matter which version of Node.js you used to install them.

Also iojs is completely unsupported now, so it's not worth worrying about it.

@MikeMcQuaid
Copy link
Member

In that case, I think generally some package installed using npm 6.x should run on any other 6.x version of npm.

Ok. We'll need to figure out a way to encode that into this requirement.

The vast majority of npm packages are non-native packages that just contain JavaScript code so it doesn't matter which version of Node.js you used to install them.

Good to know.

Also iojs is completely unsupported now, so it's not worth worrying about it.

The voice of a non-packager 😉. As we're just looking for a node in $PATH we will likely find some people/systems with weird stuff like iojs still around so we'll need to detect and handle these cases.

@torifat
Copy link
Author

torifat commented Nov 6, 2016

@MikeMcQuaid which node should work for iojs too.

screenshot 2016-11-07 00 08 08

There's no version conflict too:
Node & IO versions

And, finally I mocked node in test but it's failing in Jenkins 😢 Working in both local & travis.

https://github.com/Homebrew/brew/pull/1408/files#diff-595241f18c3635cda19d357a78dc5c52R6

@MikeMcQuaid
Copy link
Member

And, finally I mocked node in test but it's failing in Jenkins 😢 Working in both local & travis.

Let's not worry about that until the PR handles the other issues above. When it's working there I'll help fix the issues.

@ilovezfs
Copy link
Contributor

Are we sure we want yet another one of these special requirements given the difficulties we've had with the others?

@MikeMcQuaid
Copy link
Member

@ilovezfs I think this may be one where we can handle bottles sensible due to this being interpreted with vendored dependencies rather than using linkage. This PR is still a bit off, though, and there's a bunch of questions to be answered and implemented.

@torifat
Copy link
Author

torifat commented Nov 15, 2016

@MikeMcQuaid I tried to answer all the questions you asked and also pursed @Daniel15 to answer too.

Ok. We'll need to figure out a way to encode that into this requirement.

Any suggestions regarding how we can do that?

bunch of questions to be answered and implemented.

I'm not sure which questions are still unanswered.

@MikeMcQuaid
Copy link
Member

As long as it meets the version requirement it should work.

We'll need confirmation that it does work and has been tested with a couple of different depends_on "node" formulae.

Any suggestions regarding how we can do that?

I'm not sure. Are you saying both the Node and NPM version matter at runtime?

@torifat
Copy link
Author

torifat commented Nov 15, 2016

We'll need confirmation that it does work and has been tested with a couple of different depends_on "node" formulae.

I can do that for a few popular formulae.

I'm not sure. Are you saying both the Node and NPM version matter at runtime?

Only node version matters. npm is mostly backward compatible.

IMO brew shouldn't handle npm install or yarn install. Formulae tarball should comes with node_modules like yarn tarball.

@MikeMcQuaid
Copy link
Member

I can do that for a few popular formulae.

Thanks! Report back in here and try with node, homebrew/versions/node4-lts, homebrew/versions/node6-lts and homebrew/versions/iojs formulae.

npm is mostly backward compatible.

Can you elaborate on "mostly"?

IMO brew shouldn't handle npm install or yarn install. Formulae tarball should comes with node_modules like yarn tarball.

Check out the e.g. yarn.rb and jsonlint.rb formulae. We're open to doing it in a different way but may need some formula PRs for that. Thanks!

@gsklee
Copy link

gsklee commented Jan 10, 2017

Is something blocking further progress of this MR?

@tonytonyjan
Copy link

wonder if there is any progress

@MikeMcQuaid
Copy link
Member

There's no news or progress. If there was it'd be posted on here. If anyone would like to try and create their own PR: please do.

@sjmueller
Copy link

Why is this taking so long? Right now yarn from homebrew is broken for lots and lots of people who use nvm. Simply check if node or nvm is installed and skip as necessary. Even if it doesn't handle every case, surely it will improve from what's out there now...

@ilovezfs
Copy link
Contributor

Sorry I don't understand. The requirement system is only intended to provide non-mandatory flexibility. The default formula should always be sufficient to build any formulae, so the urgency here is pretty low unless you're doing something peculiar.

@DomT4
Copy link
Member

DomT4 commented Jan 13, 2017

Having used nvm and Homebrew together for quite some time in the past I'm fairly sure the most "broken" I ever found things was the minor irritation of having two Nodes installed. As ILZ points out, you'll still have to remember to stick an -s on brew install xyz where applicable to avoid that happening even if this is merged.

@MikeMcQuaid
Copy link
Member

Why is this taking so long?

Because it's neither the maintainers nor contributors paid employment to work on Homebrew or submit a PR to fix this. This PR has changes requested that need addressed and it's failing CI.

If you'd like to create your own competing PR, we'd welcome it. This document should help and we're happy to walk you through anything else.

Thanks!

Simply check if node or nvm is installed and skip as necessary. Even if it doesn't handle every case, surely it will improve from what's out there now...

If it were a simple problem to solve, it would have been solved already.

@sjmueller
Copy link

So are you saying there is a way right now to install yarn via homebrew without installing a second copy of node (when using nvm)?

@Daniel15
Copy link

@sjmueller I no longer have a Mac so I can't test this, but the --ignore-dependencies flag should work

@jeanregisser
Copy link

Yes this flag works, but the next time you do a brew upgrade and there's an update for yarn, it will install it with the node deps.

@ilovezfs
Copy link
Contributor

@sjmueller as @DomT4 said above, "the most 'broken' I ever found things was the minor irritation of having two Nodes installed."

@MikeMcQuaid
Copy link
Member

@sjmueller two current options:

  1. Stop caring about having two nodes on your system
  2. Install Yarn through NPM or other means

@Daniel15
Copy link

Daniel15 commented Jan 13, 2017 via email

@torifat
Copy link
Author

torifat commented Jan 13, 2017

Sorry, I'm migrating to another country. So, currently not getting enough time to work on this. Anyone interested should take the lead.

@DomT4
Copy link
Member

DomT4 commented Jan 13, 2017

If the primary reason most people want this is to avoid dual installations that's a slippery slope towards:

depends_on :rust
depends_on :go
depends_on :node
depends_on :swift
depends_on :mono
depends_on :maven
depends_on :opam

And so on. I can see an argument for it but I also see endless new possibilities for people to break their local builds in interesting ways and then expect Homebrew to know how to fix those use cases, and quickly. Homebrew has already seen quite a bit of that with the :ruby and to a slightly lesser degree :perl requirements.

I think it would be useful if the argument gets fleshed out a bit more than "Having two of these is annoying", especially when a plain Homebrew node installation clocks in at <50MB, which even on the smallest SSDs Apple ships these days is a sneeze of disk space.

@sjmueller
Copy link

In my experience it's been quite a hassle having two versions of node competing on the same system. When something goes wrong, which version is running? Did this particular terminal instance use a different node because a path variable was changed? If I'm hunting down a global dependency that I linked locally, am I looking in the right dir?

Much easier to troubleshoot when nvm is given autonomy to manage node versions, resulting in a single source of truth.

@MikeMcQuaid
Copy link
Member

@sjmueller A solution has been provided for that. Let's keep the discussion off this PR now, thanks,.

@michael-yx-wu
Copy link

Would it also be possible to make this work for folks who use nodenv instead of nvm to manage node versions?

@DomT4
Copy link
Member

DomT4 commented Jan 31, 2017

A requirement won't care where it's coming from as long as the node and npm executables are found. But someone would still need to complete any remaining work here, and convince the remaining maintainers there's an inconvenience beyond a sneeze of disk space.

@ilovezfs
Copy link
Contributor

@DomT4 Wait, I'm confused. So you're not volunteering to implement :rust, :go, :node, :swift, :mono, :maven, and :opam? I had my hopes up!

@DomT4
Copy link
Member

DomT4 commented Jan 31, 2017

@ilovezfs All of those being a thing might actually be enough to push me to find an alternative package manager, and I used to help maintain this one 😆.

@ilovezfs
Copy link
Contributor

I think you and fink will get along swimmingly.

@DomT4
Copy link
Member

DomT4 commented Jan 31, 2017

Come on now, I didn't say I hated myself and felt the deep need for self-punishment 😉. (Mike's going to tell us off for dragging this off-topic any second, heh).

@MikeMcQuaid
Copy link
Member

Closing as this has stalled.

@SimenB
Copy link

SimenB commented Mar 31, 2017

For now avoid using the :node requirement and just demonstrate how npm install isn't required, thanks!

Homebrew/homebrew-core#11881

@Homebrew Homebrew locked and limited conversation to collaborators May 14, 2017
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.