How do I resolve a Cucumber 'can't load such file' warning?

dglass picture dglass · Feb 27, 2013 · Viewed 7.9k times · Source

I'm trying to work through 'The Cucumber Book', but Cucumber is not behaving as expected.

I'm on Windows 7 (32-bit), and I'm reasonably confident I have Ruby and the necessary gems installed properly.

However, when I run cucumber I get the following message:

WARNING: cannot load such file -- 2.0/gherkin_lexer_en
Couldn't load 2.0/gherkin_lexer_en
The $LOAD_PATH was:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/bin/../lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6-x86-mingw32/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/builder-3.2.0/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.1/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib

This continues for a bit, listing more paths that were checked, and then a 'Reverting to Ruby lexer', and a message 'No lexer was found for en (cannot load such file --gherkin/lexer/en)...'

Based on the path it is checking it seems like it wants a '2.0' folder in the 'gherkin-2.11.6-x86-mingw32/lib' folder, which obviously doesn't exist. There are, however, '1.8' and '1.9' folders which appear to have the 'gherkin_lexer_en' file (actually 'gherkin_lexer_en.so').

As a wild guess, I duplicated the 1.9 folder and named it 2.0. I didn't really expect that would work, but figured it was worth a shot.

How do I get cucumber to look in one of the folders I have, or alternatively get a 2.0 folder in place that it will accept?

Answer

maruti060385 picture maruti060385 · Jun 29, 2015

$ gem install gherkin --platform ruby

go to below folder inside your ruby installation directory

{rubyDir}\lib\ruby\gems\2.0.0\gems\gherkin-2.12.2\lib\gherkin

may be different path for you guys

Modify *lib/gherkin/c_lexer.rb:7 change the value of prefix as below:

prefix = ''

Found answer at below link https://github.com/cucumber/gherkin/issues/273

with reply mscharley commented on Jan 18, 2014

worked for me like charm..