Roman Reimche
Roman Reimche

Reputation: 143

Capistrano fails to deploy due to a bundler error: "An error occurred while installing json...", but I am able to install that manually

I am rails and capistrano novice and the whole day today I've ruined trying to make all this stuff work.

For now I have a problem that I simply don't have any idea how to solve.

Syptom:

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 [email protected]
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 [email protected]: 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 [email protected]: 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

But when I login as rreimche and do 'gem install json -v 1.8.2' – everything is OK. Then I've tried to run the whole failing command as rreimche and it runs just perfect: (I've removed "--quite" from the end of the command, supposing that it just makes the run non-verbose)

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.

I am running Ubuntu 12.04 on the server and here's some more info:

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

Capfile:

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

Gemfile:

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

deploy.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

staging.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)
}

My local system is Mac OS X 10.8.

I would be very grateful for any help. Thank you.

Upvotes: 2

Views: 1018

Answers (1)

Abhinay
Abhinay

Reputation: 1816

Try running below commands:

$ sudo apt-get install libgmp3-dev

and then install json

$ gem install json

Reference: https://www.digitalocean.com/community/questions/how-do-i-fix-this-error-when-deploying-rails-with-capistrano-using-nginx-and-puma

Upvotes: 1

Related Questions