4 ms·
I'm awkwardly patting myself on the back here since I'm one of the co-authors, but I really wish more people knew about the package manager we have for Dart[1].
by munificent 12y ago
I'm awkwardly patting myself on the back here since I'm one of the co-authors, but I really wish more people knew about the package manager we have for Dart[1]. Really, though, I can't take credit, since we basically just do the same thing Bundler does.
[1]: https://www.dartlang.org/tools/pub/get-started.html https://www.dartlang.org/tools/pub/get-started.html
It solves every single one of the problems listed here. It has a very simple workflow:
1. You make a pubspec.yaml file to list your package's immediate dependencies and the version ranges you allow for them.
2. You run "pub get". It finds all of your transitive dependencies, picks versions that satisfy the constraints, and downloads them.
It also creates a pubspec.lock file that specifies which versions it picked for everything. You check that into source control and now everyone on your team will use the exact same versions of all of your package's dependencies.
3. When you want to get a new version of a dependency, you run "pub upgrade <package>".
4. To add or remove a dependency, just edit your pubspec.yaml file then run "pub get" again.
We have a central repository where packages or hosted, and you can also pull in packages from Git or your local file system.
Packages do not at all interfere with each other. Two packages on your machine can use different versions of the same dependency without any problem.
Bundler is an absolutely brilliant package manager. My prediction is that every language either has a Bundler-style package manager or will eventually move to one.
- andrewchambers 12y agoI think something like this combined with the new gb project tool would be a good solution.
- lobster_johnson 12y agoBundler is among the better package-dependency management solutions. I do wish Bundler would simply be bundled into Ruby at this point; it's become so ingrained that there's no longer any reason to not make it a first-class citizen. The one big problem with Bundler is "bundle exec", which is required because project-local gems can conflict with system-wide gems. If all of Ruby honoured Bundler, we could let the Ruby runtime itself handle the gem isolation. My main complaint about Bundler and RubyGems (and NPM for that matter) is that we're still unpacking packages with no good reason. RubyGems would be easier to deal with if you could just treat .gem files like Java does with JAR files. (The sore point is gems requiring compilation of binaries, but that's solvable.) Actually, I have another complaint: Even after numerous security gaffes, gems still generally aren't signed.
- RickHull 12y agoThere is a long-term plan, I believe, to merge all necessary bundler features into rubygems. Much of this has already taken place, as rubygems has (generic) support for Gemfile and Gemfile.lock
- pjungwir 12y agoAt least in development, if you use rvm gemsets you can avoid having to type `bundle exec`. In fact I learned recently that nowadays you don't even need gemsets: https://rvm.io/integration/bundler https://rvm.io/integration/bundler
- lobster_johnson 12y agoInteresting. That hack is not RVM-specific (I use rbenv), but it looks like it has been superceded by the use of RUBYGEMS_GEMDEPS in RubyGems >= 2.4. If you do: export RUBYGEMS_GEMDEPS=- then all binstubs will apparently be looked up via the Gemfile.
- nulltype 12y agoOne thing I've never been able to figure out about these package management systems: why do you specify a version range, and not just always specify a precise version? I don't like dependencies randomly upgrading themselves, and then you don't need "pub upgrade" or "pubspec.lock".
- munificent 12y ago> why do you specify a version range, and not just always specify a precise version? To handle shared constraints. Let's say myapp uses foo and bar, which both use shared_thing. To solve this, we need to pick a single version of shared_thing that both foo and bar work with. If foo and bar have narrow-to-the-point-of-precise constraints like shared_thing 1.2.3+bug-fix, then it's very likely that no version of shared_thing makes both foo and bar happy. The end result is no solution. To accommodate that, packages are strongly encouraged to semantically version themselves. Then, when you depend on a package, you use as wide a range as you can. If foo wants shared_thing ">=1.2.3 <2.0.0" and bar wants ">=1.3.0 <2.0.0" then the solver can pick, say, 1.5.3, and both are happy.
- nulltype 12y agoThanks for the explanation! I'm not sure I personally want to rely on semantic versioning, but if you have a hierarchy of dependencies like that I see how that would be pretty useful.
- tene 12y agoHow do you arrange to never have any transitive dependencies?
- nulltype 12y agoI use specific versions of libraries in my app. If two libraries depend on some third library it's rarely an issue, and when it is an issue I often have to resolve it manually anyway. Ideally I think each library would have its own internal copy of any dependencies, but there are some issues with doing that at least in go.
- hittaruki 12y agoOne of the thing Cheney says in his talk about gb is that nobody likes the .lock files[1], I see that dart is using .lock files, bundlers also uses .lock files as does rust. But other languages seems to get away without it.. clojure with lenigen seems to do it nicely. So what are the problems with it? http://go-talks.appspot.com/github.com/davecheney/presentations/reproducible-builds.slide#16 http://go-talks.appspot.com/github.com/davecheney/presentati...
- Nullabillity 12y agoMaven-style dependency managers (including leiningen) just contain the locks inline in the regular build script.
- Jweb_Guru 12y agoA slight tangent, but as someone who is sort of in the "respect but do not use" Clojure category, Leiningen seems pretty amazing. I really hope future language package managers look to it for inspiration; it seems to get practically everything right.
- munificent 12y ago> One of the thing Cheney says in his talk about gb is that nobody likes the .lock files[1] That may be true if by "nobody" he means Go users, but outside of the Go community things are different. I haven't heard many complaints about them in the Ruby or Dart ecosystems, and the value they provide (repeatable builds!) is very real.
- nrser 12y agobundler is great. i really wish it worked for most major languages. switching between projects in different languages with different packaging systems is a bunch of weight i don't want to have to carry around or time i don't want to waste. it sounds like you some-what 'ported' bundler to dart... what's your impression of how difficult it would be extend a tool like this to work for many languages? it seems like i'm always asking them all to do the same thing... go get this at that version from there, include anything it needs, and stick that somewhere this thing can find it.
- munificent 12y ago> it sounds like you some-what 'ported' bundler to dart... More or less. Most of pub's code is devoted to stuff that's specific to Dart, but it's underlying "philosophy" is Bundler's model. > what's your impression of how difficult it would be extend a tool like this to work for many languages? This comes up a lot, but my hunch is that we're unlikely to see a successful language-agnostic package manager. The package manager has to be written in some language, and users of language X generally don't want to be told that they have to install language Y before they can download packages for X. Also, most of the code for a package manager is fiddly details related to the specific language in question. Thinks like how files are organized, running tests, etc. The amount of code you could share is actually pretty small.