简体   繁体   English

尝试使用Capistrano 3和rbenv安装rails应用程序

[英]Trying to install a rails app with Capistrano 3 and rbenv

I have a VPS setup with Ruby 2.1.1 installed and the same version is installed locally. 我安装了Ruby 2.1.1的VPS设置,并在本地安装了相同的版本。 My dev machine running 14.04 Ubuntu reports ruby -v = ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux] and rbenv -v = rbenv 0.4.0-97-gfe0b243. 我的dev机器运行14.04 Ubuntu报告ruby -v = ruby​​ 2.1.1p76(2014-02-24修订版45161)[x86_64-linux]和rbenv -v = rbenv 0.4.0-97-gfe0b243。

I originally installed ruby on the server using knife solo but it seems like capistrano wants to take care of this. 我最初使用刀独奏在服务器上安装了ruby,但似乎capistrano想要照顾这个。

When I run cap staging deploy I get an error 当我运行cap staging deploy时,我收到一个错误

rbenv: cap: command not found
The `cap' command exists in these Ruby versions:  2.1.0

Gemfile 的Gemfile

group :development do
 gem 'capistrano', github: 'capistrano/capistrano', ref: 'master'
 gem 'capistrano-rails', github: 'capistrano/rails', ref: 'master'
 gem 'capistrano-bundler'
 gem 'capistrano-rbenv', "~> 2.0"
end

Capfile Capfile

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

deploy.rb deploy.rb

set :rbenv_type, :system
set :rbenv_ruby, '2.1.1'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

gem env 宝石环境

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/mark/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /home/mark/.rbenv/versions/2.1.1/bin/ruby
  - EXECUTABLE DIRECTORY: /home/mark/.rbenv/versions/2.1.1/bin
  - SPEC CACHE DIRECTORY: /home/mark/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/mark/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0
     - /home/mark/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/mark/.rbenv/versions/2.1.1/bin

Was also struggling with this problem for a long time. 很长一段时间也在努力解决这个问题。 @Darmen's answer pointed me into the right direction: @Darmen的回答指出了我正确的方向:

1) Set the path for rbenv in Capfile. 1)在Capfile中设置rbenv的路径。 For Capistrano 3.2.1, this is: 对于Capistrano 3.2.1,这是:

set :rbenv_custom_path, '/home/deploy/.rbenv/'

Note (maybe obvious) that it has to be the path on the server, find it with: 注意(可能很明显)它必须是服务器上的路径,找到它:

which rbenv

(compare https://github.com/capistrano/rbenv for rbenv_custom_path syntax - slightly different from @Darmen's answer) (比较https://github.com/capistrano/rbenv的rbenv_custom_path语法 - 与@ Darmen的答案略有不同)

2) Set the correct rbenv version in capfile, eg, 2)在capfile中设置正确的rbenv版本,例如,

set :rbenv_ruby, '2.1.2'

For me, I did not have to use the complete ruby version. 对我来说,我没有必要使用完整的ruby版本。 It has to match the directory name in /.rbenv/versions 它必须匹配/.rbenv/versions中的目录名称

Hope that helps - took me ages... ;-) 希望有所帮助 - 带我年龄...... ;-)

I solved the same problem setting :rbenv_path . 我解决了同样的问题设置:rbenv_path Yours should be: 你的应该是:

set :rbenv_path, '/home/mark/.rbenv/'

I also had to set the complete ruby version, like this: 我还必须设置完整的ruby版本,如下所示:

set :rbenv_ruby, '2.1.1-p76' 

try those commands from your dev machine: 从您的开发机器尝试这些命令:

cd /path/to/your/application/root
gem uninstall capistrano
gem uninstall capistrano-rails
gem uninstall capistrano-bundler
gem uninstall capistrano-rbenv
# select "All versions" everytimes
bundle
# Verify that all capistrano gems are installed
rbenv rehash

Then try cap staging deploy again 然后再次尝试cap staging deploy

Try to use Ruby 2.1.0, seems that the problem is caused by some compatibility issue with 2.1.1. 尝试使用Ruby 2.1.0,似乎问题是由2.1.1的一些兼容性问题引起的。

Or try to update Capistrano to the latest release (if you haven't yet done). 或者尝试将Capistrano更新到最新版本 (如果您尚未完成)。

您可能需要运行deploy:setup_config ,然后只需直接部署即可。

namespace :logs do desc "tail rails logs" task :tail_rails do on roles(:app) do execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log" end end end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 与Capistrano Rbenv独角兽一起部署Rails应用 - Deploy rails app with capistrano rbenv unicorn 使用Capistrano部署Rails应用程序 - Rbenv版本问题 - Deploying Rails App Using Capistrano - Rbenv version issue 有和没有rbenv的Rails Capistrano部署 - Rails Capistrano deploy with and without rbenv Rails Capistrano的rbenv路径错误? - Rails Capistrano with wrong rbenv path? Rails 3.2不使用捆绑的宝石,Capistrano需要安装sudo gem和rbenv找不到轨道 - Rails 3.2 not using bundled gems, Capistrano needs sudo gem install and rbenv not finding rails 使用 capistrano 部署 rails 4 应用程序时 rbenv 出错 - Error with rbenv at deploying rails 4 application with capistrano Rails + Capistrano`rbenv:2.3.1未在$ HOME / .rbenv / versions / 2.3.1中找到或未找到 - Rails + Capistrano `rbenv: 2.3.1 is not installed or not found in $HOME/.rbenv/versions/2.3.1` Rails Capistrano rbenv Puma 包:找不到命令 - Rails Capistrano rbenv Puma bundle: Command not found 执行 bundler 时 gem 版本出错:尝试部署 rails 应用程序时安装 capistrano 任务 - Errors on gem version while executing bundler:install task of capistrano when trying to deploy rails app 尝试使用Capistrano部署Rails App来执行Droplet - Trying to deploy Rails App with Capistrano to Do Droplet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM