Capistrano v3 could not find a Bundler
10,306
It seems that you had to add capistrano-rvm
. It will take care about your ruby and bundler paths.
bundle install doesn't work from capistrano
Related videos on Youtube
Author by
ekondr
Updated on April 11, 2020Comments
-
ekondr about 4 years
I have a problem in deploying my App with Capistrano v3. When I run '$ cap production deploy' I see an error...
INFO [825ad68d] Running /usr/bin/env bundle --gemfile /home/username/www/myapp/releases/20131026181031/Gemfile --path /home/username/www/myapp/shared/bundle --deployment --quiet --binstubs /home/username/www/myapp/shared/bin --without development test on myhostname.com DEBUG [825ad68d] Command: cd /home/username/www/myapp/releases/20131026181031 && ( RAILS_ENV=production /usr/bin/env bundle --gemfile /home/username/www/myapp/releases/20131026181031/Gemfile --path /home/username/www/myapp/shared/bundle --deployment --quiet --binstubs /home/username/www/myapp/shared/bin --without development test ) DEBUG [825ad68d] /usr/bin/env: DEBUG [825ad68d] bundle DEBUG [825ad68d] : No such file or directory
But when I run the last command...
cd /home/username/www/myapp/releases/20131026181031 && ( RAILS_ENV=production /usr/bin/env bundle --gemfile /home/username/www/myapp/releases/20131026181031/Gemfile --path /home/username/www/myapp/shared/bundle --deployment --quiet --binstubs /home/username/www/myapp/shared/bin --without development test )
... via ssh on my server I don't see any errors.
Here is my server's environment:
- Ubuntu 13.04
- rvm 1.23.5
- rubygems 1.8.25
- Bundler 1.3.5
- ruby 1.9.3p448
- capistrano (3.0.0)
- capistrano-bundler (1.0.0)
- capistrano-rails (1.0.0)
Here is a piece of my Gemfile which includes capistrano's gems
... group :development do ... # Deploy with Capistrano gem 'capistrano', '~> 3.0.0' gem 'capistrano-rails' gem 'capistrano-bundler' end ...
Please see below capistrano's configuration:
Capfile
require 'capistrano/setup' require 'capistrano/deploy' require 'capistrano/bundler' require 'capistrano/rails/assets' require 'capistrano/rails/migrations' Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
config/deploy.rb
set :application, 'myapp' set :repo_url, "/home/username/repository/#{fetch(:application)}.git" set :deploy_to, "/home/usename/www/#{fetch(:application)}" set :scm, :git set :branch, "master" set :format, :pretty set :use_sudo, false set :linked_files, %w{config/database.yml} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} set :keep_releases, 5 SSHKit.config.command_map[:rake] = "bundle exec rake" SSHKit.config.command_map[:rails] = "bundle exec rails" namespace :deploy do desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do # Your restart mechanism here, for example: # execute :touch, release_path.join('tmp/restart.txt') end end 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 after :finishing, 'deploy:cleanup' end
config/deploy/production.rb
set :stage, :production set :bundle_gemfile, -> { release_path.join('Gemfile') } set :bundle_dir, -> { shared_path.join('bundle') } set :bundle_flags, '--deployment --quiet' set :bundle_without, %w{development test}.join(' ') set :bundle_binstubs, -> { shared_path.join('bin') } set :bundle_roles, :all role :app, %w{myhostname.com} role :web, %w{myhostname.com} role :db, %w{myhostname.com} server 'myhostname.com', user: 'username', roles: %w{web app}, my_property: :my_value fetch(:default_env).merge!(rails_env: :production)
Please help me.
SOLVED
I've solved my problem by following steps:
Add capistrano-rvm into Gemfile and do
... group :development do ... gem 'capistrano', '~> 3.0.0' gem 'capistrano-rails' gem 'capistrano-bundler' gem 'capistrano-rvm' end ...
Add this line into Capfile
require 'capistrano/rvm'
Add these lines into the deploy.rb file.
set :rvm_ruby_version, '1.9.3-p448' set :default_env, { rvm_bin_path: '~/.rvm/bin' } SSHKit.config.command_map[:rake] = "#{fetch(:default_env)[:rvm_bin_path]}/rvm ruby-#{fetch(:rvm_ruby_version)} do bundle exec rake"
-
Tim Moore over 10 yearspossible duplicate of bundle install doesn't work from capistrano
-
ekondr over 10 yearsI added capistrano-rvm and it solved the problem but another problem appeared. I think this one and previous one are similar (see below):
DEBUG [3686e995] Command: cd /home/username/www/myapp/releases/20131027130646 && ( RVM_BIN_PATH=~/.rvm/bin RAILS_ENV= ~/.rvm/bin/rvm ruby-1.9.3-p448 do rake assets:precompile ) DEBUG [3686e995] /home/username/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in block in materialize' DEBUG [3686e995] : DEBUG [3686e995] Could not find i18n-0.6.1 in any of the sources DEBUG [3686e995] ( DEBUG [3686e995] Bundler::GemNotFound
-
freemanoid over 10 years@ekondr As you can see, you haven't specified
RAILS_ENV
try to addset :rails_env, "production"
instead offetch(:default_env).merge!(rails_env: :production)
-
ekondr over 10 yearsI've added
set :rails_env, "production"
instead offetch(:default_env).merge!(rails_env: :production)
but nothing changed. -
ekondr over 10 yearsI've fixed my problem. I've added these lines into the deploy.rb file.
set :rvm_ruby_version, '1.9.3-p448'
set :default_env, { rvm_bin_path: '~/.rvm/bin' }
SSHKit.config.command_map[:rake] = "#{fetch(:default_env)[:rvm_bin_path]}/rvm ruby-#{fetch(:rvm_ruby_version)} do bundle exec rake"
-
freemanoid over 10 years@ekondr so all works as expected now? If migrations and assets compilation works well?
-
Altonymous over 10 yearsI don't see any instructions on that link for how to resolve. Good explanation of the problem though.