我使用Capistrano来部署我的应用程序。 Ruby是由我的Mac上的RVM安装的,在服务器上是由rbenv安装的相同的Ruby版本(2.2.5)。
在我想限制生产部署后,会出现以下错误:
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 user@52.28.250.42
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)
这是deploy.rb:
lock '3.5.0'
set :application, "app_#{fetch(:stage)}"
set :repo_url, 'git@bitbucket.org:...'
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
我的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]
服务器是Amazon EC2,带有Ubuntu,Ruby 2.2.5(由rbenv安装)。
这是gem active_support的错误,还是我做错了什么?
答案 0 :(得分:3)
我不认为你做错了什么。我的猜测是你在Bundler中遇到了一个错误,或者存在文件权限问题阻止了ActiveSupport gem的加载。
检查以下内容:
确认/home/ubuntu/jozu_production/shared/bundle/ruby/2.2.0/gems
中确实安装了ActiveSupport。您应该会看到由activesupport-4.1.14
用户拥有的名为ubuntu
的目录。确保目录及其内容全部归ubuntu
所有并且可读。
确保在rbenv管理的Ruby 2.2.5环境中安装了最新版本的Bundler。在撰写本文时,那就是Bundler 1.12.5。 (运行gem install bundler
。)
尝试在服务器上手动运行预编译命令,以查看行为是否存在任何差异。将--trace
添加到命令以获取其他故障排除数据。
cd /home/ubuntu/jozu_production/releases/20160606043027 && ( export RAILS_ENV="production" ; bundle exec rake assets:precompile --trace )