简体   繁体   中英

Ruby version conflicts in “rails c / s” commands

I have installed all the gems in my existing ruby on rails project. But when the time I tried to run the application it always complaining the following.

efuturess-mbp:Actionrev-average-costing efutures$ rails c
Your Ruby version is 2.3.7, but your Gemfile specified 2.3.5
efuturess-mbp:Actionrev-average-costing efutures$ rbenv install 2.3.5
rbenv: /Users/efutures/.rbenv/versions/2.3.5 already exists
continue with installation? (y/N) 

This is my GEM file.

source "https://rubygems.org"

ruby "2.3.5"

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem "RedCloth", "~> 4.2.9"
gem "active_shipping", "~> 1.7"
gem "activerecord-import"
gem "apartment"
gem "carrierwave"
gem "email_validator"
gem "flutie"
gem "googlecharts", "~> 1.6.8"
gem "mini_magick", "~> 3.8.1"
gem "mysql2", "~> 0.3.21"
gem "neat", "~> 2.1.0"
gem "net-ssh"
gem "normalize-rails", "~> 3.0.0"
gem "omniauth-stripe-connect", "~> 2.9"
gem "pikaday-gem"
gem "pothoven-attachment_fu"
gem "prawn"
gem "prawn-table"
gem "puma_worker_killer"
gem "rack-cors", require: "rack/cors"
gem "rack-mini-profiler", "~> 0.10.1"
gem "rack-rewrite", "~> 1.5"
gem "rails", "~> 5.1.5"
gem "recipient_interceptor"
gem "rollbar", "~> 2.12"
gem "simple_form", "~> 3.2"
gem "stripe", "~> 1.41"
gem "sucker_punch"
gem "will_paginate", "~> 3.0.7"
gem "xmlrpc"
gem "bootstrap-sass"
gem "coffee-rails", "~> 4.2"
gem "fog", require: "fog/aws/storage"
gem "fog-aws", "<= 0.1.1", require: false
gem "jbuilder", "~> 2.5"
gem "jquery-rails"
gem "jquery-ui-rails"
gem "memory_profiler"
gem "puma", "~> 3.7"
gem "rails-jquery-autocomplete"
gem "record_tag_helper", "~> 1.0"
gem "sass-rails", "~> 5.0"
gem "therubyracer", platforms: :ruby
gem "uglifier", ">= 1.3.0"

gem "bootstrap-datepicker-rails"
gem "american_date"

I cannot figure out why this is happening like this. If someone can help me to sort out this that would be really helpful.

It's very clear in the error message. Your problem is that your current ruby version is 2.3.7 and your project uses version 2.3.5 , that causes the conflict. You can try adding a file named .ruby-version in your project directory so that rbenv know and auto switch between versions, or suggest you to install one if not that version not yet installed.

# In file .ruby-version
2.3.5

Read more about it here .

This should help you:

echo '2.3.5' > .ruby-version
rbenv rehash
rbenv local 2.3.5
rbenv global 2.3.5
bundle exec rails c

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