2012-11-06 23 views
0

我想讓nginx爲rails應用程序提供服務。我已經使用rvm gemset設置了我的寶石。從directions獲得nginx的加載我的寶石,我做了一個配置/ setup_load_paths.rb文件:ENV ['MY_RUBY_HOME']在試圖讓nginx和rvm一起玩時爲零

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') 
    begin 
    rvm_path  = File.dirname(File.dirname(ENV['MY_RUBY_HOME'])) 
    rvm_lib_path = File.join(rvm_path, 'lib') 
    puts rvm_lib_path.inspect 
    $LOAD_PATH.unshift rvm_lib_path 
    require 'rvm' 
    RVM.use_from_path! File.dirname(File.dirname(__FILE__)) 
    rescue LoadError 
    # RVM is unavailable at this point. 
    raise "RVM ruby lib is currently unavailable." 
    end 
end 

ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__)) 
require 'bundler/setup' 

這似乎並沒有做到這一點。所以試圖調試,我發現ENV['MY_RUBY_HOME']實際上是零,因此第一塊代碼甚至不運行。爲什麼是這個零,我能做些什麼來解決這個問題?

+0

如果你放在'配置/初始化文件/ setup_load_path.rb'呢? –

回答

0

您正在關注老的指令,再次訪問https://rvm.io/integration/passenger/並使用config/setup_load_paths.rb的正確代碼:

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') 
    begin 
    gems_path = ENV['MY_RUBY_HOME'].split(/@/)[0].sub(/rubies/,'gems') 
    ENV['GEM_PATH'] = "#{gems_path}:#{gems_path}@global" 
    require 'rvm' 
    RVM.use_from_path! File.dirname(File.dirname(__FILE__)) 
    rescue LoadError 
    raise "RVM gem is currently unavailable." 
    end 
end 

# If you're not using Bundler at all, remove lines bellow 
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__)) 
require 'bundler/setup' 
相關問題