-
Notifications
You must be signed in to change notification settings - Fork 220
Lexing errors - gherkin reads file differently each time #182
Comments
What OS are you on? |
Mac OS 10.7.3 |
Are you and your colleagues exchanging files via git? Some other scm? Sounds like file encoding gets converted somewhere in that process. Is there a git repo anywhere where I can access a feature file to reproduce this? Alternatively, can you Aslak |
This sounds related to what's described in this thread |
We use git, and I haven't modified the features at all (most I haven't even opened). Also, if it were a file-encoding issue, wouldn't it fail the same way every time? Each time I |
I'd rather reproduce this locally before speculating about the cause. Base64 please. |
Our files are confidential but I'm going to try and reproduce with a hello world |
Do you want the feature or the step definitions? |
Just a feature file that fails to parse would suffice. Base64 encoded to preserve encoding (in case that is the problem). Thanks! |
Ok, this feature (usually) breaks: QGphdmFzY3JpcHQKRmVhdHVyZTogRGVmZXJyZWQgc2lnbiB1cAoKICBJbiBvcmRlciB0byB1c2UgU29tZXRoaW5nCiAgQXMgYW4gdW5yZWdpc3RlcmVkIHVzZXIKICBJIHdhbnQgdG8gc2lnbiB1cCB3aXRoIG9ubHkgbXkgZW1haWwgYWRkcmVzcwoKICBTY2VuYXJpbzogQXR0ZW1wdCB0byB2aXNpdCB0aGUgc2V0dGluZ3MgcGFnZSBhcyBlbWFpbC1vbmx5IHVzZXIKICAgIEdpdmVuIGEgc2lnbmVkIGluIHJlZ2lzdGVyZWQgZW1haWwtb25seSB1c2VyIHdpdGggZW1haWwgInRlc3RAdGVzdC5jb20iCiAgICBXaGVuIEkgZ28gdG8gInRlc3RAdGVzdC5jb20iJ3MgZWRpdCBzZXR0aW5ncyBwYWdlCiAgICBUaGVuIEkgc2hvdWxkIGJlIG9uICJ0ZXN0QHRlc3QuY29tIidzIGNvbXBsZXRlIHNpZ251cCBwYWdlCgo= |
Thanks for that. After decoding it I successfully parsed it. I'm fairly confident that the behaviour you are seeing is not encoding related. To investigate further it would be helpful to know your |
$ ruby --version $ gcc --version |
Thanks for your help, by the way - I don't think I mentioned that :) |
I think that's what I have as well (don't have my laptop at work so I'll check later). I have never heard of anyone with a similar problem to this. The really odd thing is that it seems to behave inconsistently. I'm at a loss here. @ghnatiuk @msassak any ideas? Here is one more thing for you to try. Switch to the ruby lexer instead of the C one. Open up your gherkin gem's With this change, what happens then? |
Making that change, I get the same trouble. |
But perhaps a useful stack trace this time? |
Also, sprinkle a few puts statements in the beginning of your |
I'm not able to duplicate the issue w/ 1.9.3p125 and the same LLVM build. You're not sitting on top of a giant magnet, are you? If you copy just the features to a new directory and run cucumber on them there (without requiring your app/library or step defs), do you still get lexing errors? |
I put |
So far you are the only one I know of who has seen this behaviour. It sounds like something is wrong at your end. No idea what though. |
This change in the ruby-build def for 1.9.3-p125 caused different build flags (no |
I'm not sure I understand how a change in ruby-build is relevant to this issue. @bfulton can you explain? @tom-swipely confirmed above that intermittent lexing errors happen with the pure ruby lexer as well, and there is no C code involved in that case. @tom-swipely did you use ruby-build to install your ruby? |
Don't know what to make of the pure ruby lexer anecdote above. When I deleted the the C lexers it failed back to pure ruby and worked correctly. I linked to the the ruby-build commit to show the environment is uncommon: OS X 1.9.3-p125 only, but after 2012-04-23 when ruby-build also added 3 later 1.9.3 definitions. To repro the bad
To workaround, insist on
A fix might add I was unable to yield the failure with one call to Parser.parse yesterday, so I think there must be some accumulated state required. Over the weekend I'll work on further reducing the cucumber scenario that triggers it. |
I wonder if the same core issue underlies a problem we see; our Lexer error reports a different line number, but always the empty string. And it will lex without issue from time to time as well. OS X 10.7.5 |
For those seeing this issue: Do you have any feature files with a comment (or comments) at the end? |
We have cucumber tests running on Mac OS X Mountain Lion (CI environment) and am seeing lexing errors for feature files most of the time but pass once in a while without any changes to the feature files or to the step definitions themselves. This is the stack trace I see. Even the error varies for different runs with different line numbers reported in the same feature file or a different feature file Versions Stack Trace [:runHeadlessTests] /Users/teamcity/TeamCity/buildAgent/work/merchpay/qa/acceptance/features/ui/fc/fc_landing_page.feature: Lexing error on line 153: ''. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information. (Gherkin::Lexer::LexingError) I have tried a few things suggested on different threads like
Is there anyway I can debug these lexing errors? |
On 21 Dec 2012, at 18:41, smallbin wrote:
Are you able to show us what's on and around line 153 of that file at the moment? cheers, Freelance programmer & coach |
I've been having these lexer problems as well. They're really tough to track down because they're non-deterministic. But I think I found a fix: Don't use Ruby 1.8! I've not had any problems after switching to Ruby 1.9.3. |
We were having a similar problem at one point. Recompiling ruby 1.8.7 with a non LLVM compiler seemed to make it go away - @patchfx might be able to throw some more light. |
That is the thing, even the reported line numbers(or the feature file themselves) do not remain constant. @fc_landing
@vocaro @tooky Thanks, |
We’re seeing this as well. It doesn’t happen predictably, but it only happens with feature files that have a tag (e.g. |
I got the same lexing error every now and then. We also got tags in the first line of our files. Adding a comment or an empty line before these doesn't chang things however. It's not reproducible every time. Running cucumber a couple of times, it sometimes works and sometimes fails due to that lexing error. |
Has anyone seen this behaviour on MRI ruby 1.9.3? |
I do. Still running 1.9.3-p385 ATM. |
My best guess is that there is a bug in the C code somewhere. It might be a good idea to run valgrind on it to see if that uncovers something. The main priority right now is to finish Gherkin3 - a new lexer/parser based on flex/bison, so personally I don't have cycles to spend on fixing this bug. I'd be happy to take a patch though. For details about Gherkin3 - see the cukes and cukes-devs google group archives in the past 4-8 weeks. |
I'm also seeing some very odd lexing errors today:
I added some debug logging in Source: Error: So definitely sounds like a bug in the C code. EDIT: My Ruby version: |
Today I faced same issue. Setting force_ruby=true on the first line in the lexer method solved my issue. Thanks @aslakhellesoy |
We experienced the same thing, and setting force_ruby=true solved the issue. Here are some system specs: OSX 10.7.5 $ ruby --version $ gcc --version Changed lib/gherkin/i18n.rb:96 from: Only happening on one file, and the scenario steps it fails on stays consistent, but the filename the error shows is random. It almost appears that it's looking in other gems' files? Here are two examples where it looks like it's looking inside Rails. Lexing error on line 4: 'active_support/notifications.rb:52:in Lexing error on line 4: 'dispatch/middleware/static.rb:30:in |
Falling back to the ruby lexer as described in #245 seems to work so far. Thanks. :fingers-crossed |
This is also an issue for me, only on ubuntu. The same features run fine on Mac OS X with the same gem version. This worked for me but I think this issue should be resolved - couldn't the ruby lexer be made default? |
Same problem here with ruby 2.0.0p195 and cucumber 1.1.4. Updating cucumber to 1.3.13 fixed it for me. |
I'm running
bundle exec cucumber
on features that pass on 9 other peoples' machines. Each time I run it, I get gherkin lexing errors in different places.For example, I'll see a line like:
Lexing error on line 4: ' And I fill in "session_password?C?'.
The '?C?' should have been a double-quote, and that line appears on line 14, not 4.
Or, for example, these all came from the same feature line, on different runs:
Lexing error on line 4: ''.
Lexing error on line 4: 'ż'.
Lexing error on line 4: '???'.
(The line numbers are again incorrect)
In the first issue (the one with '?C?'), I looked at the file in hexdump, and the misread character was the character it was supposed to be - so the file is fine.
Specifics:
The code is in Ruby
I'm using gherkin 2.11.1, and cucumber 1.2.1
Here's what I've already tried:
export LC_CTYPE=en_US.UTF-8
gem uninstall gherkin && bundle install
bundle update gherkin
bundle update cucumber
The text was updated successfully, but these errors were encountered: