Rails 5 - 找不到生成器“rspec:install" [英] Rails 5 - Could not find generator 'rspec:install'

查看:46
本文介绍了Rails 5 - 找不到生成器“rspec:install"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 rails 5.0.0 应用程序中,我在 Gemfile 中添加了以下内容:

In my rails 5.0.0 application I've added the following to my Gemfile:

group :development, :test do
  gem 'byebug', platform: :mri
  gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
end

我运行了bundle install.然后gem就安装成功了.

I ran bundle install. Then gem was successfully installed.

然后我跑了:

rails generate rspec:install

但我收到一条错误消息:

But I got an error saying:

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

在这个错误上发布了一大堆其他问题(找不到生成器'rspec:install'),但他们都没有为我工作,看起来我遇到了不同的问题.

There are whole bunch of other question posted on this error (Could not find generator 'rspec:install'), but none of them worked for me and it looks like I am having a different issue.

如果需要,这是我的 bundle show 输出:

Incase its needed, here's my bundle show output:

Gems included by the bundle:
  * actioncable (5.0.0.1)
  * actionmailer (5.0.0.1)
  * actionpack (5.0.0.1)
  * actionview (5.0.0.1)
  * activejob (5.0.0.1)
  * activemodel (5.0.0.1)
  * activerecord (5.0.0.1)
  * activesupport (5.0.0.1)
  * arel (7.1.2)
  * builder (3.2.2)
  * bundler (1.12.5)
  * byebug (9.0.5)
  * coffee-rails (4.2.1)
  * coffee-script (2.4.1)
  * coffee-script-source (1.10.0)
  * concurrent-ruby (1.0.2)
  * debug_inspector (0.0.2)
  * diff-lcs (1.2.5)
  * erubis (2.7.0)
  * execjs (2.7.0)
  * ffi (1.9.14)
  * globalid (0.3.7)
  * i18n (0.7.0)
  * jbuilder (2.6.0)
  * jquery-rails (4.2.1)
  * listen (3.0.8)
  * loofah (2.0.3)
  * mail (2.6.4)
  * method_source (0.8.2)
  * mime-types (3.1)
  * mime-types-data (3.2016.0521)
  * mini_portile2 (2.1.0)
  * minitest (5.9.0)
  * multi_json (1.12.1)
  * nio4r (1.2.1)
  * nokogiri (1.6.8)
  * pkg-config (1.1.7)
  * puma (3.6.0)
  * rack (2.0.1)
  * rack-test (0.6.3)
  * rails (5.0.0.1)
  * rails-dom-testing (2.0.1)
  * rails-html-sanitizer (1.0.3)
  * railties (5.0.0.1)
  * rake (11.2.2)
  * rb-fsevent (0.9.7)
  * rb-inotify (0.9.7)
  * rspec-core (3.5.3)
  * rspec-expectations (3.5.0)
  * rspec-mocks (3.5.0)
  * rspec-rails (3.5.2)
  * rspec-support (3.5.0)
  * sass (3.4.22)
  * sass-rails (5.0.6)
  * spring (1.7.2)
  * spring-watcher-listen (2.0.0)
  * sprockets (3.7.0)
  * sprockets-rails (3.2.0)
  * sqlite3 (1.3.11)
  * thor (0.19.1)
  * thread_safe (0.3.5)
  * tilt (2.0.5)
  * turbolinks (5.0.1)
  * turbolinks-source (5.0.0)
  * tzinfo (1.2.2)
  * uglifier (3.0.2)
  * web-console (3.3.1)
  * websocket-driver (0.6.4)
  * websocket-extensions (0.1.2)

推荐答案

在我的例子中,spring gem 有问题.重启spring解决了问题.

Turns out its an issue with spring gem in my case. Restarting spring solved the problem.

首先运行bin/spring status.如果 spring 正在运行,您会得到类似的结果:

First run bin/spring status. If spring is running you will get something similar:

Spring is running:

    8774 spring server | chessboard | started 14 mins ago   
    8808 spring app    | chessboard 6.52.08 PM | started 12 mins ago | development mode

这意味着你必须通过跑步来阻止 spring:

That means you have to stop spring by running:

bin/spring stop

然后重新开始:

bin/spring server

然后运行 ​​rails generate rspec:install 就可以了.

Then run rails generate rspec:install and it should work.

您可能需要运行bundle update.

这篇关于Rails 5 - 找不到生成器“rspec:install"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆