chef / appbundler

Generate locked binstubs for ruby applications
Apache License 2.0
14 stars 10 forks source link

Bundler as a dependency doesn't work #4

Closed mikesimons closed 8 years ago

mikesimons commented 9 years ago

When bundler creates the lock file it omits itself from the resolved specs. This means that when appbundler tries to process the lock file it can't find the spec for bundler.

I'm not sure what the best resolution would be but the following strike me:

Anything beyond that would require using or replicating the bundler constraint resolution I think.

Here are steps to reproduce:

Gemfile:

source 'https://rubygems.org'
gemspec

testing.gemspec:

Gem::Specification.new do |spec|
  spec.name          = "testing"
  spec.version       = '0'
  spec.summary       = 'testing'
  spec.executables   = 'testing'
  spec.authors       = [ 'mike' ]
  spec.add_dependency "bundler", ">= 1.5.2"
end

mkdir bin && touch bin/testing

bundle install

appbundler . .

The resulting Gemfile.lock looks like this:

PATH
  remote: .
  specs:
    testing (0)
      bundler (>= 1.5.2)

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

PLATFORMS
  ruby

DEPENDENCIES
  testing!
mikesimons commented 9 years ago

Oh, and here is the error :facepalm:

/home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:161:in `spec_for': No spec bundler (RuntimeError)
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:153:in `block in add_dependencies_from'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:151:in `each'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:151:in `add_dependencies_from'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:129:in `runtime_dep_specs'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:106:in `runtime_activate'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:116:in `binstub'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:33:in `block (2 levels) in write_executable_stubs'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:32:in `open'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:32:in `block in write_executable_stubs'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:31:in `each'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/app.rb:31:in `write_executable_stubs'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/cli.rb:54:in `run'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/lib/appbundler/cli.rb:10:in `run'
    from /home/mike/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/appbundler-0.2.0/bin/appbundler:12:in `<top (required)>'
    from /home/mike/.rbenv/versions/2.1.1/bin/appbundler:23:in `load'
    from /home/mike/.rbenv/versions/2.1.1/bin/appbundler:23:in `<main>'
    from /home/mike/.rbenv/versions/2.1.1/bin/ruby_executable_hooks:15:in `eval'
    from /home/mike/.rbenv/versions/2.1.1/bin/ruby_executable_hooks:15:in `<main>'
danielsdeleo commented 9 years ago

I'd be okay with special casing bundler. My initial reaction is that bundler ought not exclude itself from the lock, but I imagine there's a really good reason why they have to (seems like bundler would conflict with itself after an upgrade or some scenario like that).

Either of your options is fine to me, as I don't have a use case for appbundling bundler; I guess the second one seems "better" since it at least locks bundler to something that you know works.

lamont-granquist commented 8 years ago

22