简体   繁体   English

Rails使用rvm忽略Ruby版本

[英]Rails ignores Ruby version using rvm

I'm having an issue getting the right Ruby version to load with one project. 我在获取正确的Ruby版本以加载一个项目时遇到问题。 I've already install the ruby version I need with rvm, and set it up with rvm use 1.9.3 , when I run rvm list I get this: 我已经用rvm安装了所需的ruby版本,并用rvm use 1.9.3 ,当我运行rvm list我得到了:

=> ruby-1.9.3-p547 [ x86_64 ]
 * ruby-2.1.2 [ x86_64 ]

So it appear it's correct, but when I try to run the project with rails server I get this: 看来这是正确的,但是当我尝试使用rails server运行项目时,我得到了:

Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3

Here is my Gemfile : 这是我的Gemfile

source 'http://rubygems.org'

ruby '1.9.3'

#gem 'date-performance'

gem 'rails', '3.1.12'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'bson',     '1.3.1'
gem 'bson_ext', '~> 1.3.1'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
  gem 'rails-backbone'
end

gem 'jquery-rails'

# Use unicorn as the web server
gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

gem 'rspec-rails', :group => [:development, :test]

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
  gem 'database_cleaner'
  gem 'factory_girl_rails'
  #gem 'mongoid-rspec'
  gem 'cucumber-rails'
  gem 'capybara'
end

#
# Backup
#
gem "heroku-mongo-backup"

#
# Errors
#
gem 'newrelic_rpm'

# ORM
gem 'mongoid', '~> 2.2'

#S3 media storage
gem 'aws-s3'
gem 'fog'
gem 'asset_sync'

#Image processing
gem 'carrierwave'
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
gem 'rmagick'

#Cache
gem 'rack-cache', :require => 'rack/cache'
gem 'dalli'

# Active admin
gem 'activeadmin'
gem 'meta_search', '>= 1.1.0.pre'
gem 'sass-rails', "  ~> 3.1.0"

group :production do
  gem 'thin'
end

group :development do
  #gem 'heroku-rails'
end

which bundle output: 哪个捆绑输出:

/Users/arielorozco/.rvm/gems/ruby-1.9.3-p547@global/bin/bundle

gem env : gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 1.9.3 (2014-05-14 patchlevel 547) [x86_64-darwin13.1.0]
  - INSTALLATION DIRECTORY: /Users/arielorozco/.rvm/gems/ruby-1.9.3-p547
  - RUBY EXECUTABLE: /Users/arielorozco/.rvm/rubies/ruby-1.9.3-p547/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/arielorozco/.rvm/gems/ruby-1.9.3-p547/bin
  - SPEC CACHE DIRECTORY: /Users/arielorozco/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-13
  - GEM PATHS:
     - /Users/arielorozco/.rvm/gems/ruby-1.9.3-p547
     - /Users/arielorozco/.rvm/gems/ruby-1.9.3-p547@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/arielorozco/.rvm/gems/ruby-1.9.3-p547/bin
     - /Users/arielorozco/.rvm/gems/ruby-1.9.3-p547@global/bin
     - /Users/arielorozco/.rvm/rubies/ruby-1.9.3-p547/bin
     - /Users/arielorozco/.rvm/bin
     - /usr/local/heroku/bin
     - /Applications/MAMP/bin/php/php5.4.19/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/bin
     - /opt/X11/bin
     - /usr/local/git/bin

I've no idea how to get this work (I'm using a Mac), please help! 我不知道如何进行这项工作(我使用的是Mac),请帮忙!

There are two approaches that come to mind to solve this without being able to see your Gemfile. 有两种方法可以解决此问题,而又看不到您的Gemfile。

First your Gemfile more than likely has a line like this in it 首先,您的Gemfile很可能在其中包含这样的行

              ruby '2.0.0'

You can either change that '2.0.0' to '1.9.3' and that would make the app run with 1.9.3 upon bundling. 您可以将“ 2.0.0”更改为“ 1.9.3”,然后在捆绑时使应用程序以1.9.3运行。

The alternative would be to upgrade the ruby version you are using now to 2.0. 替代方法是将您正在使用的红宝石版本升级到2.0。 With something like rvm install ruby 2.0.0. 使用rvm之类的东西安装ruby 2.0.0。

Gemfile specified ruby version takes priority. Gemfile指定的ruby版本优先。 so it doesn't matter which ruby is currently set in terminal. 因此,终端中当前设置的红宝石都没关系。 Remove ruby '1.9.3' line from Gemfile , it will work . Gemfile删除Gemfile ruby '1.9.3'行,它将起作用。

This may be a case where your bundler gem is installed in ruby 2.0.0 这可能是您的bundler gem安装在ruby 2.0.0中的情况

Can you add '$rbenv which bundle' and '$ gem env' results 能否添加“ $ rbenv捆绑销售商品”和“ $ gem env”结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM