Question

Although I've often come here for solutions, however this is my first post!

Problem:

When trying to run "rails generate cucumber:install" I receive the error: Could not find generator cucumber:install

Note: When using plain Ruby on Windows I have managed to successfully configure cucumber, but had to change because of the dependency on java libraries and requirement for Jruby...

Background: Setting up a testing pc that requires Windows and Java 6.

  • Using Windows XP
  • Downloaded and installed Jruby 1.7.9
  • Downloaded Ruby Dev Kit 4.5.2 (32 bit)
  • installed the required gems for the project (which worked previously on plain ruby) using "jruby
    -S gem install x"
  • generated a new rails project
  • Did the necessary bundle init and bundle install
  • Get stuck trying to do the cucumber install for the project to generate the required artifacts.

List of installed gems: "jruby -S gem list --local"

* LOCAL GEMS *

  • actionmailer (4.0.2)
  • actionpack (4.0.2)
  • activemodel (4.0.2)
  • activerecord (4.0.2)
  • activerecord-deprecated_finders (1.0.3)
  • activerecord-jdbc-adapter (1.3.3)
  • activerecord-jdbcsqlite3-adapter (1.3.3)
  • activesupport (4.0.2)
  • arel (4.0.1)
  • atomic (1.1.14 java)
  • builder (3.2.2, 3.1.4)
  • bundler (1.3.5)
  • capybara (2.2.0)
  • coffee-rails (4.0.1)
  • coffee-script (2.2.0)
  • coffee-script-source (1.6.3)
  • cucumber (1.3.10)
  • cucumber-rails (1.4.0)
  • diff-lcs (1.2.5)
  • erubis (2.7.0)
  • execjs (2.0.2)
  • gherkin (2.12.2 java)
  • hike (1.2.3)
  • i18n (0.6.9)
  • jbuilder (1.5.3)
  • jdbc-sqlite3 (3.7.2.1)
  • jquery-rails (3.0.4)
  • jruby-win32ole (0.8.5)
  • json (1.8.1 java)
  • mail (2.5.4)
  • mime-types (1.25.1)
  • mini_portile (0.5.2)
  • minitest (4.7.5)
  • multi_json (1.8.2) multi_test (0.0.2)
  • nokogiri (1.6.0 java)
  • polyglot (0.3.3)
  • rack (1.5.2)
  • rack-test (0.6.2)
  • rails (4.0.2)
  • railties (4.0.2)
  • rake (10.1.0)
  • rdoc (3.12.2)
  • rubygems-update (2.1.11)
  • sass (3.2.12)
  • sass-rails (4.0.1)
  • sdoc (0.3.20)
  • sprockets (2.10.1)
  • sprockets-rails (2.0.1)
  • therubyrhino (2.0.2)
  • therubyrhino_jar (1.7.4)
  • thor (0.18.1)
  • thread_safe (0.1.3 java)
  • tilt (1.4.1)
  • treetop (1.4.15)
  • turbolinks (2.0.0)
  • tzinfo (0.3.38)
  • uglifier (2.3.2)
  • xpath (2.0.0)

List of Generators:

  • Rails:
  • assets
  • controller
  • generator
  • helper
  • integration_test
  • jbuilder
  • mailer
  • migration
  • model
  • resource
  • scaffold
  • scaffold_controller
  • task
  • Coffee:
  • coffee:assets
  • Jdbc:
  • jdbc
  • Jquery:
  • jquery:install
  • Js:
  • js:assets
  • TestUnit:
  • test_unit:plugin

So how can I get the cucumber-rails generator to be added to the rails generator list?

I have searched forums and have not come up with an answer, please try to the assist in answering the questions and not simply post a url to another article/forum, as this does not appear to be a duplicate.

Your help would be appreciated!

As requested - here is the Gemfile from the project directory created by "rails generate project_name"

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use jdbcsqlite3 as the database for Active Record
gem 'activerecord-jdbcsqlite3-adapter'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyrhino'

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

Note: I am still new to this Jruby/Ruby and cucumber, so not yet sure what to look for.

Was it helpful?

Solution

The problem was related to Jruby not setting the GEM_HOME and GEM_PATH variables, they were not set by default on the Jruby install. To fix, this you will need the gem location for your ruby installation (run "gem env" to find the GEM PATHS). In my particular case this was: c:\jruby-1.7.9/lib/ruby/gems/shared

Create the System Variables for both GEM_HOME and GEM_PATH and set the value to the path you found above.

Thereafter the Gemfile in the project directory required a manual update to include the line:

gem 'cucumber-rails'

Note: I also added cucumber for good measure as below in the Gemfile.

gem 'cucumber' 

Then run:

bundle install

Then install cucumber:

rails generate cucumber:install  

A Special thanks to Gregory for his support, although it was not the complete solution, he provided some key steps that were required after fixing the Environment.

OTHER TIPS

You are missing the cucumber gem from your gemfile

gem "cucumber-rails"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top