News for hackers. Stuff that matters.
Re:Bundler to be integrated into Rubygems by plorkyeran on Tuesday December 03, 2013 @01:51PM (#6842233)
With Bundler, you have a single copy of each (version of each) library installed, and Bundler decides at runtime which to make visible (which is trivial with Gemfile.lock, since all of the interesting logic is done when creating that). This decision is a global one, so if you depend on two libraries that themselves depend on libfoo, both of those libraries have to use the same libfoo, and there's no difference between having a direct dependency on libfoo and depending on a library that depends on libfoo.

With npm, each library has its own set of dependencies (and those libraries have their own sets of dependencies, and so on) that are entirely separate. Thus, if you depend on two libraries that use libfoo, those two libraries have their own copies of libfoo - and those two copies can be different versions, if needed (and if libfoo depends on libbar, you'll have two copies of that too). This makes the presence of dependencies much less leaky and eliminates most problems with incompatible gem versions at the cost of wasted disk space, (usually trivially) increased memory usage and some potential confusion. It also happens to make npm pretty mind-numbingly simple compared to bundler's dependency resolution logic.

Re:Bundler to be integrated into Rubygems by djur on Tuesday December 03, 2013 @02:34PM (#6842556)
Rubygems doesn't have the luxury of providing that kind of system, though, because of how 'require' works in Ruby. AMD/RequireJS allows requires to be scoped, while Ruby requires dump directly into the global namespace.
Re:Bundler to be integrated into Rubygems by xs_kid on Tuesday December 03, 2013 @03:49PM (#6843082)
Right and the guy of the last comment of the issue is proposing also an solution for it:

https://github.com/soveran/cargo

Re:Bundler to be integrated into Rubygems by stormbrew on Tuesday December 03, 2013 @05:34PM (#6843678)
No matter what it's too leaky an abstraction. Everything in the stdlib uses require. Every fundamental piece of ruby code not in the stdlib uses require. The process of getting from point A to point C involves crossing a point B so frustrating, limiting, and ugly no one is really willing to cross it.

Ruby's global constant namespace was probably a mistake in hindsight, but at this point it'd be a language fork to change it meaningfully.

Re:Bundler to be integrated into Rubygems by ollysb on Tuesday December 03, 2013 @04:12PM (#6843220)
I was wondering how you could achieve the same level of isolation in ruby, this looks like a very interesting project. Ruby projects move fast and even though they're pretty good about semantic versioning this isn't enough to save you when your Gemfile starts filling up. Cargo looks like a huge improvement over require.
Re:Bundler to be integrated into Rubygems by yxhuvud on Tuesday December 03, 2013 @02:14PM (#6842398)
It sounds like npm quite easily can become a dependency hell where you have no idea whatsoever what code is actually being run.
Re:Bundler to be integrated into Rubygems by pilif on Tuesday December 03, 2013 @02:22PM (#6842451)
On one hand that's certainly true. On the other: Do you care how $LIB does some work for you? Does it matter to you whether $LIB uses $OTHERLIB in version 0.1 or 0.2? Does it matter to you whether $LIB bundles $OTHERLIB as a package or whether it just includes the source code of $OTHERLIB?

Yes. I see the security implications of running an outdated $OTHERLIB, but that's $LIB's responsibility, no matter whether they include a copy of $OTHERLIB as its own package in a subdirectory or whether they just copy $OTHERLIB into their own code base.

Once you bundle dependencies, you're responsible for security holes in them.

The other issue of course is RAM usage once you start running multiple identical copies of $OTHERLIB, but that's only if they use identical versions. If it's different versions, you will have to run multiple copies at once or you risk breaking your dependencies. Or you don't run at all (Bundler's "solution")

Re:Bundler to be integrated into Rubygems by stormbrew on Tuesday December 03, 2013 @02:37PM (#6842576)
I'm not sure there's any universal answer to the questions you pose in your first paragraph. The problem is that sometimes you do care (sometimes a library is actually an interface into some kind of stateful machine) and sometimes you don't (when it's just objects that hold their own state). To some extent javascript gets a bit of a free ride on this question because most libraries are designed around there being only one global state machine (the event loop), but ruby doesn't impose an execution model on you.
Re:Bundler to be integrated into Rubygems by plorkyeran on Tuesday December 03, 2013 @02:56PM (#6842725)
Yeah, I think npm's model is the correct one for node, but it's not universally better than all others by any means. It's not possible at all in many languages, would result in absurd compilation times and disk space usage in compiled languages, and makes security audits much more difficult. It's certainly not very compatible with an environment where every dependency requires external approval.
Re:Bundler to be integrated into Rubygems by jrochkind1 on Tuesday December 03, 2013 @10:51PM (#6844932)
> Do you care how $LIB does some work for you? Does it matter to you whether $LIB uses $OTHERLIB in version 0.1 or 0.2?

Only when debugging. But that's a pretty big 'only when'

Re:Bundler to be integrated into Rubygems by rschmitty on Tuesday December 03, 2013 @08:42PM (#6844484)
Can't you just "vendor everything" and now each project will install all of the gems locally to vendor and not be concerned about global choices?

http://ryan.mcgeary.org/2011/02/09/vendor-everything-still-a...

Re:Bundler to be integrated into Rubygems by tomphoolery on Wednesday December 04, 2013 @12:34AM (#6845219)
Sure, but if you use Git this can get pretty hard to deal with especially on large repos with lots of history. A `git clone` downloads an entire repo, and all of its history...so if you have a bunch of gems or executables in there that boosts the contents of your repo tremendously.

This is why there is `bundle install --deployment`, which "freezes" the Gemfile and ensures it has not changed from what has been committed to the repo. If it has, `bundle install` will not succeed.

Re:Bundler to be integrated into Rubygems by tomphoolery on Wednesday December 04, 2013 @12:37AM (#6845226)
I do like npm's simplicity. You used to have to be really careful with the versions, because if you didn't specify it would just download the latest version, and sometimes some of your dependencies would use the wrong versions of libraries and APIs would change and things go haywire. I think they've fixed a lot of that now, though...it was certainly easier a few months ago than it was a few years ago.