【问题标题】:Error when running rails g rspec:install in AWS cloud9 terminal运行 rails g rspec 时出错:在 AWS cloud9 终端中安装
【发布时间】:2021-04-11 14:51:10
【问题描述】:

我正在使用 AWS Cloud9 (Rails v.5.0.0, Ruby v.2.6.3) 创建一个 Rails 应用程序,并已使用 gem install rspec 成功安装 rspec,并将 gem 'rspec-rails' 添加到我的 gemfile 中的 :development, :test 块并执行了 bundle install

问题 当我尝试在终端中运行命令rails g rspec:install 时,我得到以下信息:

Running via Spring preloader in process 7356
Could not find generator 'rspec:install'. Maybe you meant 'assets', 'channel' or 'scaffold'
Run `rails generate --help` for more options.

预期我期待:

no examples found
finished in x seconds...
0 examples, 0 failures

我的尝试

  1. 在 gemfile 中的 :development, :test 块之外添加 gem 'rspec-rails',然后添加 bundle install
  2. 指定版本 (5.0)
  3. 禁用弹簧预加载器
  4. 尝试了以下命令:
bin/rails g rspec:install 
bundle exec rails g rspec:install 
bundle exec bin/rails g rspec:install

还有其他人遇到过这个问题吗?

提前谢谢你!

【问题讨论】:

  • 您的应用在 AWS Cloud9 中的 rails 环境是什么,您可以通过运行 rails r "puts Rails.env" 来检查
  • 我运行了那个命令,输出如下:Running via Spring preloader in process 11867 development

标签: ruby-on-rails rspec rspec-rails cloud9-ide aws-cloud9


【解决方案1】:

在将 gem 添加到 Gemfile 后,您需要使用 bundle install 安装 gem。所以只需运行bundle install 然后重新运行rails g rspec:install

您可以通过运行 bundle info rspec-rails

来检查您的项目中是否安装了 gem

如果这不起作用,您可能需要通过设置 RAILS_ENV=development 或 (test) 将环境设置为 development,但是

【讨论】:

  • 对不起,我忘了说我已经完成了捆绑安装。还是一样的错误。
  • @KatieEdmonds 你试过运行bin/rails g rspec:installbundle exec rails g rspec:install 甚至bundle exec bin/rails g rspec:install吗?
  • @KatieEdmonds 也请您尝试运行 bundle info rspec-rails 并告诉我它输出什么?
  • 我在你的第一条评论和同样的错误中运行了所有内容。然后我运行bundle info rspec-rails 并得到以下输出:The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Could not find gem 'rspec-rails'.
  • 您可能缺少您的环境中设置的 RAILS_ENV,我更新了答案,祝您好运
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多