Question: Why am I getting this error when I try to install RSpec?


Why am I getting this error when I try to install RSpec?

Answers 2
Added at 2017-01-05 06:01

I have used RSpec before and this is the first time I get this error when I try to run:

rails generate rspec:install

It results in this error:

/Users/ldco2016/Projects/workout_app/config/application.rb:11:in `require': cannot load such file -- action_cable/engine (LoadError)
    from /Users/ldco2016/Projects/workout_app/config/application.rb:11:in `<top (required)>'
    from /Users/ldco2016/.rvm/gems/ruby-2.2.5/gems/spring-2.0.0/lib/spring/application.rb:82:in `require'
    from /Users/ldco2016/.rvm/gems/ruby-2.2.5/gems/spring-2.0.0/lib/spring/application.rb:82:in `preload'
    from /Users/ldco2016/.rvm/gems/ruby-2.2.5/gems/spring-2.0.0/lib/spring/application.rb:143:in `serve'
    from /Users/ldco2016/.rvm/gems/ruby-2.2.5/gems/spring-2.0.0/lib/spring/application.rb:131:in `block in run'
    from /Users/ldco2016/.rvm/gems/ruby-2.2.5/gems/spring-2.0.0/lib/spring/application.rb:125:in `loop'
    from /Users/ldco2016/.rvm/gems/ruby-2.2.5/gems/spring-2.0.0/lib/spring/application.rb:125:in `run'
    from /Users/ldco2016/.rvm/gems/ruby-2.2.5/gems/spring-2.0.0/lib/spring/application/boot.rb:19:in `<top (required)>'
    from /Users/ldco2016/.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/ldco2016/.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'

This is my gemfile:

source ''

git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "{repo_name}.git" end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more:
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more:
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

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

group :development, :test do
  gem 'rspec-rails', '3.2.3'
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more:
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'

group :test do
  gem 'capybara', '2.4.4'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

This is my config/application.rb:

require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "action_cable/engine"
require "sprockets/railtie"
# require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.

module WorkoutApp
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
Answers to

Why am I getting this error when I try to install RSpec?

nr: #1 dodano: 2017-01-05 06:01

This issue is not related to RSpec. You're trying to load action_cable in a Rails 4 application (according to your Gemfile), and that's a built in feature for Rails 5. Just remove this line from your application.rb.

require "action_cable/engine"

If you don't really need to load Rails modules independently, just replace all the requires by:

require 'rails/all'
nr: #2 dodano: 2017-01-05 06:01

In app/application.rb, comment "require "action_cable/engine"

Source Show
◀ Wstecz