Bundle: Permission Denied

I upgraded my server to ruby โ€‹โ€‹2.1.1 and I use Capistrano to deploy on my server. However, during deployment, I get various errors. Every time I play with my deployment code. Below is the current problem.

UPDATE / NEW ISSUE

After reinstalling rvm and ruby, I now face various deployment problems. Here is my deploy.rb file currently.

require "bundler/capistrano" require "rvm/capistrano" set :rvm_type, :system set :rvm_ruby_string, "ruby-2.1.1" require 'bundler/capistrano' # Capistrano set :default_environment, { 'PATH' => '/root/.rvm/gems/ruby-2.1.1/bin:/root/.rvm/gems/ ruby-2.1.1@global /bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games', 'GEM_HOME' => "/root/.rvm/gems/ruby-2.1.1", 'GEM_PATH' => "/root/.rvm/gems/ruby-2.1.1:/root/.rvm/gems/ ruby-2.1.1@global ", "MY_RUBY_HOME" => "/usr/local/rvm/rubies/ruby-2.1.1", "BUNDLE_PATH" => "/usr/local/rvm/rubies/ruby-2.1.1/bin/bundle" } set :rails_env, "production" set :branch, "master" set :app_server, "ip" set :db_server, "ip" server app_server, :app, :web role :db, db_server, :primary => true set :keep_releases, 1 set :deploy_to, "/var/www" set :user, :jason set :password, "cool password here" set :repository, "git url" # Your clone URL set :scm, "git" set :scm_username, "jason" set :scm_passphrase, "password" set :use_sudo, false default_run_options[:pty] = true set :ssh_options, {:forward_agent => true} after 'deploy:restart', 'deploy:cleanup' after 'deploy:update', 'deploy:create_symlink' 

When starting the deployment, I encounter this error:

 Error: RVM was unable to use 'default' 

I assume this applies to rvm_ruby_string , which I did not install. Other than that, I have no idea why the error occurs. Perhaps RVM cannot recognize ruby โ€‹โ€‹on the server?

OLD ISSUE

I upgraded my server to ruby โ€‹โ€‹2.1.1. SSHing on the server I run gem env to determine the relative default environment characteristics.

 set :default_environment, { 'PATH' => '/root/.rvm/gems/ruby-2.1.1/bin:/root/.rvm/gems/ ruby-2.1.1@global /bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games', 'GEM_HOME' => "/root/.rvm/gems/ruby-2.1.1", 'RUBY_VERSION' => 'ruby 2.1.1', 'GEM_PATH' => "/root/.rvm/gems/ruby-2.1.1:/root/.rvm/gems/ ruby-2.1.1@global " } 

However, when I run cap deploy , I get the following:

  * executing "cd /var/www/releases/20140517014048 && bundle install --gemfile /var/www/releases/20140517014048/Gemfile --path /var/www/shared/bundle --deployment --quiet --without development test" servers: ["ip address"] ["ip address"] executing command ** [out :: ipaddress] sh: 1: bundle: Permission denied 

I assume it is my default environment. Since this is the only thing that I changed in my deploy.rb file. `

+6
source share
2 answers
  • You want to use default_env to define SHELL vars
  • Permission Denied means your SSH user is not allowed to use SSH, RVM or Bundler

Capistrano

The first step is to ensure that default_environment works properly. Although I cannot find a direct link (search for default_env on this page) , I read that default_environment been replaced with default_env

If you are using capistrano 3.0+ , you should use default_env as follows:

 set :default_env, { 'PATH' => '/root/.rvm/gems/ruby-2.1.1/bin:/root/.rvm/gems/ ruby-2.1.1@global /bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games', 'GEM_HOME' => "/root/.rvm/gems/ruby-2.1.1", 'RUBY_VERSION' => 'ruby 2.1.1', 'GEM_PATH' => "/root/.rvm/gems/ruby-2.1.1:/root/.rvm/gems/ ruby-2.1.1@global " } 

Resolution

Secondly, your ssh user will not have the correct permissions to access the Ruby / bundler installation

As you said in the comments, this may be due to the fact that Ruby or rvm not installed on your system or you do not have access to it.

@chloe has an amazing recommendation - to work with this I have to log in using the root (to check) to make sure you can really get the bundler or rvm

+5
source

Uninstall Bundler, RVM, Ruby and reinstall them. It worked for me.

+1
source

Source: https://habr.com/ru/post/969413/


All Articles