[英]Bundler + RVM + Passenger + Capistrano deployment & missing gems
I got the server with the configuration above. 我得到了上面配置的服务器。
This is the important part of my deploy.rb recipe: 这是我的deploy.rb配方的重要部分:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
require 'bundler/capistrano'
set :rvm_ruby_string, 'ruby-1.9.2-p290'
set :rvm_type, :system
set :bundle_flags, "--deployment"
set :default_environment, {
'PATH' => ENV['PATH'],
'RAILS_ENV' => ENV['RAILS_ENV']
}
set :stages, %w(staging production)
require 'capistrano/ext/multistage'
Running cap staging deploy
as is, leads to an error: 按原样运行
cap staging deploy
会导致错误:
* executing "cd /mnt/data-store/project/releases/shared &&
bundle install --gemfile /mnt/data-store/project/releases/shared/Gemfile
--path /mnt/data-store/project/shared/bundle --deployment --without development test"
** [out :: localhost] The --deployment flag requires a Gemfile.lock.
Please make sure you have checked your Gemfile.lock into version control
before deploying.
... rolling back ...
failed: "env PATH=... RAILS_ENV=staging rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.2-p290' -c 'cd /mnt/data-store/project/releases/shared && bundle install --gemfile /mnt/data-store/project/releases/shared/Gemfile --path /mnt/data-store/project/shared/bundle --deployment --without development test'" on localhost
Gemfile and Gemfile.lock are in the source control. Gemfile和Gemfile.lock位于源代码管理中。 I ran
bundle install
locally first to generate the .lock file. 我首先在本地运行
bundle install
以生成.lock文件。 But the bundler/capistrano points to /mnt/data-store/project/releases/shared/Gemfile so I just copied manually both files there. 但是bundler / capistrano指向/ mnt / data-store / project / releases / shared / Gemfile,所以我只是手动复制了两个文件。 I'm sure I'm doing it wrong here.
我确定我在这里做错了。 I guess it should be copied automatically.
我想它应该自动复制。
Executed deploy again (1) and it didn't fail on the bundle install, it even had 再次执行部署(1)并且它在捆绑安装上没有失败,它甚至有
Your bundle is complete! It was installed into /mnt/data-store/project/shared/bundle
Your bundle is complete! It was installed into /mnt/data-store/project/shared/bundle
in the output. Your bundle is complete! It was installed into /mnt/data-store/project/shared/bundle
中。
BUT, one of my cap tasks executes a rake. 但是,我的一个上限任务执行一个耙子。 The result of this is: *Could not find bcrypt-ruby-3.0.1 in any of the sources *Try running
bundle install
. 结果是:*无法在任何源中找到bcrypt-ruby-3.0.1 *尝试运行
bundle install
。
Proceeding with my adventure, I discovered that once you have .bundle/config with BUNDLE_PATH: /mnt/data-store/project/shared/bundle
It works. 继续我的冒险,我发现一旦你有.bundle / config与
BUNDLE_PATH: /mnt/data-store/project/shared/bundle
它的工作原理。 I had this directory, probably created by bundler, under /mnt/data-store/releases/shared/
, so I copied manually to the rails root. 我有这个目录,可能是由bundler在
/mnt/data-store/releases/shared/
,所以我手动复制到rails根目录。
Now, rake/rails c work. 现在,rake / rails c工作。
bundle show twitter
shows .../shared/bundle/ruby/1.9.1/gems/twitter-1.7.1
. bundle show twitter
shows .../shared/bundle/ruby/1.9.1/gems/twitter-1.7.1
。
BUT, redeploying brings me back to (1), because the .bundle dir isn't there. 但是,重新部署将我带回(1),因为.bundle目录不存在。
Concrete questions: 具体问题:
Thanks! 谢谢!
Look at this part in the deployment.rb file (Bundler code) 在deployment.rb文件(Bundler代码)中查看此部分
args = ["--gemfile #{File.join(context.fetch(:current_release), bundle_gemfile)}"]
args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
There's a key called :current_release
, this key is probably not being set correctly with Capistrano for some reason. 有一个名为
:current_release
键,由于某些原因,这个键可能没有被Capistrano正确设置。
the :current_release
in bundler will point to the "shared" folder instead of the latest release (with the timestamp) :current_release
bundler中的:current_release
将指向“共享”文件夹而不是最新版本(带时间戳)
This is getting executed on before 'deploy:finalize_update'
. 这将
before 'deploy:finalize_update'
执行。
What I would do in order to fix this is to add your own hook on this event. 我要做的就是在这个事件上添加你自己的钩子。
before 'deploy:finalize_update', 'x:set_current_release'
And this is the actual method 这是实际的方法
task :set_current_release, :roles => :app do
set :current_release, latest_release
end
Error 错误
The --deployment flag requires a Gemfile.lock. Please make sure you have checked your Gemfile.lock into version control before deploying.
occurs when there is something unwantend inside your releases directory on server. 当服务器上的发行版目录中存在未解决的内容时发生。 There should be only directories with previous versions of your app (their names starts with date and looks like 20111025125442).
应该只有您的应用程序以前版本的目录(其名称以日期开头,看起来像20111025125442)。
So, remove unwanted directories or files and then try to deploy again. 因此,删除不需要的目录或文件,然后再次尝试部署。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.