bobvanderlinden / nixpkgs-ruby

A Nix repository with all Ruby versions being kept up-to-date automatically
120 stars 25 forks source link

Customize bundler version #72

Open ryansch opened 1 year ago

ryansch commented 1 year ago

I'm currently using this project via devenv.sh with the following configuration:

  # https://devenv.sh/languages/
  languages.ruby.enable = true;
  # Uses bobvanderlinden/nixpkgs-ruby to supply any version of ruby
  languages.ruby.versionFile = ./.ruby-version;

I think I'm getting bundler from this project since the version devenv reports via devenv update isn't available.

How do I update bundler?

bobvanderlinden commented 1 year ago

Hmm, interesting. Bundler is shipped with Ruby nowadays, so the Ruby packages have it in /bin/bundle:

$ nix build github:bobvanderlinden/nixpkgs-ruby#"ruby-3" --print-out-paths 
/nix/store/52k5x0jcrxxx857ilizpiafk8fy7rfa1-ruby-3.2.2
$ ls -l /nix/store/52k5x0jcrxxx857ilizpiafk8fy7rfa1-ruby-3.2.2/bin
/nix/store/52k5x0jcrxxx857ilizpiafk8fy7rfa1-ruby-3.2.2/bin/bundle

That means if there is no other bundler package available it will pick the one shipped with Ruby.

The Ruby module in devenv places the bundler package from nixpkgs below the Ruby package:

https://github.com/cachix/devenv/blob/a908c8bb7d21f97e1aff3489307087fa68913e5d/src/modules/languages/ruby.nix#L84-L87

Maybe that prioritizes the bundler from nixpkgs lower than the one from Ruby and thus the one from Ruby ends up in the devenv profile?

Does it help to add packages = lib.mkBefore [ pkgs.bundler ]; to devenv.nix?