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?
$ 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..
On Windows, you will have to use Ruby 1.9 for the time being. There isn't a Ruby 2.0 build of gherkin published yet.
If you are using gherkin ver 2.12.1, you should be able to use cucumber with ruby 2.0 on Windows now.
First, install gherkin-2.12.1 with --ignore-dependencies option.
The reson --ignore-dependencies option is required is that without specifying it, it will install json 1.4.X which is very old version and fail to install on ruby 2.0.
At this point, you should be able to ruby cucumber on ruby 2.0, but you'll see the error message like above as warning message. This means you can still use cucumber although you are seeing the message.
If you want to remove the error, follow the step below.
create [2.0] folder on [ruby installed dir]\lib\ruby\gems\2.0.0\gems\gherkin-2.12.1\lib (This folder includes gherkin_lexer_XX.so).
copy all the contents in [ruby installed dir]\lib\ruby\gems\2.0.0\gems\gherkin-2.12.1\lib to the created [2.0] folder (you don't need to copy [2.0] folder you created).
Related
I have no knowledge in Ruby, but I need to run some tests in it. The code is in Ruby and Cucumber. I use intellij on Mac. When I first open intellij cucumber step definition where not recognised from feature file. In terminal I got:
Required ruby-2.1.2 is not installed.
To install do: 'rvm install "ruby-2.1.2"'
but
$ which ruby
/Users/myuser/.rvm/rubies/ruby-2.4.1/bin/ruby
so I run the install command as suggested and now I get
$ which ruby
/Users/myuser/.rvm/rubies/ruby-2.1.2/bin/ruby
Now my feature files connected to step definition as well. I will appreciate if anyone could explain me what happened. What prompted me to downgrade the version of Ruby and how it fixed cucumber.
Make sure you have ruby 2.1.2 set in File -> Settings -> Languages & Frameworks -> Ruby SDK and Gems
What I suspect is happening is you have run rvm use 2.1.2 in the terminal but when your IDE runs something it is using the ruby version set in the settings.
You probably have a .ruby_version file in the project root directory. This will enforce a specific version of Ruby. So the person who put it there is who to ask why the version was restricted like that. There may have been a good reason, such as that's what is being used by all your users.
It has nothing to do with Cucumber. rvm has some kind of operating system hook, I think, that runs whenever you cd into a directory. It looks for its special control fiels such as .ruby_version and .rvmrc file. This page describes this in more detail: https://rvm.io/workflow/projects.
I've installed RSpec on a win7 lappy and am following along the http://rspec.info/ homepage tutorial to make sure everything works. If I am reading their demo correctly bin/rspec --format doc should run the specification test file.
Instead, I get a system prompt for a text editor... ? I am confused.
Any explanation of what is going on or guidance about how to get my RSPEC configuration working in accordance to the makers homepage would be great.
FWIW Ruby 2.2.5p319, Bundler version 1.13.1 and gem -v tells me 2.6.7 (originally I had 2.4 but that is broken on windows, so I upgraded according to http://guides.rubygems.org/ssl-certificate-update/) Also, I have basic RSpec functionality and have completed the tutorial here: https://www.tutorialspoint.com/rspec/rspec_writing_specs.htm
Ah, I figured out what I need to do... I just need to explicitly call ruby:
ruby bin/rspec --format doc
...and the test gets run - YaY!
Per #JörgWMittag, I confirmed my Environment Variable Path to make sure ruby.exe was in there (C:\Ruby22\bin;).
Then looking at my Program Defaults, I thought that maybe I could tell win7 to associate any file named "rspec" with ruby.exe per https://support.microsoft.com/en-us/help/18539/windows-7-change-default-programs ...but I couldn't actually add file type "extensions" or "protocols" - I could only change the association of existing ones, but .rb and .rbw were in there... Maybe there is a way to do this manually, but I am not a windows expert.
Thinking on all this it occurred to me that I just needed to explicitly tell ruby to ingest the command... Heh.
I apologize if this is off-topic.
I use Eclispse Kepler with DLTK plugin for ruby. I am unable to "require" nokogiri module because it cannot be found by eclipse. I tried some gem install command from some website and that did not help. Now, I don't want to use commandline until I first master Ruby programming.
I learned that I can add java jars to my project by creating a lib folder, copying jars to that folder and then adding them all to the build path. So easy, right ?
Can I do the same thing for ruby gems and modules ? Ideally, I'd like to use only the IDE for this instead of using commandline and complext install scripts.
Please help.
If this gem already installed with all dependencies, then you can add it with simple require command:
require "/path_to_gems/gem_name/lib/gem_name"
In my case the command is:
require '/Users/yukke/.rvm/gems/ruby-2.1.1/gems/nokogiri-1.6.1/lib/nokogiri'
Otherwise you can try to require rubygems first:
require "rubygems"
require "gem-name"
I would suggest maybe using a different IDE with better Ruby support, such as Aptana, which is Eclipse-based but has a lot of additional addons to support Ruby development. You can install Ruby gems in it on the start page, or through the integrated terminal.
If you run the command gem which bundler you will see the folder gems are installed on your system.
You can copy executables there but it's highly recommended you use gem install on the command line.
I have find the answer to this question. I not sure if this is the best way to do it, but it works for me. Pro developers, can you please review this answer ? So, for now let me give quick guide for this.
1 - Install Eclipse DLTK plugin for Ruby as suggested here - Preferred Ruby plugin for Eclipse?
See the answer with photo, by James.
2 - Next, lets pick a random gem such as nokogiri and download it from rubygems.org. The file name of the Gem tells you which OS its meant for. I use windows 7 64bits. So, I take version with x64-mingw32. Here is a sample list of downloads:
1.6.4.1 November 7, 2014 java (2.37 MB)
1.6.4.1 November 7, 2014 x64-mingw32 (2.86 MB)
1.6.4.1 November 7, 2014 (8.81 MB)
1.6.4.1 November 7, 2014 x86-mingw32 (3.91 MB)
1.6.4 November 5, 2014 java (2.37 MB)
Show all versions (271 total)
3 - AFAIK, eclipse cannot use the gem file as is. You need to unpack it first. Lets say you kept the gem file in c:\RubyGems\extras, and you want to unpack it there itself.
open windows cmd > cd into the above directory > gem unpack nokogiri-1.6.4.1-x64-mingw32.gem > press enter !!!
Now, your gem will be unpacked into a folder nokogiri-1.6.4.1-x64-mingw32.
4 - Locate the nokogiri.rb file inside the unpacked folder. Its in the lib folder.
Copy the full path of this folder - c:\RubyGems\extras\nokogiri-1.6.4.1-x64-mingw32\lib. We need this for eclipse.
5 - Eclipse > create new ruby project > right click project > build path > configure build path > libraries tab > add external source folder > enter the path from step 4 > Ok > ok. You can now use the gem in your project.
6 - Testing if the steps work. Use the code in your project !
require 'nokogiri'
puts "Chenqui ! It is work!!!"
If the message prints without error, then you are a success ! To see the error you get when the required modules can't be found, add something like this require 'restclient'.
I am integrating licensed version of flat-ui-pro with my Rails app.
For this, I am using 'designmodo-flatuipro-rails' gem
My environments are:-
OS - Windows7 32-bit
Ruby - 1.9.3p327
Rails - 4.0.0
twitter-bootstrap-rails - 2.2.8
jquery-ui-rails - 4.0.5
designmodo-flatuipro-rails - 1.1.4.2
I have generated "bootstrap_and_overrides.css" file by bootstrap generator at location "app/assets/stylesheets/". I am not using ".less" files for bootstrap.
I am also not getting Cannot detect twitter-bootstrap-rails install error
and Invalid Flat UI Pro directory error while running the flatUI generating command. It means I am inside the right FlatUI directory.
When I run the flat-ui-pro generate command rails g flatuipro:install ./FlatUI/HTML/UI/Flat-UI-Pro-1.1.4, It is throwing a error
Could not find "./FlatUI/HTML/UI/Flat-UI-Pro-1.1.4/css/flat-ui.css" in any of yo
ur source paths. Your current source paths are:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/designmodo-flatuipro-rails-1.1.4.2/lib/gener
ators/flatuipro/install/templates
I am getting the same error while passing the FlatUI directory containing PSD and HTML both.
I am not understanding why generator can not recognizing flat-ui.css in the right directory.
I used differ version of gem "designmodo-flatuipro-rails", "~> 1.2.2.0.branch" with the other version of FlatUI-Pro directory (1.2.2) but also getting the same error.
This is tree of FlatUiPro directory:-
Please reply with good suggestions.
Thanks.
Try changing your relative-path to the Flat-UI Pro Directory to "absolute" in the rails "generate" command, seems to work only for absolute paths!
After getting stuck very much, I found the solution.
I was hitting command in cmd-prompt:-
rails g flatuipro:install ./FlatUI/HTML/UI/Flat-UI-Pro-1.1.4
It will work with Mac/Ubuntu OS as creator of flatui-gem explained in the issue created on github <<Link of Github Issue>>
In Windows, it is mandatory to put the flatui directory out of the project folder.
For example:-
My FlatUIPro directory saved in "D:" drive, so my command will be
rails g flatuipro:install D:/FlatUI
or
rails g flatuipro:install D:/FlatUI/HTML/UI/Flat-UI-Pro-1.1.4
Please check your Flat UI Pro directory... you really are missing demo.css for some reason. Try re-downloading the Flat UI Pro assets from designmodo
I am trying to set up Ruby on Rails on windows. I am using the Flash Rails distribution that looks pretty good, but there is an issue with sqlite3. I found the threads telling me to install version 1.2.3, which installed fine. I'm using ruby 1.9.0, and every time I try and run a script (e.g. rake db:create) that uses the database I get an error message "no driver for sqlite3 found".
This apparently is a missing sqlite3.dll, but I have the dll in my %PATH%, and I have also tried copying it into the directory where I am running the script from, the directory where the sqlite3 ruby code lives.
Does anyone have any ideas? If possible I want all teh ruby stuff to be self contained so I can use it from a pen drive.
EDIT: To clarify, I already used gem install to install the ruby-sqlite3 gem - it is just non functional as it cannot find the sqlite3.dll (even though it is actually present in a directory on my %PATH%)
EDIT PART 2: After doing some more digging, the problem appears that ruby will not load the sqlite3_api.dll. I have copied it all over my filesystem, I just get a failure to read file. Other dll libraries in the same directory (e.g. zlib.dll) work fine!
I tried installing the dlls into system32, and that did not work either.
The problem put simply is that sqlite3-ruby 1.2.3 is not compatible with ruby 1.9. This is caused because ruby 1.9 does not use .dll files for c libraries it uses .so files instead. Additionally, since sqlite3_api.dll is written against msvcrt-ruby18.dll. This means that it specifically only will support ruby 1.8.*.
The good news is that there is a fat binary version that will support both ruby 1.8 and ruby 1.9. Uninstalling all former versions of sqlite3-ruby and then installing this one. (You may have to manually delete some versions the gem after uninstalling.) in order to install it use
install sqlite3-ruby --source http://gems.rubyinstaller.org
for more information see this website
Try installing the sqlite3-ruby gem:
gem install sqlite3-ruby
Something similar happened to me recently so I thought I'd update my answer.
For reference there's a sqlite3_api.dll file located in the gem's lib directory. Also the sqlite3.dll file needs to be reachable on the path. They are different files, the first is required by the gem to interface Ruby to C code, while the second contains the actual Sqlite implementation.
It's best to get the second file from the sqlite website and extract it to the Ruby\bin directory (as you shouldn't manually put DLL's into the windows or windows\system directories any more).
So for reference "sqlite3_api.dll" needs to be in:
Ruby\lib\ruby\gems\1.8\gems\sqlite3-ruby-1.2.3-x86-mswin32\lib
and "sqlite3.dll" needs to be on the path, possibly in:
Ruby\bin
As for the "driver not found" problem I would suggest trying the easy things first and making sure gems is installed correctly, up to date, and that the RUBYLIB and PATH environment variables are set appropriately. (System restart may be required to propagate the changes fully.)
Re this link
Download sqlitedll-3_6_10.zip and extract into ruby/bin!
Try going to sqlite.org download page and get the zipped up dll. Then put that in your c:\windows\system32 folder, that should allow Ruby to find it.
Restart your machine after running install sqlite3-ruby
To clarify, which gem are you using? sqlite-ruby or sqlite3-ruby?
They're part of the same project, but different releases. The key is that sqlite3 appears to have driver code included.
I assume you're attempting to use the first, since it's giving me the same error. If so, try switching.
Also.. How literal do you mean by this?
but I have the dll in my %PATH%
PATH=...;C:\sqlite\sqlite3.dll
PATH=...;C:\sqlite
The first will attempt to find C:\sqlite\sqlite3.dll\sqlite3.dll, AFAIK.
I use Ruby 1.8.7 (works with 1.9.1 too)
OS is WindowsXP SP3
Go to
http://www.sqlite.org/download.html
and Download file
sqlitedll-3_7_0_1.zip (265.19 KiB)
and unzip then we will get
sqlite3.dll
Copy sqlite3.dll to your bin folder
as C:\Ruby191\bin or C:\Ruby187\bin
then it works