尝试使用Capistrano 3和rbenv安装Rails应用程序 [英] Trying to install a rails app with Capistrano 3 and rbenv

查看:82
本文介绍了尝试使用Capistrano 3和rbenv安装Rails应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装了Ruby 2.1.1的VPS设置,并且本地安装了相同版本。我的运行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 have a VPS setup with Ruby 2.1.1 installed and the same version is installed locally. 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.

我本来是用刀单刀在服务器上安装ruby的,但是好像capistrano想要解决这个问题。

I originally installed ruby on the server using knife solo but it seems like capistrano wants to take care of this.

当我运行cap分期操作时部署我收到错误

When I run cap staging deploy I get an error

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

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

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


推荐答案

长期以来一直在为这个问题而苦苦挣扎。 @Darmen的回答为我指明了正确的方向:

Was also struggling with this problem for a long time. @Darmen's answer pointed me into the right direction:

1)在Capfile中设置rbenv的路径。对于Capistrano 3.2.1,这是:

1) Set the path for rbenv in Capfile. For Capistrano 3.2.1, this is:

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

(比较rbenv_custom_path语法的 https://github.com/capistrano/rbenv -与@Darmen的答案稍有不同)

(compare https://github.com/capistrano/rbenv for rbenv_custom_path syntax - slightly different from @Darmen's answer)

2)在capfile中设置正确的rbenv版本,例如

2) Set the correct rbenv version in capfile, e.g.,

set :rbenv_ruby, '2.1.2'

对我来说,我不必使用完整的红宝石版本。它必须与/.rbenv/versions中的目录名称匹配

For me, I did not have to use the complete ruby version. It has to match the directory name in /.rbenv/versions

希望有帮助-我花了很长时间...;-)

Hope that helps - took me ages... ;-)

这篇关于尝试使用Capistrano 3和rbenv安装Rails应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆