ruby-on-rails - 由于 bundle 程序错误 : "An error occurred while installing json...",,Capistrano 无法部署,但我可以手动安装

标签 ruby-on-rails ubuntu capistrano bundler

我是 Rails 和 capistrano 新手,今天一整天我都在努力让所有这些东西正常工作。

现在我有一个问题,我根本不知道如何解决。

症状:

cap staging deploy

... lots of stuff goes here and then...

INFO [ba405350] Running /usr/bin/env bundle install --path /home/ftpusers/my-server.com/rails/stage/shared/bundle --without development test --deployment --quiet as rreimche@my-server.com
DEBUG [ba405350] Command: cd /home/ftpusers/my-server.com/rails/stage/releases/20150414185146 && /usr/bin/env bundle install --path /home/ftpusers/my-server.com/rails/stage/shared/bundle --without development test --deployment --quiet
DEBUG [ba405350]    An error occurred while installing json (1.8.2), and Bundler cannot continue.
DEBUG [ba405350]    Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as rreimche@my-server.com: bundle exit status: 5
bundle stdout: An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
bundle stderr: Nothing written

SSHKit::Command::Failed: bundle exit status: 5
bundle stdout: An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
bundle stderr: Nothing written

Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as rreimche@my-server.com: bundle exit status: 5
bundle stdout: An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
bundle stderr: Nothing written

但是当我以 rreimche 身份登录并执行“gem install json -v 1.8.2”时——一切正常。然后我尝试将整个失败的命令作为 rreimche 运行,它运行得非常完美:(我已经从命令末尾删除了“--quite”,假设它只是使运行不冗长)
rreimche@la:/home/ftpusers/my-server.com/rails/stage/releases/20150414185146$ /usr/bin/env bundle install --path /home/ftpusers/my-server.com/rails/stage/shared/bundle --without development test --deployment
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.1.6
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.6
Using rack 1.5.2
Using rack-test 0.6.3
Using actionpack 4.1.6
Using mime-types 2.4.3
Using mail 2.6.3
Using actionmailer 4.1.6
Using activemodel 4.1.6
Using arel 5.0.1.20140414130214
Using activerecord 4.1.6
Using execjs 2.4.0
Using autoprefixer-rails 5.1.8
Using sass 3.2.19
Using bootstrap-sass 3.3.4 from https://github.com/twbs/bootstrap-sass.git (at next)
Using climate_control 0.0.3
Using cocaine 0.5.7
Using orm_adapter 0.5.0
Using ckeditor 4.1.1
Using coffee-script-source 1.9.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.6
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.11.0
Using jbuilder 2.2.12
Using jquery-rails 3.1.2
Using paperclip 4.2.1
Using bundler 1.9.4
Using tilt 1.4.1
Using sprockets 2.12.3
Using sprockets-rails 2.2.4
Using rails 4.1.6
Using rdoc 4.2.0
Using sass-rails 4.0.5
Using sdoc 0.4.1
Using sqlite3 1.3.10
Using turbolinks 2.5.3
Using uglifier 2.7.1
Bundle complete! 14 Gemfile dependencies, 48 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into /home/ftpusers/my-server.com/rails/stage/shared/bundle.

我在服务器上运行 Ubuntu 12.04,这里有更多信息:
rreimche@la:/home/ftpusers/my-server.com/rails/stage/releases/20150414185146$ ruby -v
ruby 2.1.3p242 (2014-09-19 revision 47630) [i686-linux]
rreimche@la:/home/ftpusers/my-server.com/rails/stage/releases/20150414185146$ bundle -v
Bundler version 1.9.4

帽文件:
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

gem 文件:
source 'https://rubygems.org'

gem 'rails', '4.1.6'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'spring',        group: :development
gem 'ckeditor'
gem 'paperclip'
gem 'bootstrap-sass', :git => 'https://github.com/twbs/bootstrap-sass.git', :branch => 'next'
gem 'autoprefixer-rails'
group :development do
  gem 'capistrano-rails', '~> 1.1.1'
end

部署.rb
lock '3.4.0'

set :application, 'kariera-centr.ru'
set :repo_url, 'https://github.com/mygit/myrepo.git' 

namespace :deploy do

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
    end
  end

end

分期.rb
server 'my-server.com', user: 'rreimche', roles: %w{web}
set :deploy_to, '/home/ftpusers/my-server.com/rails/stage'

set :linked_files, fetch(:linked_files, []).push('config.yml')

set :linked_dirs, fetch(:linked_dirs, []).push('uploads')

set :ssh_options, {
    keys: %w(/home/rreimche/.ssh/id_rsa),
    forward_agent: false,
    auth_methods: %w(publickey)
}

我的本地系统是 Mac OS X 10.8。

如果有任何帮助,我将不胜感激。谢谢你。

最佳答案

尝试运行以下命令:
$ sudo apt-get install libgmp3-dev
然后安装json$ gem install json
引用:https://www.digitalocean.com/community/questions/how-do-i-fix-this-error-when-deploying-rails-with-capistrano-using-nginx-and-puma

关于ruby-on-rails - 由于 bundle 程序错误 : "An error occurred while installing json...",,Capistrano 无法部署,但我可以手动安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29635735/

相关文章:

mysql - 获取mysql命令的返回码

ruby-on-rails - 来自 cloudfront 的动态内容 - 我可以放置来自 Rails 的 API 结果 (JSON) 吗?

ruby-on-rails - Rails 6 Action 邮箱和 Gmail 集成方法

mysql - RoR数据库错误

eclipse - 是否有任何 Ubuntu 10.04 存储库可以下载最新版本的 Eclipse?

linux - 在 Linux 中运行 datastax intsallation runner 时出错

ruby-on-rails - 如何在 Ruby 中通过元编程访问顶级命名空间?

ruby-on-rails-3 - 由于缺少 development.log 文件,Capistrano 首次部署不起作用

nginx -/usr/bin/env : ruby_executable_hooks : No such file or directory

ruby-on-rails - Windows 上的 Capistrano : 'cap deploy' defaults to wrong username