使用rvm1-capistrano3安装Ruby

时间:2014-01-21 13:47:42

标签: ruby-on-rails ruby rvm capistrano capistrano3

当我跑步时

cap production rvm1:install:ruby

我在控制台输出结束时收到此错误:

Command: cd ~/apps/foo/releases/20140121133714 && ( PATH=/opt/ruby/bin:$PATH /usr/bin/env /tmp/foo/rvm-auto.sh rvm install . )
  

无法确定要使用哪个Ruby; 。应该包含.rvmrc或   .versions.conf或.ruby-version或.rbfu-version或.rbenv-version,或Gemfile中的相应行。
  上限已中止!

修改

在我的应用根目录添加.ruby-version后,我收到的内容

DEBUG [af3b80bc] Command: cd ~/apps/foo/releases/20140121160854 && /usr/bin/env /tmp/foo/rvm-auto.sh rvm install .
DEBUG [af3b80bc]    ruby-2.0.0-p247 is not installed.
DEBUG [af3b80bc]    To install do: 'rvm install ruby-2.0.0-p247'
DEBUG [af3b80bc]    ruby-2.0.0-p247 is not installed.
DEBUG [af3b80bc]    Searching for binary rubies, this might take some time.
DEBUG [af3b80bc]    ruby-2.0.0-p247 is not installed.
DEBUG [af3b80bc]    Searching for binary rubies, this might take some time.
DEBUG [af3b80bc]    No binary rubies available for: ubuntu/12.10/x86_64/system.
DEBUG [af3b80bc]    Searching for binary rubies, this might take some time.
DEBUG [af3b80bc]    Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
DEBUG [af3b80bc]    Searching for binary rubies, this might take some time.
DEBUG [af3b80bc]    RVM does not have prediction for required space for system, assuming 150MB should be enough, let us know if it was not.
DEBUG [af3b80bc]    Searching for binary rubies, this might take some time.
DEBUG [af3b80bc]    Either the ruby interpreter is unknown or there was an error!.

我正在使用rvm1-capistrano gem运行Capistrano 3.1.1。这是开箱即用的实施;没什么特别的。

group :development do
  gem 'capistrano', '~> 3.1.0'
  gem 'capistrano-rails'
  gem 'capistrano-bundler'
  gem 'rvm1-capistrano3', require: false
# gem 'capistrano-rvm'
end

# capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'rvm1/capistrano3'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

我还在输出中遇到另外两个错误:

Running /usr/bin/env [ -L ~/apps/foo/releases/20140121135720/public/assets ] on foo.com
Command: [ -L ~/apps/foo/releases/20140121135720/public/assets ]
Finished in 0.291 seconds with exit status 1 (failed).
Running /usr/bin/env [ -d ~/apps/foo/releases/20140121135720/public/assets ] on foo.com
Command: [ -d ~/apps/foo/releases/20140121135720/public/assets ]
Finished in 0.295 seconds with exit status 1 (failed).

2 个答案:

答案 0 :(得分:6)

问题

如果你去远程服务器并执行:

cd ~/apps/foo/releases/20140121160854 && /usr/bin/env /tmp/foo/rvm-auto.sh rvm install .

你会得到同样的错误,但如果你执行此操作

cd ~/apps/foo/releases/20140121160854 && /usr/bin/env /tmp/foo/rvm-auto.sh rvm install ruby-2.0.0-p247

成功。 当rvm-auto.sh执行rvm install .命令时,会出现此问题。不确定是否是一个rvm问题,但它看起来对我的眼睛..

解决方法

如果您指定要在config/deploy.rb中安装的所需ruby版本:

set :rvm1_ruby_version, "ruby-2.0.0-p247"

执行任何rvm1任务之前。一切都应该没问题

答案 1 :(得分:0)

应用程序不知道要使用哪个版本的ruby。

您需要做的就是将一个名为.ruby-version的文件添加到您的应用程序的根目录,并将其内容添加到

1.9.3

或者您正在使用的任何版本的红宝石。

您可能还需要.ruby-gemset个文件。在这种情况下,其内容应为

some_gemset_name

您可以随意调用gemset。它是您的应用程序的本地。