Capistrano 和 Bundler 问题 - 捆绑包:未找到
尝试使用捆绑/安装选项部署我的应用程序时,我不断收到以下错误:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我在这里找到了解决方案:
http:// www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/
然后我必须将 gemfile.lock 和 gemfile 添加到存储库和 BAM!
I found the solution here:
http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/
Then I had to add gemfile.lock and gemfile to the repository and the BAM!
过时
以下解决方案适用于 capistrano 2。对于版本 3 及更高版本,请使用 capistrano-rbenv插件。
假设您使用的是 bash shell,并且按照 bashrc 或 profile 文件(全局在 /etc 或问题在于 capistrano 不使用加载这些文件所需的所谓登录 shell(最终加载 rbenv)。
为此,您可能需要指示 capistrano 使用此类 shell :
将其放入您的
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
orprofile
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:
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.发生这种情况是因为 bashrc rbenv init 没有被执行。将其移至部署者用户 bashrc 文件的顶部,它将解决问题:
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:
如果您的问题是服务器上的 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
确保您的服务器中确实安装了 rbenv(听起来很荒谬,但它确实发生在我的情况下)
使用这个宝石:https://github.com/yyuu/capistrano-rbenv
了解更多详细信息,请参阅我的回答:https://stackoverflow.com/a/15779928/445908
make sure you indeed have the rbenv installed in your server(sounds ridiculous, but it did happen in my case)
use this gem: https://github.com/yyuu/capistrano-rbenv
for more details, see my answer here: https://stackoverflow.com/a/15779928/445908
我遇到了这个问题,在我的例子中,部署/生产.rb 的代码片段如下:
必须安装捆绑器,如下所示:
I was facing this problem and in my case the snippet from deploy/production.rb was as follows:
Had to install bundler as follows: