IT TIP

"루비 버전이 1.9.3이지만 Gemfile이 2.0.0을 지정했습니다"를 수정하는 방법

itqueen 2020. 10. 27. 23:53
반응형

"루비 버전이 1.9.3이지만 Gemfile이 2.0.0을 지정했습니다"를 수정하는 방법


실행할 때 나는 루비 프로젝트를 생성하지만, bundle update그리고 bundle install그것이 오류를 반환합니다 :

Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

이미지 : http://i.imgur.com/dZMhI11.png?1

내 gemfile은 다음과 같습니다.

ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.0'

group :development do
    gem 'sqlite3', '1.3.8'
end

gem 'sass-rails', '4.0.0'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
    gem 'sdoc', '0.3.20', require: false
end

실행 ruby -v하면 Ruby 1.9.3이 설치되어 있음을 알 수 있지만 Gemfile의 첫 번째 행은 Ruby 2.0.0을 사용하도록 지정합니다.

Ruby 2.0.0을 설치하거나 Gemfile의 첫 번째 줄을 변경하여 Ruby 1.9.3을 지정해야합니다.

Gemfile 샘플 :

source 'https://rubygems.org'
ruby "1.9.3"

gem 'pry'

gem 'pry-nav'

# Use with command-line debugging, but not RubyMine
#gem 'debugger'

gem 'bundler'

bundle install아직 번 들러를 포함하지 않은 새로운 RVM gemset을 시도했을 때 이런 일이 발생한다는 것을 알아 챘습니다 (시스템 루비를 참조하는 시스템 번 들러 설치에서 떨어졌기 때문입니다).

gem install bundler나를 위해 고정 실행 .


이것들 중 어느 것도 나를 위해 일하지 않았지만 마침내 그것을 알아 냈습니다.

spring stop

저는 Spring이라는 것을 사용하여 Rails 환경을 백그라운드에서 실행하는 속도를 유지하는 Rails 4 프로젝트가있었습니다.

Ruby 2.1.1로 Spring을 시작했지만 Gemfile 및 .ruby 버전에서 2.1.2로 업그레이드했습니다. 내 이론은 Spring이 2.1.1에서 계속 실행 되어이 오류를 일으켰다는 것입니다.


Heroku Toolbeltheroku명령을 사용 하거나 더 구체적으로를 사용하는 경우 발생할 수 있습니다 bundle exec heroku. 통화 bundle exec앞에서 제거하여 문제를 해결할 수 있다면 heroku먼저 시도해보십시오. 그렇지 않은 경우 아래 제안 된 내용을 따르십시오.


2017 년 2 월 25 일 업데이트 :
Heroku Toolbelt가 Heroku CLI로 이름이 변경되었습니다 . 업데이트 된 설치 / 제거 지침은 다음 링크를 참조하십시오.
https://devcenter.heroku.com/articles/heroku-cli
https://github.com/heroku/cli

원본 게시물은 아래에 편집되지 않은 상태로 제공됩니다 (기존 지침 용).


공식 사이트에서 Heroku 툴 벨트를 설치 한 경우 :

상단에 /usr/bin/heroku다음과 같은 내용이있을 것입니다.#!/usr/local/heroku/ruby/bin/ruby

실행을 시도 /usr/local/heroku/ruby/bin/ruby -v하고 루비 1.9.3을 출력하는지 확인하십시오.

https://github.com/heroku/toolbelt/issues/53

› heroku --version
heroku-toolbelt/3.26.1 (x86_64-darwin10.8.0) ruby/1.9.3

거기 끝에 지정된 1.9.3을 주목하십시오.

--- OSX에 Heroku CLI를 설치하기 위해이 페이지와 패키지 된 설치 프로그램을 사용 하지 마십시오 .

https://toolbelt.heroku.com/

나열된 기술 세부 사항이 중요하기 때문에 :

heroku 명령 줄 클라이언트가 / usr / local / heroku에 설치되고 / usr / local / heroku / bin이 PATH에 추가됩니다.

이것은 RVM이 다음을 수행하기 때문에 해 롭습니다.

› rvm current
ruby-2.1.1

› heroku --version
heroku-toolbelt/3.26.1 (x86_64-darwin10.8.0) ruby/1.9.3

RVM으로 다른 Ruby 버전을 지정한 경우에도 짜증나는 1.9.3 버전이 있습니다.

Heroku toolbelt 제거

OSX 용 공식 제거 프로그램은 없습니다. 필요하다고 생각되면 여기에 +1을 작성하십시오 : https://github.com/heroku/toolbelt/issues/8

수동으로 제거 (문제가 발생할 경우 백업을 유지하기 위해 휴지통으로 이동) :

mv ~/.heroku ~/.Trash
sudo mv /usr/local/heroku ~/.Trash
sudo mv /usr/bin/heroku ~/.Trash

대신 homebrew로 Heroku 도구 벨트를 설치하십시오.

현재 RVM 버전을 Heroku-toolbelt에 올바르게 연결하기 때문입니다. 운영:

brew install heroku-toolbelt

Heroku toolbelt는 다음 위치에만 설치됩니다.

/usr/local/Cellar/heroku-toolbelt/3.21.4

( brew uninstall heroku-toolbelt원하는 경우 쉽게 제거 할 수도 있습니다 .)

설치 테스트 :

› rvm current
ruby-2.0.0-head@bloggery

› rvm list

rvm rubies

=* ruby-2.0.0-head [ x86_64 ]
   ruby-2.1-head [ x86_64 ]
   ruby-2.1.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

› rvm use ruby-2.1.1
Using /Users/Username/.rvm/gems/ruby-2.1.1

› rvm current
ruby-2.1.1

› heroku --version
heroku-toolbelt/3.26.1 (x86_64-darwin12.0) ruby/2.1.1
You have no installed plugins.

› rvm use ruby-2.0.0-head
Using /Users/Username/.rvm/gems/ruby-2.0.0-head

› heroku --version
heroku-toolbelt/3.26.1 (x86_64-darwin13.4.0) ruby/2.0.0
You have no installed plugins.

Notice it now says 2.0.0 at the end of that last command there. You now run the Heroku client with whatever rvm current ruby version you have specified in RVM.


If you type rvm list and it shows a 2.0 version of Ruby as your current version and you are still getting this error, typing rvm use (ruby version) fixed this issue for me.


"I had the same problem using rbenv, installed via brew.

I couldn't figure it out, tried all of the above, I ended up switching to rvm which solved it."

In response to this post, you have to make sure you run rbenv rehash after you install a ruby version. That seemed to work for me when I ran into the same problem.


If you are using a Ruby version manager like RVM or rbenv, then create, in the top-level directory of your project, a file named .ruby-version containing the version spec'd in your Gemfile, e.g.:

2.0.0

That apparently is the cross-{rbenv,rvm} way of spec'ing the version now.


ruby-switch was removed from ubuntu 14.04 and up. I'll leave this answer for posterity, but you probably need a different solution. Check out "Install ruby 2.0 without ruby-switch?" as well.


If you have you've installed a new version of Ruby but are still getting errors about the Gemfile mismatch, you probably need to use ruby-switch to set the new version of Ruby as your default:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install ruby2.1 ruby2.1-dev
sudo ruby-switch --set ruby2.1
sudo gem install bundler

In my case I used rvm get head to update the RVM version and it worked.


I found that reinstalling RVM did the trick when this error occured, as any other suggestion didn't work.


I had this issue after upgrading Ruby versions via rbenv. I tried the spring stop command that someone mentioned above.

When I ran that I got another message suggesting that I run gem pristine --all

Warning: Running gem pristine --all to regenerate your installed gemspecs will improve the startup performance of Spring.

So I ran that command, and then things went back to normal.


I had the same problem using rbenv, installed via Homebrew.

I couldn't figure it out, tried all of the above, so I ended up switching to RVM which solved it.


I discovered my rake or rails script under the bin directory was using another version of ruby. I compared two rake scripts from two servers (production and development) and it showed me they were using different ruby versions. So I had to update accordingly.

1c1
< #!/usr/bin/env ruby
---
> #!/usr/bin/env ruby1.9.1

Came across this error while using the passenger gem. Since I installed this gem with sudo access, it took a default version of ruby on its own. I believe the reason could be that ruby was installed without sudo access on my system and passenger didn't know the actual version of ruby to be used.

However, installing the gem and its apache module without sudo access fixed the problem.


Suggestion for anybody finding this issue and none of the typical solutions resolve this issue for you, check to see if you have more than one ruby version manager. There are multiple version managers, and some software or install scripts will use different ones. I know of rbenv, rvm, asdf, and at least one other that I don't recall the name of. I had asdf installed by a different tool without realizing it happened and it caused the specified version mismatch.

To check for this execute which ruby and look carefully at the path. If it's not the actual version manager you are expecting, you are suffering from this issue. Simplest fix is to use the one you want, and get rid of the other one. If for some reason you need to keep both, you will probably need to change the order of paths in your shell's .rc file.


I share this tidbit in a moment of great relief after having finally solved a problem that's been haunting me for months.

rails new myapp
//Your Ruby version is 2.1.5, but your Gemfile specified 2.0.0

I tried literally every solution to this problem that I could find on the web and at the end of the day it turns out my problem was caused because I had accidentally installed a Rails app in Users/MyName, and it was reading that Gemfile.

So before you go try the various other solutions offered here, you may want to take a second to confirm that you have not done something similar.


I am running the Windows dev environment.

I just added C:\Ruby22-x64\bin in my path variable before heroku\bin entry.


I had this exact issue - just a few seconds after watching Mac OSX Terminal confirm that Ruby 2.0.0 was successfully installed.

Mac OSX ships with an out-of-date version of Ruby already installed and set as the default Ruby. In order to correct the issue, you can install "JewelryBox", a charming and lovely app that gives you a GUI to view and manage multiple rubies (helpful if you have multiple dev environments on one Mac). You can use it to deselect Mac OSX's default Ruby and select your newly installed Ruby.

참고URL : https://stackoverflow.com/questions/19342044/how-to-fix-your-ruby-version-is-1-9-3-but-your-gemfile-specified-2-0-0

반응형