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

failing to execute bundix due to bundler version read in Gemfile #92

Open
drzln opened this issue Aug 8, 2022 · 3 comments
Open

failing to execute bundix due to bundler version read in Gemfile #92

drzln opened this issue Aug 8, 2022 · 3 comments

Comments

@drzln
Copy link

drzln commented Aug 8, 2022

Hello,

It would seem that bundix is unhappy with the bundler read in the Gemfile. My understanding is bundix should be an isolated binary with all its necessary dependencies with it.

Traceback (most recent call last):
        8: from /nix/store/fm8l4xxawiw08a9ylwgzkqc46whgh53d-bundix-2.5.1/bin/.bundix-wrapped:18:in `<main>'
        7: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems.rb:298:in `activate_bin_path'
        6: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems.rb:298:in `synchronize'
        5: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems.rb:299:in `block in activate_bin_path'
        4: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1372:in `activate'
        3: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1390:in `activate_dependencies'
        2: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1390:in `each'
        1: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1402:in `block in activate_dependencies'
/nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/dependency.rb:313:in `to_specs': Could not find 'bundler' (1.17.3) required by your /home/luis/code/tapresearch/raynor/Gemfile.lock. (Gem::MissingSpecVersionError)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.17.3`
Checked in 'GEM_PATH=/nix/store/85p5si2a5amra5f3vbq6qjhsl127ck5i-bundler-2.3.9/lib/ruby/gems/2.7.0:/nix/store/fm8l4xxawiw08a9ylwgzkqc46whgh53d-bundix-2.5.1/lib/ruby/gems/2.7.0:/nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/gems/2.7.0' , execute `gem env` for more information
        8: from /nix/store/fm8l4xxawiw08a9ylwgzkqc46whgh53d-bundix-2.5.1/bin/.bundix-wrapped:18:in `<main>'
        7: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems.rb:298:in `activate_bin_path'
        6: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems.rb:298:in `synchronize'
        5: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems.rb:299:in `block in activate_bin_path'
        4: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1372:in `activate'
        3: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1390:in `activate_dependencies'
        2: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1390:in `each'
        1: from /nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1401:in `block in activate_dependencies'
/nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/2.7.0/rubygems/specification.rb:1404:in `rescue in block in activate_dependencies': Could not find 'bundler' (>= 1.11) among 57 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/nix/store/85p5si2a5amra5f3vbq6qjhsl127ck5i-bundler-2.3.9/lib/ruby/gems/2.7.0:/nix/store/fm8l4xxawiw08a9ylwgzkqc46whgh53d-bundix-2.5.1/lib/ruby/gems/2.7.0:/nix/store/ki8kjxf7bnrykyv3jsr8g7cqm8sgc9b2-ruby-2.7.6/lib/ruby/gems/2.7.0' at: /nix/store/fm8l4xxawiw08a9ylwgzkqc46whgh53d-bundix-2.5.1/lib/ruby/gems/2.7.0/specifications/bundix-2.5.0.gemspec, execute `gem env` for more information
┌───────────────────>
│<rio>
│raynor
│on  nix_configuration
└─>✖  bundle --version
Bundler version 1.17.3```

Is there something I'm doing particularly wrong here?
@pfgray
Copy link

pfgray commented Aug 12, 2022

It looks like bundix pulls bundler from nixpkgs (https://github.com/nix-community/bundix/blob/master/default.nix#L23), which is currently v2.3.9.

If there's a way to override that, you might be able to replace that with bundler v1.17.3

@pfgray
Copy link

pfgray commented Aug 12, 2022

I was able to hack around this by checking out the bundix repo, replacing the bundler reference with an old version from nix, building it, and using the executable in my project.

Here's the changes I made to bundix:

diff --git a/default.nix b/default.nix
index f72ea93..6f664e9 100644
--- a/default.nix
+++ b/default.nix
@@ -1,10 +1,18 @@
 {
   pkgs ? (import <nixpkgs> {}),
-  ruby ? pkgs.ruby_2_6,
+  ruby ? pkgs.ruby_2_7,
   bundler ? (pkgs.bundler.override { inherit ruby; }),
   nix ? pkgs.nix,
   nix-prefetch-git ? pkgs.nix-prefetch-git,
 }:
+let
+  old_nixpkgs = import (
+    builtins.fetchTarball {
+      url = "https://github.com/nixos/nixpkgs/archive/96a1dbac972c4f67aea7ee548f4e5531003f8ab0.tar.gz";
+      sha256 = "0mx335ym9ai3ci3dgwszk289xjpvsqf6xx6g43250y5zwz9692mz";
+    }
+  ) {};
+in
 pkgs.stdenv.mkDerivation rec {
   version = "2.5.0";
   name = "bundix";
@@ -20,7 +28,7 @@ pkgs.stdenv.mkDerivation rec {
   '';

   nativeBuildInputs = [ pkgs.makeWrapper ];
-  buildInputs = [ ruby bundler ];
+  buildInputs = [ ruby old_nixpkgs.bundler ];

   meta = {
     inherit version;

and then after that, I ran nix-build ., and then I had a bundix executable in result/bin/bundix which had bundler v1.17.3.

You can check out the history of bundler on nixpkgs here to find other commit shas with different versions: https://github.com/NixOS/nixpkgs/commits/350fd0044447ae8712392c6b212a18bdf2433e71/pkgs/development/ruby-modules/bundler

Someone with more nix experience than me could probably come up with a better solution, maybe there's a way you can override bundix's bundler version from just a reference to the derivation?

@AndrewKvalheim
Copy link

In case it helps anyone, here’s how I did it:

let
  bundler_1_17_3 = (import (pkgs.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs";
    rev = "fcc8660d359d2c582b0b148739a72cec476cfef5";
    hash = "sha256-eZhUhVwSWkLqhmbOoBDd26J42CeyhMcYxXRqjGuVXFs=";
  }) { }).bundler;

  bundix = pkgs.bundix.override {
    bundler = bundler_1_17_3.override {
      ruby = pkgs.ruby_2_7;
    };
  };
in
pkgs.mkShell {
  buildInputs = [ bundix ];
}

Nix Package Versions is useful for finding the old revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants