3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RiotGames/rbenv-cookbookでgem install railsした時にハマったこと

Last updated at Posted at 2014-10-29

Chefのサードパーティレシピ管理Berkshelfで使われているRiotGames/rbenv-cookbookを使ってRails入れようとしたらハマった。

##ハマったとこ
rbenv, ruby共に入れられたけど

site-cookbook/my_cookbook/recipes/default.rb
rbenv_gem "rails" do
  ruby_version "x.x.x"
  version "x.x.x"
end

のところでエラー。

##結論

site-cookbook/my_cookbook/recipes/default.rb
include_recipe "rbenv::rbenv_vars"

site-cookbook/my_cookbook/recipes/default.rb
execute "resolv.option" do
  command "echo 'options single-request-reopen' >> /etc/resolv.conf"
  not_if "cat /etc/resolv.conf | grep 'options single-request-reopen'"
  action :run
end

を追記すればおk。

##rbenv-varsとは?
Rubyのプロセスを生成する前に、グローバルおよびプロジェクト固有の環境変数を設定することができる、rbenvためのプラグイン。

sstephenson/rbenv-vars · GitHub : https://github.com/sstephenson/rbenv-vars

どうやらPATHが通ってなかったんだなー(´・ω・`)

##single-request-reopenとは?

RHEL6/CentOS6では、single-request-reopen を必須にしたい… : http://www.kunitake.org/chalow/2012-11-02-1.html

CentOS6はIPv6が有効になっているとなるらしい(;・∀・)

##書いたところ

# Berksfile
source "https://supermarket.getchef.com"

cookbook "rbenv"
site-cookbook/my_cookbook/metadata.rb
# 追加
depends 'rbenv'
site-cookbook/my_cookbook/recipes/default.rb
include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

# Rails インストール時に最強に時間が掛かるのでとりあえず resolvにsingle-request-reopen設定。
# Vagrant + Chef Solo + Berkshelf で rbenv + Rails + Passenger をインストールした話 - ichidou のブログ : http://ichidou.hatenablog.com/entry/2014/02/27/021659
execute "resolv.option" do
  command "echo 'options single-request-reopen' >> /etc/resolv.conf"
  not_if "cat /etc/resolv.conf | grep 'options single-request-reopen'"
  action :run
end

rbenv_ruby "2.1.3" do
  global "true"
end

rbenv_gem "rails" do
  ruby_version "2.1.3"
  version "4.1.6"
end

##エラー内容(一部)

Running handlers:
[2014-10-29T03:12:07+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-10-29T03:12:07+00:00] ERROR: Exception handlers complete
[2014-10-29T03:12:07+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 20 resources updated in 1263.996965772 seconds
[2014-10-29T03:12:07+00:00] ERROR: rbenv_gem[rails] (rails_install::default line 25) had an error: Mixlib::ShellOut::CommandTimeout: Command timed out after 600s:
Command execeded allowed execution time, process terminated
---- Begin output of /opt/rbenv/versions/2.1.3/bin/gem install rails -q --no-rdoc --no-ri  -v "4.1.6"  ----

環境
ローカル: Mac
リモート: Vagrant(CentOS6.5)

3
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?