乘客上的导轨无法识别 RVM [英] Rails on Passenger not recognizing RVM

查看:53
本文介绍了乘客上的导轨无法识别 RVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已通过以下方式使用 rvm 转向 ree:

I have shifted to ree using rvm by:

rvm use ree@mygemset

并通过 Gemfile 和 bundle install 安装了 kaminari gem.

and installed kaminari gem through Gemfile and bundle install.

但 Phusion 乘客似乎仍在系统默认目录中寻找 gem.它说:

But Phusion passenger seems to still look for the gem in system default directory. It says:

Error message:
    Could not find kaminari-0.10.4 in any of the sources (Bundler::GemNotFound)

我错过了什么?Rails 需要任何特定的配置来识别我正在使用的当前 ruby​​ 版本和 gemset??

What do I missing? Rails need any specific configuration to recognize the current ruby version and gemset I am using??

推荐答案

您需要指示Passenger 加载RVM,然后为您的gemset 设置环境.最简单的方法包括三个步骤:

You need to instruct Passenger to load RVM and then setup the environment for your gemset. The easiest way to go about this involves three steps:

  1. 创建 .rvmrc 文件:在 Rails 项目的根目录中,创建一个名为 .rvmrc 的文件,其中包含用于加载 gemset 的 RVM 命令.例如:

  1. Create a .rvmrc file: In the root of your rails project, create a file called .rvmrc that contains the RVM command you would use to load up your gemset. For example:

rvm use ree@gemset

  • 信任 .rvmrc 文件:将新的 .rvmrc 文件部署到服务器后,将目录更改为你的轨道项目.RVM 应该询问您是否要信任您的 .rvmrc 文件;只需按照说明操作并在询问时输入 yes.如果没有出现提示,请使用以下命令信任您的.rvmrc:

  • Trust the .rvmrc file: Once you've deployed your new .rvmrc file to your server, change directories into your rails project. RVM should ask you if you want to trust your .rvmrc file; simply follow the instructions and type yes when asked. If the prompt does not appear, use the following command to trust your .rvmrc:

    rvm rvmrc trust
    

    注意:如果您希望自动信任所有.rvmrc,只需添加:

    Note: If you wish to automatically trust all .rvmrcs, it is a simple matter of adding:

    rvm_trust_rvmrcs_flag=1
    

    到您的个人或系统范围的 rvmrc(分别为~/.rvmrc/etc/rvmrc).

    to your personal or system wide rvmrc (~/.rvmrc and /etc/rvmrc, respectively).

    指示乘客设置 RVM 环境:通过在你的 Rails config 目录叫做 setup_load_paths.rb (所以是 config/setup_load_paths.rb ).该文件应包含https://gist.github.com/870310的内容:

    Instruct passenger to set up the RVM environment: Instruct passenger to load up RVM and use the gemset in your .rvmrc file by creating a new file in your Rails config directory called setup_load_paths.rb (so config/setup_load_paths.rb in all). The file should contain the contents of https://gist.github.com/870310:

    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')
        $LOAD_PATH.unshift rvm_lib_path
        require 'rvm'
        RVM.use_from_path! File.dirname(File.dirname(__FILE__))
      rescue LoadError
        raise "RVM ruby lib is currently unavailable."
      end
    end
    
    # This assumes Bundler 1.0+
    ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
    require 'bundler/setup'
    

    现在,当您重新启动应用程序 (touch tmp/restart.txt) 时,您应该可以开始使用了.

    Now when you restart your app (touch tmp/restart.txt) you should be good to go.

    你应该注意到Passenger一次只能运行一个版本的Ruby;如果Passenger 是在ree 以外的其他东西下设置的,您可能需要重新安装Passenger 和/或重做它生成的包装脚本.

    You should note that Passenger can only run one version of Ruby at a time; if Passenger was set up under something other than ree, you will probably have to reinstall Passenger and/or redo the wrapper script it generates.

    这篇关于乘客上的导轨无法识别 RVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆