Bundler pre bug #171

Merged
merged 2 commits into from Sep 23, 2011

Conversation

Projects
None yet
4 participants
@chaffeqa
Contributor

chaffeqa commented Sep 22, 2011

Fixes Bundler --pre issue that only arrises if cucumber-rails is included outside of group :test.

Its a real edge case, but the fix was pretty painless and actually makes the code base more robust.

Basically any require of lib/cucumber/rails.rb will be ignored unless the call is from env.rb.

I also added a warning message to admonish users to put cucumber-rails under group :test (if the edge case is triggered)

@chaffeqa

This comment has been minimized.

Show comment
Hide comment
@chaffeqa

chaffeqa Sep 22, 2011

Contributor

I did create a ticket for bundler btw: bundler/bundler#1448

Contributor

chaffeqa commented Sep 22, 2011

I did create a ticket for bundler btw: bundler/bundler#1448

aslakhellesoy added a commit that referenced this pull request Sep 23, 2011

@aslakhellesoy aslakhellesoy merged commit c23d391 into cucumber:master Sep 23, 2011

@pda

This comment has been minimized.

Show comment
Hide comment
@pda

pda Oct 24, 2011

The instructions in the warning message were not enough to prevent the warning for me.

Apart from moving cucumber-rails to a test-only bundler group, I had to prevent it being loaded by Bundler:

gem "cucumber-rails", "~> 1.0", require: false

Here's the backtrace of the warning I was getting prior to adding require: false:

⸩ rspec
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:76:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:76:in `rescue in block in require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:62:in `block in require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:55:in `each'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:55:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler.rb:128:in `require'
/Users/paul/org/project/config/application.rb:7:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/config/environment.rb:2:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/spec/spec_helper.rb:8:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/spec/models/example_spec.rb:1:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `map'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load_spec_files'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/command_line.rb:18:in `run'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:80:in `run_in_process'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:69:in `run'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:10:in `block in autorun'

WARNING: Cucumber-rails required outside of env.rb.  The rest of loading is being defered until env.rb is called.
  To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile

pda commented Oct 24, 2011

The instructions in the warning message were not enough to prevent the warning for me.

Apart from moving cucumber-rails to a test-only bundler group, I had to prevent it being loaded by Bundler:

gem "cucumber-rails", "~> 1.0", require: false

Here's the backtrace of the warning I was getting prior to adding require: false:

⸩ rspec
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:76:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:76:in `rescue in block in require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:62:in `block in require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:55:in `each'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler/runtime.rb:55:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc/lib/bundler.rb:128:in `require'
/Users/paul/org/project/config/application.rb:7:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/config/environment.rb:2:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/spec/spec_helper.rb:8:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/paul/org/project/spec/models/example_spec.rb:1:in `<top (required)>'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `map'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load_spec_files'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/command_line.rb:18:in `run'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:80:in `run_in_process'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:69:in `run'
/Users/paul/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:10:in `block in autorun'

WARNING: Cucumber-rails required outside of env.rb.  The rest of loading is being defered until env.rb is called.
  To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
@JeanMertz

This comment has been minimized.

Show comment
Hide comment
@JeanMertz

JeanMertz Nov 12, 2011

same here, I already had the gem in the test group, but that didn't stop this message from showing up. using require: false solved this for now.

same here, I already had the gem in the test group, but that didn't stop this message from showing up. using require: false solved this for now.

@aslakhellesoy

This comment has been minimized.

Show comment
Hide comment
@aslakhellesoy

aslakhellesoy Nov 12, 2011

Contributor

What kind of ruby syntax is require: false ? Is that a new way to make a Hash?

Contributor

aslakhellesoy commented Nov 12, 2011

What kind of ruby syntax is require: false ? Is that a new way to make a Hash?

@JeanMertz

This comment has been minimized.

Show comment
Hide comment
@JeanMertz

JeanMertz Nov 12, 2011

Yes, it's the Ruby 1.9 style of assigning values in a hash. See here for the best explanation on the entire web.

Yes, it's the Ruby 1.9 style of assigning values in a hash. See here for the best explanation on the entire web.

@chaffeqa

This comment has been minimized.

Show comment
Hide comment
@chaffeqa

chaffeqa Nov 19, 2011

Contributor

Sorry for taking so long to get back about this...

I'm guessing that since you use require: false the cucumber-rails lib isn't getting loaded by bundler.

Could you try it without the require: false and get back to me about whether it worked?

Contributor

chaffeqa commented Nov 19, 2011

Sorry for taking so long to get back about this...

I'm guessing that since you use require: false the cucumber-rails lib isn't getting loaded by bundler.

Could you try it without the require: false and get back to me about whether it worked?

@aslakhellesoy

This comment has been minimized.

Show comment
Hide comment
@aslakhellesoy

aslakhellesoy Nov 19, 2011

Contributor

Folks, please open a new ticket. This is a closed pull request.

Contributor

aslakhellesoy commented Nov 19, 2011

Folks, please open a new ticket. This is a closed pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment