5

我正在尝试使用 Vagrant 和 Chef-Solo 在 CentOS 6.3 64 位上设置 Rails 环境。

使用 Chef 时无法安装 Rails,并显示错误消息,

Mixlib::ShellOut::CommandTimeout: rbenv_gem[rails] (main::default line 21) 有一个错误:Mixlib::Shell
Out::CommandTimeout: 命令超时:

我该如何解决这个问题?

环境

  • 操作系统:Mac OS X 10.8.2
  • 虚拟盒子:4.2.12
  • 流浪者:1.1.5
  • 厨师:11.4.0
  • 刀独奏:0.3.0

我的脚步

1.创建流浪虚拟机

$ vagrant box add centos https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box`
$ vagrant init centos
$ vagrant up

2.创建厨师存储库并将厨师安装到VM

$ knife solo init chefrepo
$ knife solo prepare vagrant@192.168.33.10 # vagrant VMs IP

3.从 OpsCode 导入公共食谱

$ knife cookbook site vendor rbenv 

这会将 rbenv 食谱导入到 chefrepo/cookbooks/rbenv

4.创建我的食谱并修改default.rb

$ knife cookbook create main -o site-cookbooks
$ vi site-cookbooks/main/recipes/default.rb


include_recipe 'rbenv::default'
include_recipe 'rbenv::ruby_build'

rbenv_ruby "2.0.0-p0" do
  global true
end

rbenv_gem "rails" do
  ruby_version "2.0.0-p0"
end

5.厨师

$ knife solo cook vagrant@192.168.33.10

然后得到如下错误。

# Declared in /home/vagrant/chef-solo/site-cookbooks/main/recipes/default.rb:21:in `from_file'

rbenv_gem("rails") do
  provider Chef::Provider::Package::RbenvRubygems
  action :install
  retries 0
  retry_delay 2
  cookbook_name :main
  recipe_name "default"
  ruby_version "2.0.0-p0"
  package_name "rails"
  gem_binary "/opt/rbenv/shims/gem"
  version "3.2.13"
end


[2013-04-17T12:00:13+02:00] ERROR: Running exception handlers
[2013-04-17T12:00:13+02:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2013-04-17T12:00:13+02:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-04-17T12:00:13+02:00] FATAL: Mixlib::ShellOut::CommandTimeout: rbenv_gem[rails] (main::default line 21) had an error: Mixlib::Shell
Out::CommandTimeout: command timed out:
---- Begin output of /opt/rbenv/versions/2.0.0-p0/bin/gem install rails -q --no-rdoc --no-ri -v "3.2.13" ----
STDOUT: 
STDERR: 
---- End output of /opt/rbenv/versions/2.0.0-p0/bin/gem install rails -q --no-rdoc --no-ri -v "3.2.13" ----

ERROR: RuntimeError: chef-solo failed. See output above.

手动安装

Rails 可以通过$ sudo gem install railsVM 安装。这大约需要 20 分钟或更长时间。

4

1 回答 1

3

我不确定您的环境限制是什么,但一种可能的解决方案是使用不同的操作系统。几个星期前,我在 CentOS 6.3 和 Vagrant 上遇到了一个非常相似的问题,并且花了几天的时间。一旦我切换到 Ubuntu,就像切热黄油一样。

于 2013-04-20T18:23:50.407 回答