简体   繁体   中英

Rails ignores Ruby version using rvm

I'm having an issue getting the right Ruby version to load with one project. 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:

=> 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:

Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3

Here is my 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 :

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!

There are two approaches that come to mind to solve this without being able to see your Gemfile.

First your Gemfile more than likely has a line like this in it

              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.

The alternative would be to upgrade the ruby version you are using now to 2.0. With something like rvm install ruby 2.0.0.

Gemfile specified ruby version takes priority. so it doesn't matter which ruby is currently set in terminal. Remove ruby '1.9.3' line from Gemfile , it will work .

This may be a case where your bundler gem is installed in ruby 2.0.0

Can you add '$rbenv which bundle' and '$ gem env' results

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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