Capistrano 和 Bundler 问题 - 捆绑包:未找到

发布于 2024-12-03 06:35:19 字数 2317 浏览 0 评论 0原文

尝试使用捆绑/安装选项部署我的应用程序时,我不断收到以下错误:

    failed: "sh -c 'cd /home/deploy/swamp/releases/20110903003336 
    && bundle install --gemfile /home/deploy/swamp/releases/20110903003336/Gemfile 
    --path /home/deploy/swamp/shared/bundle --deployment --quiet 
    --without development test'" on 12.345.678.98

**更新 - 看起来我错过了一个错误:

[err :: 12.345.678.98] sh: bundle: not found

我已经在我的deploy.rb中尝试过这个:

require "bundler/capistrano"

并且我已经尝试过这个:

namespace :bundler do
  task :create_symlink, :roles => :app do
    shared_dir = File.join(shared_path, 'bundle')
    release_dir = File.join(current_release, '.bundle')
    run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
  end
  task :bundle_new_release, :roles => :app do
    bundler.create_symlink
    run "cd #{release_path} && bundle install --without test"
  end
end
after 'deploy:update_code', 'bundler:bundle_new_release'

我'我还将我的捆绑包移动到供应商路径:

bundle install --path vendor/bundle

我不认为这是权限问题,因为我可以使用部署手动登录,并直接在服务器上捆绑安装,没有问题。这是整个deploy.rb文件:

require "bundler/capistrano"


 set :application, "swamp"
 set :domain, "12.345.678.98"
 set :repository,  "[email protected]:***/**.git"
 set :deploy_to, "/home/deploy/#{application}"
 set :rails_env, 'production'
 set :branch, "master"

 role :app, domain
 role :web, domain
 role :db,  domain, :primary => true

 set :deploy_via, :remote_cache

 set :scm, :git
 set :user, "deploy"
 set :runner, "deploy"
 ssh_options[:port] = ****
 set :use_sudo, false

 after "deploy", "deploy:cleanup"

namespace :deploy do

    desc "Restarting mod_rails with restart.txt"
    task :restart, :roles => :app, :except => { :no_release => true } do
        run "touch #{current_path}/tmp/restart.txt"
    end

    [:start, :stop].each do |t|
        desc "#{t} task is a no-op with mod_rails"
        task t, :roles => :domain do ; end
    end
end

task :after_update_code do  
 run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
end

I keep getting the following error when trying to deploy my app with the bundle/install option:

    failed: "sh -c 'cd /home/deploy/swamp/releases/20110903003336 
    && bundle install --gemfile /home/deploy/swamp/releases/20110903003336/Gemfile 
    --path /home/deploy/swamp/shared/bundle --deployment --quiet 
    --without development test'" on 12.345.678.98

**Update - looks like I missed an error:

[err :: 12.345.678.98] sh: bundle: not found

I've tried this in my deploy.rb:

require "bundler/capistrano"

and I've tried this:

namespace :bundler do
  task :create_symlink, :roles => :app do
    shared_dir = File.join(shared_path, 'bundle')
    release_dir = File.join(current_release, '.bundle')
    run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
  end
  task :bundle_new_release, :roles => :app do
    bundler.create_symlink
    run "cd #{release_path} && bundle install --without test"
  end
end
after 'deploy:update_code', 'bundler:bundle_new_release'

I've also moved my bundle to the vendor path with this:

bundle install --path vendor/bundle

I don't think it's a permissions problem, because I can log in manually with deploy and bundle install directly on the server no problem. Here is the entire deploy.rb file:

require "bundler/capistrano"


 set :application, "swamp"
 set :domain, "12.345.678.98"
 set :repository,  "[email protected]:***/**.git"
 set :deploy_to, "/home/deploy/#{application}"
 set :rails_env, 'production'
 set :branch, "master"

 role :app, domain
 role :web, domain
 role :db,  domain, :primary => true

 set :deploy_via, :remote_cache

 set :scm, :git
 set :user, "deploy"
 set :runner, "deploy"
 ssh_options[:port] = ****
 set :use_sudo, false

 after "deploy", "deploy:cleanup"

namespace :deploy do

    desc "Restarting mod_rails with restart.txt"
    task :restart, :roles => :app, :except => { :no_release => true } do
        run "touch #{current_path}/tmp/restart.txt"
    end

    [:start, :stop].each do |t|
        desc "#{t} task is a no-op with mod_rails"
        task t, :roles => :domain do ; end
    end
end

task :after_update_code do  
 run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

寂寞笑我太脆弱 2024-12-10 06:35:19

我在这里找到了解决方案:

http:// www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/

在 config/deploy.rb 中添加以下代码段

    set :default_environment, {
      'PATH' => "/opt/ruby-enterprise/bin/:$PATH"
    }

然后我必须将 gemfile.lock 和 gemfile 添加到存储库和 BAM!

I found the solution here:

http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/

In you config/deploy.rb add the following snippet

    set :default_environment, {
      'PATH' => "/opt/ruby-enterprise/bin/:$PATH"
    }

Then I had to add gemfile.lock and gemfile to the repository and the BAM!

聽兲甴掵 2024-12-10 06:35:19

过时

以下解决方案适用于 capistrano 2。对于版本 3 及更高版本,请使用 capistrano-rbenv插件


假设您使用的是 bash shell,并且按照 bashrc 或 profile 文件(全局在 /etc 或问题在于 capistrano 不使用加载这些文件所需的所谓登录 shell(最终加载 rbenv)。

为此,您可能需要指示 capistrano 使用此类 shell

default_run_options[:shell] = '/bin/bash --login'

将其放入您的 deploy.rb 中。与 fatfrog 的解决方案相比,它的另一个好处是无需引入另一个位置来管理您的 rbenv $PATH 添加,从而使您保持干燥。

outdated

the below solution works for capistrano 2. for version 3 and up use the capistrano-rbenv plugin.


assuming you're using the bash shell and have rbenv configured in something along the lines of a bashrc or profile file (globally in /etc or on a user-by-user basis) the problem is that capistrano does not use a so-called login shell which is required to have these files loaded (which, in the end, load rbenv).

for that purpose you might want to instruct capistrano to use such a shell:

default_run_options[:shell] = '/bin/bash --login'

put that into your deploy.rb. also has the benefit of keeping you DRY by not introducing another location to manage your rbenv $PATH additions -- in contrast to fatfrog's solution.

只有一腔孤勇 2024-12-10 06:35:19

发生这种情况是因为 bashrc rbenv init 没有被执行。将其移至部署者用户 bashrc 文件的顶部,它将解决问题:

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

This happens because the bashrc rbenv init doesn't get executed. Move this to the top of your deployer user bashrc file and it will fix the problem:

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
倦话 2024-12-10 06:35:19

如果您的问题是服务器上的 RVM,则查看 rvm.io 提供的帮助:
https://rvm.io/integration/capistrano/#gem

If your Issue is RVM on the server, then look at the help provided by rvm.io:
https://rvm.io/integration/capistrano/#gem

任性一次 2024-12-10 06:35:19
  1. 确保您的服务器中确实安装了 rbenv(听起来很荒谬,但它确实发生在我的情况下)

  2. 使用这个宝石:https://github.com/yyuu/capistrano-rbenv

了解更多详细信息,请参阅我的回答:https://stackoverflow.com/a/15779928/445908

  1. make sure you indeed have the rbenv installed in your server(sounds ridiculous, but it did happen in my case)

  2. use this gem: https://github.com/yyuu/capistrano-rbenv

for more details, see my answer here: https://stackoverflow.com/a/15779928/445908

遥远的绿洲 2024-12-10 06:35:19

我遇到了这个问题,在我的例子中,部署/生产.rb 的代码片段如下:

run "cd #{release_path} && bundle --without development test"

必须安装捆绑器,如下所示:

sudo apt-get 安装捆绑程序

I was facing this problem and in my case the snippet from deploy/production.rb was as follows:

run "cd #{release_path} && bundle --without development test"

Had to install bundler as follows:

sudo apt-get install bundler

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文