Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LoadError: cannot load such file -- active_support

I use Capistrano to deploy my app. Ruby is installed by RVM on my Mac, on the server is same Ruby version (2.2.5) installed by rbenv.

After I want to cap production deploy, the following error appears:

SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
LoadError: cannot load such file -- active_support
/home/user/app/shared/bundle/ruby/2.2.0/gems/railties-4.1.14/lib/rails.rb:5:in `require'
/home/user/app/shared/bundle/ruby/2.2.0/gems/railties-4.1.14/lib/rails.rb:5:in `<top (required)>'
/home/user/app/shared/bundle/ruby/2.2.0/gems/railties-4.1.14/lib/rails/all.rb:1:in `require'
/home/user/app/shared/bundle/ruby/2.2.0/gems/railties-4.1.14/lib/rails/all.rb:1:in `<top (required)>'
/home/user/app/releases/20160606092956/config/application.rb:3:in `require'
/home/user/app/releases/20160606092956/config/application.rb:3:in `<top (required)>'
/home/user/app/releases/20160606092956/Rakefile:4:in `require'
/home/user/app/releases/20160606092956/Rakefile:4:in `<top (required)>'
/home/user/.rbenv/versions/2.2.5/bin/bundle:23:in `load'
/home/user/.rbenv/versions/2.2.5/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)

 DEBUG [0ac2a446]   Bundled gems are installed into /home/user/app/shared/bundle.
  INFO [0ac2a446] Finished in 0.509 seconds with exit status 0 (successful).
 DEBUG [d7061392] Running if test ! -d /home/user/app/releases/20160606043027; then echo "Directory does not exist '/home/user/app/releases/2016060604…
 DEBUG [d7061392] Command: if test ! -d /home/user/app/releases/20160606043027; then echo "Directory does not exist '/home/user/app/releases/201606060…
 DEBUG [d7061392] Finished in 0.036 seconds with exit status 0 (successful).
  INFO [b8dc48fb] Running bundle exec rake assets:precompile as [email protected]
 DEBUG [b8dc48fb] Command: cd /home/user/app/releases/20160606043027 && ( export RAILS_ENV="production" ; bundle exec rake assets:precompile )
 DEBUG [b8dc48fb]   rake aborted!
 DEBUG [b8dc48fb]   LoadError: cannot load such file -- active_support
 DEBUG [b8dc48fb]   /home/user/app/shared/bundle/ruby/2.2.0/gems/railties-4.1.14/lib/rails.rb:5:in `require'
/home/user/app/shared/bundle/ruby/2.2.0/gems/railties-4.1.14/lib/rails.rb:5:in `<top (required)>'
/home/user/app/shared/bundle/ruby/2.2.0/gems/railties-4.1.14/lib/rails/all.rb:1:in `require'
/home/user/app/shared/bundle/ruby/2.2.0/gems/railties-4.1.14/lib/rails/all.rb:1:in `<top (required)>'
/home/user/app/releases/20160606043027/config/application.rb:3:in `require'
/home/user/app/releases/20160606043027/config/application.rb:3:in `<top (required)>'
/home/user/app/releases/20160606043027/Rakefile:4:in `require'
/home/user/app/releases/20160606043027/Rakefile:4:in `<top (required)>'
/home/user/.rbenv/versions/2.2.5/bin/bundle:23:in `load'
/home/user/.rbenv/versions/2.2.5/bin/bundle:23:in `<main>'
 DEBUG [b8dc48fb]   (See full trace by running task with --trace)

This is deploy.rb:

lock '3.5.0'

set :application, "app_#{fetch(:stage)}"

set :repo_url, '[email protected]:...'

set :user, 'user'

server "ip_adress", user: fetch(:user), roles: %w(app db web)

set :deploy_to, "/home/#{fetch(:user)}/#{fetch(:application)}"

# Default value for :pty is false
# set :pty, true

set :linked_files, fetch(:linked_files, []).push("config/database.yml")
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

set :bundle_flags, '--deployment'
set :bundle_jobs, 4

set :keep_assets, 2

set :use_sudo, true

set :rbenv_type, :user
set :rbenv_ruby, "2.2.5"

set :rails_env, fetch(:stage)

set :passenger_restart_with_touch, true

namespace :deploy do
  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end

My Gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.14'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'mysql2', '~> 0.3.18'
# Use SCSS for stylesheets
# gem 'sass-rails', '~> 4.0.3'
gem 'sass'
gem 'sass-rails', '~> 5.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/rails/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

gem 'jquery-rails'

gem 'turbolinks'
gem "therubyracer"
gem "less-rails"

# UI
gem 'nprogress-rails'
gem "twitter-bootstrap-rails"
gem "simple-navigation"
gem 'autosize-rails'
gem "emoticons_helper"

### Autentication
gem "devise"
gem 'cancancan', '~> 1.10'

gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem "omniauth-linkedin"

# utils
gem  "quiet_assets"
gem 'social-share-button'

gem 'dragonfly', '~> 1.0.12'

gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring

# gem "thin"

gem 'jquery-ui-rails'
gem 'jquery-modal-rails'

gem "capistrano", "~> 3.5.0"

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'capistrano-rbenv', require: false
  gem 'capistrano-bundler', require: false
  gem 'capistrano-rails', require: false
  gem 'capistrano-passenger', require: false
  gem 'byebug'
end

gem "activesupport", "~> 4.1.14"


# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

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

# Use debugger
# gem 'debugger', group: [:development, :test]

The server is Amazon EC2 with Ubuntu, Ruby 2.2.5 (installed by rbenv).

Is this the error with gem active_support, or am I doing anything wrong?

like image 382
Boomerange Avatar asked Jun 06 '16 08:06

Boomerange


1 Answers

I don't think you are doing anything wrong. My guess is that you've encountered a bug in Bundler, or there is a file permissions issue that is preventing the ActiveSupport gem from being loaded.

Check these things:

  1. Verify that ActiveSupport is indeed installed in /home/ubuntu/jozu_production/shared/bundle/ruby/2.2.0/gems. You should see a directory named activesupport-4.1.14, owned by your ubuntu user. Make sure the directory and its contents are all owned by ubuntu and are readable.

  2. Make sure you have the latest version of Bundler installed in your rbenv-managed Ruby 2.2.5 environment. As of this writing, that is Bundler 1.12.5. (Run gem install bundler.)

  3. Try manually running the precompile command on the server to see if there is any difference in behavior. Add --trace to the command to get additional troubleshooting data.

    cd /home/ubuntu/jozu_production/releases/20160606043027 && ( export RAILS_ENV="production" ; bundle exec rake assets:precompile --trace )
    
like image 80
Matt Brictson Avatar answered Oct 19 '22 16:10

Matt Brictson