捆绑安装不能在capistrano中工作

时间:2021-09-17 12:27:59

I want to deploy my simple rails 4.0 application via capistrano 3.0.

我想通过capistrano 3.0部署我的简单rails 4.0应用程序。

I use bundler 1.3.5 so I add capistrano-bundler gem to integrate bundler with capistrano.

我使用bundler 1。3.5所以我添加了capitrano -bundler gem来集成bundler和capistrano。

I have pretty simple configuration (almost default):

我有相当简单的配置(几乎是默认的):

set :bundle_gemfile, -> { release_path.join('Gemfile') }
set :bundle_dir, -> { shared_path.join('bundle') }
set :bundle_flags, ''
set :bundle_without, %w{test development}.join(' ')
set :bundle_binstubs, -> { shared_path.join('bin') }
set :bundle_roles, :all

When I run the cap staging deploy --trace it fails:

当我运行cap staging部署时——跟踪它失败:

[50b524bc] Running /usr/bin/env bundle --gemfile /home/webmaster/www/api/releases/20131014144650/Gemfile --path /home/webmaster/www/api/shared/bundle  --binstubs /home/webmaster/www/api/shared/bin --without test development on 125.51.3.1
DEBUG [50b144bc] Command: cd /home/webmaster/www/api/releases/20131014144650 && /usr/bin/env bundle --gemfile /home/webmaster/www/api/releases/20131014144650/Gemfile --path /home/webmaster/www/api/shared/bundle  --binstubs /home/webmaster/www/api/shared/bin --without test development
cap aborted!
bundle stdout: Nothing written
bundle stderr: Nothing written
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/command.rb:94:in `exit_status='
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-bundler-1.0.0/lib/capistrano/tasks/bundler.cap:20:in `block (4 levels) in <top (required)>'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/abstract.rb:81:in `within'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-bundler-1.0.0/lib/capistrano/tasks/bundler.cap:19:in `block (3 levels) in <top (required)>'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run'
/home/omnomnom/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:updated => bundler:install

But if I copy this command and run though ssh all works fine (all gems installed successfully) How I can fix/debug it?

但是如果我复制这个命令并在ssh上运行一切正常(所有gems都安装成功),我如何修复/调试它?

8 个解决方案

#1


50  

Just ran into the same issue. What worked for me was this:

刚刚遇到了同样的问题。对我起作用的是:

1) Installing the capistrano-rvm gem and adding

1)安装capistrand -rvm gem并添加

require 'capistrano/rvm'

to the Capfile.

Capfile。

2) Adding my deployment user to the rvm group on the server:

2)将我的部署用户添加到服务器上的rvm组:

# usermod deploy -a -G rvm

3) Creating two directories in my deployment user's home folder: .rvm and .rvm/bin

3)在部署用户的主文件夹中创建两个目录:.rvm和.rvm/bin

4) Adding this line to my deploy.rb file:

4)在我的部署中添加这一行。rb文件:

set :default_env, { rvm_bin_path: '~/.rvm/bin' }

Phew! That took a few hours.

唷!花了几个小时。

#2


12  

The error sounds like it can't find bundle in your PATH. It's possible that when you SSH in manually, it's running something in your ~/.profile or ~/.bash_profile that adds it to your path.

这个错误听起来好像在你的路径中找不到bundle。当您手动SSH登录时,它可能正在您的~/中运行一些东西。配置文件或~ /。将其添加到路径的bash_profile。

Find the path to bundle by logging in and running which bundle. Then, try to find how that path is added to your PATH environment variable. If there's something in your ~/.bash_profile, try moving it to~/.bashrc` instead.

通过登录并运行哪个bundle找到要绑定的路径。然后,尝试找到如何将该路径添加到路径环境变量中。如果你的~里面有什么东西。bash_profile,尝试将其移动到~/。bashrc”(代替。

You can also try Command Mapping to specify an exact path.

您还可以尝试命令映射来指定确切的路径。

There are some more troubleshooting tips at http://www.capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/

在http://www.capiorb.com/documentation/faq/why -do - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#3


3  

Simple solution and working on all Capistrano 3 versions:

简单的解决方案和所有Capistrano 3版本的工作:

gem 'rvm1-capistrano3', require: false

In Capfile add

在Capfile添加

require 'rvm1/capistrano3'

https://github.com/rvm/rvm1-capistrano3

https://github.com/rvm/rvm1-capistrano3

#4


2  

In my case, I changed config/deploy.rb's set :log_level, :info to set :log_level, :debug, which showed me "Can not find GEMFILE." This suggested that bundle was running with the wrong working directory, so I changed

在我的例子中,我更改了配置/部署。rb的set:log_level,:info to set:log_level,:debug,显示“找不到GEMFILE”。这表明bundle运行在错误的工作目录下,因此我进行了更改

before "deploy:assets:precompile", "deploy:bundle_install"
desc "Bundle install for RVMs sake"
task :bundle_install do
  on roles(:app) do
    execute "/u0/jrepenni/.rvm/bin/rvm 2.1.0@akiary do /u0/jrepenni/.rvm/gems/ruby-2.1.0@global/bin/bundle install"
  end
end

to

before "deploy:assets:precompile", "deploy:bundle_install"
desc "Bundle install for RVMs sake"
task :bundle_install do
  on roles(:app) do
    execute "cd #{release_path} && /u0/jrepenni/.rvm/bin/rvm 2.1.0@akiary do /u0/jrepenni/.rvm/gems/ruby-2.1.0@global/bin/bundle install"
  end
end

(note the added "cd")

(注意添加的“cd”)

#5


1  

I had:

我有:

set :bundle_flags, '--system --quiet'

Changed to:

更改为:

set :bundle_flags, '--deployment --quiet'

This resolved a problem.

这解决了问题。

#6


0  

This works in capistrano 3:

这在capistrano 3中是有效的:

  task :bundle_list do
    on roles(:app) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          execute :bundle, "list"
        end
      end
    end
  end

Use this for rake task :

用于rake任务:

execute :rake, 'some_rake_task'

#7


0  

in your config/deploy/production.rb file put

在你的配置/部署/生产。rb文件放

set :rvm_ruby_version, '2.0.0-p247'  

see https://github.com/capistrano/rvm

参见https://github.com/capistrano/rvm

#8


-1  

To debug it try to remove the --quiet flag:

要调试它,请尝试删除—安静标志:

set :bundle_flags, '--deployment'

设置:bundle_flags,”——部署“

Are you using rbenv, rvm or something similar? It might be possible that when bundle is running the Ruby version is not set yet. By removing the --quite flag you might get some debugging information.

你是用rbenv, rvm还是类似的东西?当bundle运行时,可能还没有设置Ruby版本。通过删除-quite标志,您可能会获得一些调试信息。

#1


50  

Just ran into the same issue. What worked for me was this:

刚刚遇到了同样的问题。对我起作用的是:

1) Installing the capistrano-rvm gem and adding

1)安装capistrand -rvm gem并添加

require 'capistrano/rvm'

to the Capfile.

Capfile。

2) Adding my deployment user to the rvm group on the server:

2)将我的部署用户添加到服务器上的rvm组:

# usermod deploy -a -G rvm

3) Creating two directories in my deployment user's home folder: .rvm and .rvm/bin

3)在部署用户的主文件夹中创建两个目录:.rvm和.rvm/bin

4) Adding this line to my deploy.rb file:

4)在我的部署中添加这一行。rb文件:

set :default_env, { rvm_bin_path: '~/.rvm/bin' }

Phew! That took a few hours.

唷!花了几个小时。

#2


12  

The error sounds like it can't find bundle in your PATH. It's possible that when you SSH in manually, it's running something in your ~/.profile or ~/.bash_profile that adds it to your path.

这个错误听起来好像在你的路径中找不到bundle。当您手动SSH登录时,它可能正在您的~/中运行一些东西。配置文件或~ /。将其添加到路径的bash_profile。

Find the path to bundle by logging in and running which bundle. Then, try to find how that path is added to your PATH environment variable. If there's something in your ~/.bash_profile, try moving it to~/.bashrc` instead.

通过登录并运行哪个bundle找到要绑定的路径。然后,尝试找到如何将该路径添加到路径环境变量中。如果你的~里面有什么东西。bash_profile,尝试将其移动到~/。bashrc”(代替。

You can also try Command Mapping to specify an exact path.

您还可以尝试命令映射来指定确切的路径。

There are some more troubleshooting tips at http://www.capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/

在http://www.capiorb.com/documentation/faq/why -do - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#3


3  

Simple solution and working on all Capistrano 3 versions:

简单的解决方案和所有Capistrano 3版本的工作:

gem 'rvm1-capistrano3', require: false

In Capfile add

在Capfile添加

require 'rvm1/capistrano3'

https://github.com/rvm/rvm1-capistrano3

https://github.com/rvm/rvm1-capistrano3

#4


2  

In my case, I changed config/deploy.rb's set :log_level, :info to set :log_level, :debug, which showed me "Can not find GEMFILE." This suggested that bundle was running with the wrong working directory, so I changed

在我的例子中,我更改了配置/部署。rb的set:log_level,:info to set:log_level,:debug,显示“找不到GEMFILE”。这表明bundle运行在错误的工作目录下,因此我进行了更改

before "deploy:assets:precompile", "deploy:bundle_install"
desc "Bundle install for RVMs sake"
task :bundle_install do
  on roles(:app) do
    execute "/u0/jrepenni/.rvm/bin/rvm 2.1.0@akiary do /u0/jrepenni/.rvm/gems/ruby-2.1.0@global/bin/bundle install"
  end
end

to

before "deploy:assets:precompile", "deploy:bundle_install"
desc "Bundle install for RVMs sake"
task :bundle_install do
  on roles(:app) do
    execute "cd #{release_path} && /u0/jrepenni/.rvm/bin/rvm 2.1.0@akiary do /u0/jrepenni/.rvm/gems/ruby-2.1.0@global/bin/bundle install"
  end
end

(note the added "cd")

(注意添加的“cd”)

#5


1  

I had:

我有:

set :bundle_flags, '--system --quiet'

Changed to:

更改为:

set :bundle_flags, '--deployment --quiet'

This resolved a problem.

这解决了问题。

#6


0  

This works in capistrano 3:

这在capistrano 3中是有效的:

  task :bundle_list do
    on roles(:app) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          execute :bundle, "list"
        end
      end
    end
  end

Use this for rake task :

用于rake任务:

execute :rake, 'some_rake_task'

#7


0  

in your config/deploy/production.rb file put

在你的配置/部署/生产。rb文件放

set :rvm_ruby_version, '2.0.0-p247'  

see https://github.com/capistrano/rvm

参见https://github.com/capistrano/rvm

#8


-1  

To debug it try to remove the --quiet flag:

要调试它,请尝试删除—安静标志:

set :bundle_flags, '--deployment'

设置:bundle_flags,”——部署“

Are you using rbenv, rvm or something similar? It might be possible that when bundle is running the Ruby version is not set yet. By removing the --quite flag you might get some debugging information.

你是用rbenv, rvm还是类似的东西?当bundle运行时,可能还没有设置Ruby版本。通过删除-quite标志,您可能会获得一些调试信息。