cucumber-attic / gherkin2

A fast Gherkin parser in Ragel (The parser behind Cucumber)
MIT License
381 stars 220 forks source link

WARNING: cannot load such file -- 2.0/gherkin_lexer_en(win7+ruby 2.0.0+gherkin 2.12.1 ) #273

Closed screw-spike closed 9 years ago

screw-spike commented 11 years ago

Hello I am workin in windows 7 64bit with ruby 2.0.0p247 (2013-06-27) [x64-mingw32] and gherkin 2.12.1 and it doesn't work fine when I try to use it, I always have the same message:

WARNING: cannot load such file -- 2.0/gherkin_lexer_en Couldn't load 2.0/gherkin_lexer_en The $LOAD_PATH was: lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/bin/../lib D:/Program Files (x86)/JetBrains/RubyMine 5.0/rb/testing/patch/common D:/Program Files (x86)/JetBrains/RubyMine 5.0/rb/testing/patch/bdd D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/builder-3.2.2/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.4/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/multi_json-1.8.0/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/gherkin-2.12.1/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/multi_test-0.0.2/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-expectations-2.14.2/lib D:/Ruby200-x64/lib/ruby/site_ruby/2.0.0 D:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/x64-msvcrt D:/Ruby200-x64/lib/ruby/site_ruby D:/Ruby200-x64/lib/ruby/vendor_ruby/2.0.0 D:/Ruby200-x64/lib/ruby/vendor_ruby/2.0.0/x64-msvcrt D:/Ruby200-x64/lib/ruby/vendor_ruby D:/Ruby200-x64/lib/ruby/2.0.0 D:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32. Reverting to Ruby lexer. WARNING: cannot load such file -- 2.0/gherkin_lexer_en Couldn't load 2.0/gherkin_lexer_en The $LOAD_PATH was: lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/bin/../lib D:/Program Files (x86)/JetBrains/RubyMine 5.0/rb/testing/patch/common D:/Program Files (x86)/JetBrains/RubyMine 5.0/rb/testing/patch/bdd D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/builder-3.2.2/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.4/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/multi_json-1.8.0/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/gherkin-2.12.1/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/multi_test-0.0.2/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-expectations-2.14.2/lib D:/Ruby200-x64/lib/ruby/site_ruby/2.0.0 D:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/x64-msvcrt D:/Ruby200-x64/lib/ruby/site_ruby D:/Ruby200-x64/lib/ruby/vendor_ruby/2.0.0 D:/Ruby200-x64/lib/ruby/vendor_ruby/2.0.0/x64-msvcrt D:/Ruby200-x64/lib/ruby/vendor_ruby D:/Ruby200-x64/lib/ruby/2.0.0 D:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32. Reverting to Ruby lexer. wrong number of arguments (1 for 0) (ArgumentError) D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/location.rb:22:in file_colon_line' D:/Program Files (x86)/JetBrains/RubyMine 5.0/rb/testing/patch/bdd/teamcity/cucumber/common.rb:126:intc_before_feature' D:/Program Files (x86)/JetBrains/RubyMine 5.0/rb/testing/patch/bdd/teamcity/cucumber/formatter_03103.rb:46:in before_feature' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/tree_walker.rb:181:inblock in send_to_all' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/tree_walker.rb:179:in each' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/tree_walker.rb:179:insend_to_all' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/tree_walker.rb:169:in broadcast' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/tree_walker.rb:26:invisit_feature' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/features.rb:28:in block in accept' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/features.rb:17:ineach' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/features.rb:17:in each' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/features.rb:27:inaccept' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/tree_walker.rb:21:in block in visit_features' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/tree_walker.rb:170:inbroadcast' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/ast/tree_walker.rb:20:in visit_features' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/runtime.rb:48:inrun!' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/lib/cucumber/cli/main.rb:47:in execute!' D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/cucumber-1.3.8/bin/cucumber:13:in<top (required)>' D:/Ruby200-x64/bin/cucumber:23:in load' D:/Ruby200-x64/bin/cucumber:23:in<top (required)>' -e:1:in load' -e:1:in

'

Process finished with exit code 1 Empty test suite. Does anybody know the problem? Thanks in advance

aslakhellesoy commented 11 years ago

The problem is that Windows doesn't come with a C compiler, so the Cucumber team has to precompile the gherkin C extensions for all the combinations of:

Currently we only build for x86-mingw32. The workaround until someone fixes this is to use 32bit ruby.

mscharley commented 10 years ago

@aslakhellesoy Another Windows x64 user here, having this issue as well with 2.12.2. What needs to happen to make this work? I have a mingw toolchain installed if you need help compiling stuff. Incidentally, the RubyInstaller versions of ruby for windows ship with a 'devkit' for compiling native extensions. Is there something missing from that needed for gherkin?

aslakhellesoy commented 10 years ago

Hi @mscharley - what needs to be done is to tweak Gherkin's overly complex build scripts to either:

a) build both x64 and x86 dlls b) build only x64 dlls

I think b) would be a lot easier to achieve, but it would mean we no longer support x86. Do you think a lot of people would be unable to upgrade their rubies to x64?

mscharley commented 10 years ago

@aslakhellesoy Unable; probably not, unwilling is more likely. There's still a few gems (like gherkin currently) that have issues with windows/x64.

Worth noting, I built the ruby platform gem just fine with the standard devkit from RubyInstaller but it still doesn't work as it seems there's different paths for the Windows extensions. Is it really necessary to bundle these binaries?

mscharley commented 10 years ago

There are large messages instructing people what to do if they don't install the optional devkit if they haven't and try to install a binary gem.

mscharley commented 10 years ago

@aslakhellesoy The following works for me:

$ ruby --version
ruby 2.0.0p353 (2013-11-22) [x64-mingw32]
$ gem install gherkin --platform ruby

Modify lib/gherkin/c_lexer.rb:7 to read as

prefix = ''
mscharley commented 10 years ago

Even if you want to go the precompiled route, can you still allow windows users to use the ruby platform gem in the case if they have a relevant compiler installer? Seems like an easy workaround in the interim if the build scripts are a pain.

aslakhellesoy commented 10 years ago

What you suggest sounds like a good workaround. x86 users will continue to enjoy prebuilt dlls. x64 users will have to install the ruby platform gem (with devkit installed), and compile it themselves.

We need to be a little smarter about how to assign the prefix value. I don't have windows handy - do you know of any RbConfig::CONFIG fields that would allow us to distinguish ruby x86 from x64?

mscharley commented 10 years ago

Too simple?

irb(main):002:0> RbConfig::CONFIG['arch']
=> "x64-mingw32"

Others:

irb(main):004:0> RbConfig::CONFIG['RUBY_SO_NAME']
=> "x64-msvcrt-ruby200"
irb(main):007:0> RbConfig::CONFIG['target_cpu']
=> "x64"
irb(main):008:0> RbConfig::CONFIG['target']
=> "x86_64-w64-mingw32"
irb(main):009:0> RbConfig::CONFIG['target_vendor']
=> "w64"

I imagine these would be replaced with x86 and w32 as appropriate on the 32 bit builds but I don't have one handy.

Alternatively, attempt to load without a prefix first and retry with a prefix on a LoadError (or vice versa).

brasmusson commented 10 years ago

On a Windows XP with Ruby 1.9, I get the following:

irb(main):004:0> RbConfig::CONFIG['arch']
=> "i386-mingw32"
irb(main):005:0> RbConfig::CONFIG['RUBY_SO_NAME']
=> "msvcrt-ruby191"
irb(main):006:0> RbConfig::CONFIG['target_cpu']
=> "i386"
irb(main):007:0> RbConfig::CONFIG['target']
=> "i386-pc-mingw32"
irb(main):008:0> RbConfig::CONFIG['target_vendor']
=> "pc"
kramerdog commented 10 years ago

Hi @aslakhellesoy and @mscharley

Your fix here appears to work. Thanks. In other word if I edit c_lexer within ...\Ruby200-x64\lib\ruby\gems\2.0.0\gems\gherkin-2.12.2\lib\gherkin then all is good.

However, this doesnt seem like the best approach for fixing the problem even in the short term (not supported by my automated deployment script)

The only problem is that this has been sitting as a Pull Request for a month now - waiting for the next point release I guess.

In the meantime I have been trying to monkey patch my Rails setup but to no avail. There are obviously a few things lacking my understanding of Rails...

1) The patch appears to be for a Gherkin module and yet the Pull request is for the Cucumber project. I can only see a few references to Gherkin within Cucumber but there is no gherkin folder or c_lexer file within Cucumber.

2) The fixed code is for the self.[] method of the Gherkin::CLexer module so I am thinking that this method is mixed in to any class that includes it. And yet I cant find any reference to the CLexer module throughout the whole of Rails so I have no idea how this is supposed to work?

3) I was trying to add a patch to my lib folder to override the whole Gherkin::CLexer module but cant get any of the following variations to work:

Override as is Include the self.[] method within a class<< self block Include the self.[] method within a self.class_eval block

Tried various combinations of requires but really dont know what needs to be required or where.

Help?

Thanks in advance

brasmusson commented 10 years ago

@kramerdog I'm not a Rails user so I cannot answer all your questions, but I can at least make some clarifications.

The pull request is for the Gherkin project (cucumber/gherkin), from which Gherkin parsers for many languages are build; a Ruby gem, a Java jar file etc. etc.

The Cucumber project (cucumber/cucumber) has the Gherkin gem as a dependency.

To monkey patch your Rails setup I think you have to check which version of Cucumber is used there, and then check which version of Gherkin that version of Cucumber uses. Possibly patching that version of the Gherkin gem could solve your problem.

mscharley commented 10 years ago

@kramerdog You're going to have a much easier job of it if you just patch the files directly. I'm not sure you can effectively monkey patch this change in; it gets included in other classes, but before you will ever get a chance to monkey patch anything. If you're worried about distribution issues (ie, you're using windows servers for testing) then vendor the gem with the patch till it gets fixed upstream.

kramerdog commented 10 years ago

Thanks for your input Bjorn. As you said, it doesnt completely solve my problem but does increase my understanding.

I had always assumed that Gherkin was an "independent" project and not "part of" Cucumber, just a dependency of Cucumber.

On Tue, Feb 18, 2014 at 10:09 PM, Björn Rasmusson notifications@github.comwrote:

@kramerdog https://github.com/kramerdog I'm not a Rails user so I cannot answer all your questions, but I can at least make some clarifications.

The pull request is for the Gherkin project (cucumber/gherkin), from which Gherkin parsers for many languages are build; a Ruby gem, a Java jar file etc. etc.

The Cucumber project (cucumber/cucumber) has the Gherkin gem as a dependencyhttps://github.com/cucumber/cucumber/blob/master/cucumber.gemspec#L20 .

To monkey patch your Rails setup I think you have to check which version of Cucumber is used there, and then check which version of Gherkin that version of Cucumber uses. Possibly patching that version of the Gherkin gem could solve your problem.

Reply to this email directly or view it on GitHubhttps://github.com/cucumber/gherkin/issues/273#issuecomment-35377879 .

kramerdog commented 10 years ago

Matthew

Thanks for the advice. That would explain why my efforts seem to be futile to inject the code at the right point via monkey patch.

And you are right that I maybe shouldnt worry so much about patching as it wont affect my production deployment which is Ubuntu even though developing on Windows.

Youve saved me heaps of time trying to figure out why I cant get a solution. Thanks again.

On Tue, Feb 18, 2014 at 10:44 PM, Matthew Scharley <notifications@github.com

wrote:

@kramerdog https://github.com/kramerdog You're going to have a much easier job of it if you just patch the files directly. I'm not sure you can effectively monkey patch this change in; it gets included in other classes, but before you will ever get a chance to monkey patch anything. If you're worried about distribution issues (ie, you're using windows servers for testing) then vendor the gem with the patch till it gets fixed upstream.

Reply to this email directly or view it on GitHubhttps://github.com/cucumber/gherkin/issues/273#issuecomment-35380541 .

evakili commented 10 years ago

I've this problem too, although my ruby arch is i386-mingw32. But @mscharley workaround is worked for me! Thanks.

kevinrood commented 10 years ago

I would also like to see this resolved for Win64

amaanmemon commented 9 years ago

i am having the same error..>>>>cannot load such file -- 2.1/gherkin_lexer_en and pretty new to calabash...anybody can help me wid steps>> please consider this as urgent

thanks in advance

wpride commented 9 years ago

@mscharley thanks much!

jeffnyman commented 9 years ago

The fix by @mscharley does work but the problem I find is that if I have users on Windows simply do "gem install gherkin", they get the mingw32 version which seems to not work even with the fix proposed. If I make sure everyone uses "gem install gherkin --platform ruby" then the fix proposed works. However, we have Ruby projects with Gemfiles and if someone runs a "bundle install" they usually get the mingw32 version loaded -- even if they already have the "platform ruby" version of Gherkin installed.

Once that happens, the fix no longer works any more. Further, I then usually get a segmentation fault when attempting to "gem uninstall" gherkin.

This really does need to be fixed if there is a desire to have Cucumber be viable in the Windows world. I'm working with a series of consulting firms (that are in turn working with legal and health care firms), all using Windows. This lack of ability to just have Cucumber and Gherkin run has quite literally stopped them from adoption.

kevinrood commented 9 years ago

@jnyman would specifying the platform in your Gemfile help?

gem 'gherkin', platforms: :ruby

Not an ideal solution I know.

As an aside, I ended up using JRuby to solve my problems related to running Ruby on Windows.

mscharley commented 9 years ago

@jnyman that is only because there's a mingw32 version of the gem pushed to the repositories currently. If this fix was adopted upstream this wouldn't be an actual issue.

@aslakhellesoy what's the status of this issue? It's been swimming around for a while now.

mattwynne commented 9 years ago

We're actively working on a new Gherkin parser: https://github.com/cucumber/gherkin3 which will replace this one. One of the main drivers of that re-write is that this one has become a major pain to build and release.

Realistically though, we're probably 6 months minimum away from having gherkin 3 integrated into Cucumber-Ruby and in production. I hate shutting Windows users out like this. I've experienced the same as you @jnyman on client site, and it's embarrassing.

Does anyone have the energy to try and get a new version of the gherkin gem built with the pure ruby parser in it? I'd happily release a new version of Cucumber that depends on it, and help that person get their build of gherkin released.

tooky commented 9 years ago

@mattwynne I have a windows vm now. Maybe we can sort something at cukeup?

jeffnyman commented 9 years ago

@tooky , @mattwynne - I have a ton of energy to help. My only problem is that I don't know if my skills would be up to the task. I have plenty of Windows machines that I could help test on, however. Further, I certainly don't mind working to level up my skills and contribute where I can.

osteenbergen commented 9 years ago

@mattwynne Did you (or anybody else) make any progress?

Does anyone have the energy to try and get a new version of the gherkin gem built with the pure ruby parser in it? I'd happily release a new version of Cucumber that depends on it, and help that person get their build of gherkin released

Do you mean a version of gherkin 2 with the gherkin3 parser in it, or a gem that by default uses platform=ruby? I could probably find some time to tinker with it

weiserma commented 9 years ago

Any resolution to this. Just installed a new platform and still getting the cannot load file. tried changing the prefix... didn't help.

ruby 2.1.6p336 (2015-04-13 revision 50298) [i386-mingw32]

kramerdog commented 9 years ago

I ended up side-stepping this issue completely by doing all of my development in a Ubuntu VM running on the Windows machine.

It makes much more sense to develop in the same environment as my target deployment environment anyway.

Good luck.

On Fri, Aug 14, 2015 at 2:48 AM, weiserma notifications@github.com wrote:

Any resolution to this. Just installed a new platform and still getting the cannot load file. tried changing the prefix... didn't help.

ruby 2.1.6p336 (2015-04-13 revision 50298) [i386-mingw32]

— Reply to this email directly or view it on GitHub https://github.com/cucumber/gherkin/issues/273#issuecomment-130755969.

mattwynne commented 9 years ago

Cucumber-Ruby v2.1 now uses the new Gherkin3 parser. Please give it a try!

d-led commented 8 years ago

superb, thanks!! v2.1 works without the nuisance