2013-03-08 15 views
0

我在Vagrant虛擬機上用Chef-solo獲得了RVM設置,但是我很困惑爲什麼在rails項目中找不到bundler如何從Chef和Vagrant調試RVM設置?

因此,在配置後我看到:

 
Last login: Thu Oct 4 15:23:58 2012 from 10.0.2.2 
[email protected]:~$ ruby -v 
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux] 
[email protected]:~$ gem list 

*** LOCAL GEMS *** 

bigdecimal (1.1.0) 
bundler (1.3.2) 
daemon_controller (1.1.1) 
fastthread (1.0.7) 
io-console (0.3) 
json (1.5.4) 
minitest (2.5.1) 
passenger (3.0.18) 
rack (1.5.2) 
rake (10.0.3, 0.9.2.2) 
rdoc (3.9.4) 
rubygems-bundler (1.1.1) 
rvm (1.11.3.6) 

將項目目錄我看到:

 
[email protected]:~$ cd /www/vm/rails/current/ 
============================================================================== 
= NOTICE                  = 
============================================================================== 
= RVM has encountered a new or modified .rvmrc file in the current directory = 
= This is a shell script and therefore may contain any shell commands.  = 
=                   = 
= Examine the contents of this file carefully to be sure the contents are = 
= safe before trusting it! (Choose v[iew] below to view the contents)  = 
============================================================================== 
Do you wish to trust this .rvmrc file? (/www/vm/rails/current/.rvmrc) 
y[es], n[o], v[iew], c[ancel]> y 
mkdir: cannot create directory `/usr/local/rvm/gems/[email protected]': Permission denied 
gemset vm is not existing, creating. 
mkdir: cannot create directory `/usr/local/rvm/gems/[email protected]': Permission denied 
mkdir: cannot create directory `/usr/local/rvm/gems/[email protected]': Permission denied 

但現在,束不能再被發現了,我也有問題,激活RVM ...任何想法如何調試?

 
$ rvm use ruby-1.9.3-p327 
Please note that `rvm gem ...` was removed, try `gem ` or `rvm all do gem ` instead. (see: 'rvm usage') 

PS我的節點JSON基本上是這樣的:https://github.com/mulderp/chef-rails-stack

回答

1

爲了調試我用https://github.com/mpapis/rvm-binary/blob/master/cookbooks/binary/recipes/default.rb#L11

class Chef::Resource::Script 
    def log_code command 
    if Chef::Config[:log_level] == :debug 
     code "{ #{command}; _ret=$?; echo \"Exit status was $_ret.\"; exit $_ret; } 2>&1 | 
tee /var/log/#{@command.to_s.gsub(/ /,"_")}.log; exit ${PIPESTATUS[0]}" 
    else 
     code command 
    end 
    end 
end 

,然後代替code使用log_code,這將節省日誌中/var/log/#{@command.to_s.gsub(/ /,"_")}.log

至於易於整合RVM與廚師檢查https://gist.github.com/sevos/5076747

deploy_user = node[:deploy][:user] 
deploy_user_home = File.join('/', 'home', deploy_user) 
rvm_version = "head" 

execute "install_rvm_for_deploy_user" do 
    user deploy_user 
    command "curl -L https://get.rvm.io | bash -s #{rvm_version}" 
    environment "HOME" => deploy_user_home 
    creates "#{deploy_user_home}/.rvm" 
end 

node['buildpack']['ruby_versions'].each do |ruby_version| 
    execute "install_rvm_ruby_#{ruby_version}" do 
    user deploy_user 
    environment "HOME" => deploy_user_home 
    command "#{deploy_user_home}/.rvm/bin/rvm install #{ruby_version} --autolibs=3" 
    end 
end 

file "#{deploy_user_home}/.rvmrc" do 
    content 'export rvm_trust_rvmrcs_flag=1' 
    owner deploy_user 
    mode 0644 
end 
+0

謝謝,米迦勒!很高興看到這個...我會檢查星期一... pitty,我們沒有在Wroclove.rb – poseid 2013-03-09 22:42:20

+0

下次見面,我會嘗試去參觀周圍的所有活動;) – mpapis 2013-03-09 22:47:31

+0

不幸的是,我仍然有點迷路這個。如果我運行你的食譜,我會看到確實有一些安裝正在進行:請參閱https://gist.github.com/mulderp/5134887-這可能是一個用戶配置問題 - 我將嘗試讓vagrant用戶成爲rvm用戶。 'rvm list'現在爲rvm用戶 – poseid 2013-03-11 15:09:02