LoginSignup
1
0

More than 3 years have passed since last update.

RailsでRSpecを追加しようとした時に発生したエラー「Could not find diff-lcs-1.3 in any of the sources Run `bundle install` to install missing gems.」の対処法

Last updated at Posted at 2020-03-24
Gemfile
group :development, :test do
  gem 'rspec-rails'
end

GemfileにRSpecを追加して、以下のコマンドを実行したらエラーが発生した。

エラーメッセージ

$ bundle install
・・・
$ rails generate rspec:install
Could not find diff-lcs-1.3 in any of the sources
Run `bundle install` to install missing gems.

解決方法

$ ps axu | grep spring
maiamea              53324   0.1  0.1  4336604   9524   ??  Ss    4:41PM   0:00.92 spring app    | api-project | started 5 mins ago | development mode      
maiamea              36768   0.0  0.0  4366272    748 s002  S+   月04PM   0:00.58 spring server | api-project | started 24 hours ago   
maiamea              53389   0.0  0.0  4286728    716 s003  S+    4:46PM   0:00.00 grep spring
$ spring stop
Spring stopped.
$ rails generate rspec:install
Running via Spring preloader in process 53437
      create  .rspec
      create  spec
      create  spec/spec_helper.rb
      create  spec/rails_helper.rb

原因

rails server を高速で起動させるSpringが悪さをしていた。
Springが起動していたことによりGemfileの変更が反映されなかった。

Gemfileに変更を加えた場合は、まず rails server を止め、
次にSpringをstopさせる。
その後 rails server を起動させる必要があった。

Springとは?

Railsアプリケーションのプリローダーのgem (Rubyのライブラリ)
Railsアプリケーションをバックグラウンドで走らせたままにしておくことにより、2回目以降のコマンド実行時の待ち時間が減り開発効率が上がる。

プリローダー:preloader (pre + load = 前もってロードしておく)

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0