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

Bundler::GemRequireError on yard-cucumber 3 when running scenario via "bundle exec cucumber" #72

Closed
cameronheard opened this issue Apr 11, 2016 · 1 comment · Fixed by #83

Comments

@cameronheard
Copy link

I'm trying to use:

  • yard-cucumber 3.0.0

with:

  • ruby 2.3.0
  • bundler 1.11.2
  • cucumber 2.3.3
  • gherkin 3.2
  • yard 0.8.7.6

Outside of the context of bundle exec, I'm able to generate documentation. Unfortunately, the rest of my application needs to run in context of Bundler.

When running a Cucumber scenario via "bundle exec cucumber", I get

[error]: Invalid configuration file, using default options.
[error]: NameError: uninitialized constant Cucumber::Gherkin::AstBuilder
[error]: Stack trace:
    /Users/cameron/.rvm/gems/ruby-2.3.0/gems/yard-cucumber-3.0.0/lib/cucumber/city_builder.rb:3:in `<module:Parser>'
    /Users/cameron/.rvm/gems/ruby-2.3.0/gems/yard-cucumber-3.0.0/lib/cucumber/city_builder.rb:2:in `<module:Cucumber>'
    /Users/cameron/.rvm/gems/ruby-2.3.0/gems/yard-cucumber-3.0.0/lib/cucumber/city_builder.rb:1:in `<top (required)>'
    /Users/cameron/.rvm/gems/ruby-2.3.0/gems/yard-cucumber-3.0.0/lib/yard-cucumber.rb:14:in `require'
    /Users/cameron/.rvm/gems/ruby-2.3.0/gems/yard-cucumber-3.0.0/lib/yard-cucumber.rb:14:in `<top (required)>'
    /Users/cameron/.rvm/gems/ruby-2.3.0/gems/yard-0.8.7.6/lib/yard/config.rb:161:in `require'

There was an error while trying to load the gem 'yard-cucumber'. (Bundler::GemRequireError)
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
/Users/cameron/Desktop/yard_cucumber_example/features/support/env.rb:1:in `<top (required)>'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/runtime/support_code.rb:83:in `each'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/runtime.rb:254:in `load_step_definitions'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/runtime.rb:62:in `run!'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/lib/cucumber/cli/main.rb:32:in `execute!'
/Users/cameron/.rvm/gems/ruby-2.3.0/gems/cucumber-2.3.3/bin/cucumber:8:in `<top (required)>'
/Users/cameron/.rvm/gems/ruby-2.3.0/bin/cucumber:23:in `load'
/Users/cameron/.rvm/gems/ruby-2.3.0/bin/cucumber:23:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'

The specific complaint being uninitialized constant Cucumber::Gherkin::AstBuilder in yard-cucumber-3.0.0/lib/cucumber/city_builder.rb

It seems that, with Bundler at least, there is an attempt during inheritance to find Gherkin::AstBuilder within the scope of the parent Cucumber module of city_builder.rb, which doesn't exist.

I experimented and noticed if I added an include Gherkin to city_builder.rb, the errors went away:

include Gherkin
module Cucumber
  module Parser
    class CityBuilder < AstBuilder

I'm not clear what else that change would break, however.

@sharmajai21
Copy link

Thanks, @cameronheard it worked for me as well !!!
Just to add one more bit, earlier I had something like:

module Cucumber
module Parser
class CityBuilder < Gherkin::AstBuilder

And I changed it to

include Gherkin
module Cucumber
module Parser
class CityBuilder < AstBuilder

weh pushed a commit to weh/yard-cucumber that referenced this issue May 17, 2017
There was an error while trying to load the gem 'yard-cucumber'.
Gem Load Error is: uninitialized constant Cucumber::Gherkin::AstBuilder

fixes burtlo#72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants