【问题标题】:Jruby and Cucumber / Cucumber Rails - Could not find generator cucumber:installJruby 和 Cucumber / Cucumber Rails - 找不到发电机黄瓜:安装
【发布时间】:2013-12-11 15:42:28
【问题描述】:

虽然我经常来这里寻求解决方案,但这是我的第一篇文章!

问题:

尝试运行“rails generate cucumber:install”时 我收到错误:找不到生成器黄瓜:安装

注意:在 Windows 上使用纯 Ruby 时,我已成功配置 cucumber,但由于对 java 库的依赖和对 Jruby 的要求,不得不更改...

背景:设置需要 Windows 和 Java 6 的测试电脑。

  • 使用 Windows XP
  • 已下载并安装 Jruby 1.7.9
  • 已下载 Ruby 开发工具包 4.5.2(32 位)
  • 使用“jruby
    -S gem install x"
  • 生成了一个新的 rails 项目
  • 是否进行了必要的 bundle init 和 bundle install
  • 尝试为项目安装 Cucumber 以生成所需的工件时遇到问题。

已安装 gem 列表:“jruby -S gem list --local”

* 本地宝石 *

  • actionmailer (4.0.2)
  • 动作包 (4.0.2)
  • 活动模型 (4.0.2)
  • 活动记录 (4.0.2)
  • activerecord-deprecated_finders (1.0.3)
  • activerecord-jdbc-适配器 (1.3.3)
  • activerecord-jdbcsqlite3-adapter (1.3.3)
  • 主动支持 (4.0.2)
  • 是 (4.0.1)
  • 原子(1.1.14 java)
  • 构建器(3.2.2、3.1.4)
  • 捆绑器 (1.3.5)
  • 水豚 (2.2.0)
  • 咖啡轨 (4.0.1)
  • 咖啡脚本 (2.2.0)
  • 咖啡脚本源 (1.6.3)
  • 黄瓜(1.3.10)
  • 黄瓜导轨 (1.4.0)
  • diff-lcs (1.2.5)
  • erubis (2.7.0)
  • execjs (2.0.2)
  • 小黄瓜(2.12.2 java)
  • 远足 (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)
  • 邮件 (2.5.4)
  • mime 类型 (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)
  • 多语言 (0.3.3)
  • 机架 (1.5.2)
  • 机架测试 (0.6.2)
  • 导轨 (4.0.2)
  • railties (4.0.2)
  • 耙子 (10.1.0)
  • rdoc (3.12.2)
  • rubygems 更新 (2.1.11)
  • 萨斯 (3.2.12)
  • sass-rails (4.0.1)
  • sdoc (0.3.20)
  • 链轮 (2.10.1)
  • 链轮导轨 (2.0.1)
  • therubyrhino (2.0.2)
  • therubyrhino_jar (1.7.4)
  • 雷神 (0.18.1)
  • thread_safe (0.1.3 java)
  • 倾斜 (1.4.1)
  • 树顶(1.4.15)
  • turbolinks (2.0.0)
  • tzinfo (0.3.38)
  • 丑化剂 (2.3.2)
  • xpath (2.0.0)

生成器列表:

  • 导轨:
  • 资产
  • 控制器
  • 发电机
  • 帮手
  • 集成测试
  • jbuilder
  • 邮件
  • 迁移
  • 型号
  • 资源
  • 脚手架
  • scaffold_controller
  • 任务
  • 咖啡:
  • 咖啡:资产
  • Jdbc:
  • jdbc
  • jQuery:
  • jquery:安装
  • JS:
  • js:资产
  • 测试单元:
  • test_unit:插件

那么如何才能将 cucumber-rails 生成器添加到 rails 生成器列表中呢?

我搜索了论坛并没有找到答案,请尝试协助回答问题,而不是简单地发布另一个文章/论坛的网址,因为这似乎不是重复的。

您的帮助将不胜感激!

根据要求 - 这是由“rails generate project_name”创建的项目目录中的 Gemfile

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

注意:我对这个 Jruby/Ruby 和 cucumber 还是新手,所以还不知道要寻找什么。

【问题讨论】:

  • 请您发布您的 Gemfile 吗?
  • 嗨 Gregory,使用项目目录中的 gemfile 内容更新了帖子。任何帮助表示赞赏。

标签: cucumber jruby


【解决方案1】:

问题与 Jruby 未设置 GEM_HOMEGEM_PATH 变量有关,它们在 Jruby 安装时默认未设置。 要解决此问题,您将需要安装 ruby​​ 的 gem 位置(运行“gem env”以查找 GEM PATHS)。在我的特殊情况下,这是:c:\jruby-1.7.9/lib/ruby/gems/shared

为 GEM_HOME 和 GEM_PATH 创建系统变量,并将值设置为您在上面找到的路径。

此后项目目录中的 Gemfile 需要手动更新以包含以下行:

gem 'cucumber-rails'

注意:我还在 Gemfile 中添加了黄瓜作为很好的措施,如下所示。

gem 'cucumber' 

然后运行:

bundle install

然后安装黄瓜:

rails generate cucumber:install  

特别感谢 Gregory 的支持,虽然这不是完整的解决方案,但他提供了修复环境后所需的一些关键步骤。

【讨论】:

    【解决方案2】:

    您的 gemfile 中缺少 cucumber gem

    宝石“黄瓜轨”

    【讨论】:

    • 请原谅格式。将行添加到 gemfile:gem 'cucumber-rails' 。尝试使用以下方法安装黄瓜:rails generate cucumber:install ---> 与以前一样的结果。 rails generate cucumber-rails:install ---> 与以前一样的结果。 *认为我们走在正确的道路上,但我认为 Jruby 本身缺少黄瓜生成器这一事实是一个相关问题。
    • 你做了“bundle install”,然后“bundle exec generate cucumber:install”。这对我有用。
    • 是的,我在运行上述程序之前确实进行了捆绑安装。使用“bundle exec generate cucumber:install”时,我收到一条错误消息“Bundler: command not found: generate”。使用“bundle install”安装缺少的 gem 可执行文件。基于此线索,我运行“bundle exec gem install bundler”,然后重新运行“bundle install”,然后运行“bundle exec generate cucumber:install”。结果是一样的:“bundle: command not found: generate”。
    • 我看到的奇怪的事情是当我运行“bundle exec gem install cucumber”然后去运行“bundle exec gem list --local”时,黄瓜不见了?好像它们正在下载而不是存储在同一个存储库位置?
    • 尝试“jruby -S gem install bundler”,然后“bundle install”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-26
    • 2014-03-08
    • 1970-01-01
    • 2011-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多