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

irb doesn't work when using gemspec in the Gemfile. #76

Open
Sean1708 opened this issue Jan 5, 2021 · 3 comments
Open

irb doesn't work when using gemspec in the Gemfile. #76

Sean1708 opened this issue Jan 5, 2021 · 3 comments

Comments

@Sean1708
Copy link

Sean1708 commented Jan 5, 2021

With the following files in a directory

# Gemfile
source 'https://rubygems.org'

gemspec
# foo.gemspec
Gem::Specification.new do |spec|
    spec.name = 'foo'
    spec.version = '0.0.0'
    spec.authors = ["me"]
    spec.summary = "A gem."
end
# shell.nix
let
  pkgs = import <nixpkgs> { };
  environment = pkgs.bundlerEnv {
    name = "foo";

    inherit (pkgs) ruby;
    gemdir = ./.;
  };
in environment.env

running

$(nix-build '<nixpkgs>' -A bundix --no-out-link)/bin/bundix --magic

succeeds and produces

# .bundle/config 
---
BUNDLE_PATH: "vendor/bundle"
BUNDLE_CACHE_ALL: "true"
# Gemfile.lock 
PATH
  remote: .
  specs:
    foo (0.0.0)

GEM
  remote: https://rubygems.org/
  specs:

PLATFORMS
  ruby

DEPENDENCIES
  foo!

BUNDLED WITH
   2.1.4
# gemset.nix 
{
  foo = {
    groups = ["default"];
    platforms = [{
      engine = "maglev";
    } {
      engine = "maglev";
    } {
      engine = "maglev";
      version = "1.8";
    } {
      engine = "maglev";
      version = "1.8";
    } {
      engine = "maglev";
      version = "1.9";
    } {
      engine = "maglev";
      version = "1.9";
    } {
      engine = "maglev";
      version = "2.0";
    } {
      engine = "maglev";
      version = "2.0";
    } {
      engine = "maglev";
      version = "2.1";
    } {
      engine = "maglev";
      version = "2.1";
    } {
      engine = "maglev";
      version = "2.2";
    } {
      engine = "maglev";
      version = "2.2";
    } {
      engine = "maglev";
      version = "2.3";
    } {
      engine = "maglev";
      version = "2.3";
    } {
      engine = "maglev";
      version = "2.4";
    } {
      engine = "maglev";
      version = "2.4";
    } {
      engine = "maglev";
      version = "2.5";
    } {
      engine = "maglev";
      version = "2.5";
    } {
      engine = "maglev";
      version = "2.6";
    } {
      engine = "maglev";
      version = "2.6";
    } {
      engine = "rbx";
    } {
      engine = "rbx";
    } {
      engine = "rbx";
      version = "1.8";
    } {
      engine = "rbx";
      version = "1.9";
    } {
      engine = "rbx";
      version = "2.0";
    } {
      engine = "rbx";
      version = "2.1";
    } {
      engine = "rbx";
      version = "2.2";
    } {
      engine = "rbx";
      version = "2.3";
    } {
      engine = "rbx";
      version = "2.4";
    } {
      engine = "rbx";
      version = "2.5";
    } {
      engine = "rbx";
      version = "2.6";
    } {
      engine = "ruby";
    } {
      engine = "ruby";
    } {
      engine = "ruby";
    } {
      engine = "ruby";
      version = "1.8";
    } {
      engine = "ruby";
      version = "1.8";
    } {
      engine = "ruby";
      version = "1.9";
    } {
      engine = "ruby";
      version = "1.9";
    } {
      engine = "ruby";
      version = "2.0";
    } {
      engine = "ruby";
      version = "2.0";
    } {
      engine = "ruby";
      version = "2.1";
    } {
      engine = "ruby";
      version = "2.1";
    } {
      engine = "ruby";
      version = "2.2";
    } {
      engine = "ruby";
      version = "2.2";
    } {
      engine = "ruby";
      version = "2.3";
    } {
      engine = "ruby";
      version = "2.3";
    } {
      engine = "ruby";
      version = "2.4";
    } {
      engine = "ruby";
      version = "2.4";
    } {
      engine = "ruby";
      version = "2.5";
    } {
      engine = "ruby";
      version = "2.5";
    } {
      engine = "ruby";
      version = "2.6";
    } {
      engine = "ruby";
      version = "2.6";
    }];
    source = {
      path = ./.;
      type = "path";
    };
    version = "0.0.0";
  };
}

Finally running nix-shell --run irb gives the following error:

[!] There was an error parsing `Gemfile`: There are no gemspecs at /nix/store/lf2ccppcgbprijr89vkyxkg1sjx8cr59-gemfile-and-lockfile. Bundler cannot continue.

 #  from /nix/store/lf2ccppcgbprijr89vkyxkg1sjx8cr59-gemfile-and-lockfile/Gemfile:3
 #  -------------------------------------------
 #  
 >  gemspec
 #  -------------------------------------------

If instead the files are

# Gemfile
source 'https://rubygems.org'
# shell.nix
let
  pkgs = import <nixpkgs> { };
  environment = pkgs.bundlerEnv {
    name = "foo";

    inherit (pkgs) ruby;
    gemdir = ./.;
  };
in environment.env

then

$(nix-build '<nixpkgs>' -A bundix --no-out-link)/bin/bundix --magic

produces

# .bundle/config 
---
BUNDLE_PATH: "vendor/bundle"
BUNDLE_CACHE_ALL: "true"
# Gemfile.lock 
GEM
  remote: https://rubygems.org/
  specs:

PLATFORMS
  ruby

DEPENDENCIES

BUNDLED WITH
   2.1.4
# gemset.nix    
{
}

and nix-shell --run irb works correctly.

Hopefully it goes without saying that the same behaviour occurs when I do use some actual dependencies!

@jaen
Copy link

jaen commented Jan 13, 2021

Encountering thesame behaviour here

@melg8
Copy link

melg8 commented Mar 31, 2021

Encountered same problem.

@floehopper
Copy link

floehopper commented Jan 11, 2022

I'm seeing something similar. This issue looks closely related to #73.

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

4 participants