捆绑器使用了错误的Ruby版本 [英] Bundler using wrong Ruby version
问题描述
当我尝试启动Rails服务器时,出现以下错误:
When I try to start my Rails server, I get the following error:
$ bundle exec rails s
Your Ruby version is 2.3.7, but your Gemfile specified ~> 2.3.8
我不明白为什么会这样,因为我同时使用Homebrew和rbenv将Ruby设置为2.3.8.2.3.7是系统的ruby版本.我正在使用Mac OS 10.14.4.
I don't understand why that happens though, since I set Ruby to 2.3.8 both using Homebrew and using rbenv. 2.3.7 is the version of the system's ruby. I am using Mac OS 10.14.4.
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
$ rbenv version
2.3.8 (set by /Users/ceasar/foo/.ruby-version)
$ which -a ruby
/Users/ceasar/.rbenv/shims/ruby
/usr/local/opt/ruby@2.3/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
$ which -a bundle
/Users/ceasar/.rbenv/shims/bundle
/usr/local/bin/bundle
$ /usr/bin/xcodebuild -version
Xcode 10.2
Build version 10E125
$ brew list ruby@2.3
/usr/local/Cellar/ruby@2.3/2.3.8_1/bin/erb
/usr/local/Cellar/ruby@2.3/2.3.8_1/bin/gem
/usr/local/Cellar/ruby@2.3/2.3.8_1/bin/irb
/usr/local/Cellar/ruby@2.3/2.3.8_1/bin/rake
/usr/local/Cellar/ruby@2.3/2.3.8_1/bin/rdoc
/usr/local/Cellar/ruby@2.3/2.3.8_1/bin/ri
/usr/local/Cellar/ruby@2.3/2.3.8_1/bin/ruby
/usr/local/Cellar/ruby@2.3/2.3.8_1/include/ruby-2.3.0/ (25 files)
/usr/local/Cellar/ruby@2.3/2.3.8_1/lib/libruby.2.3.0.dylib
/usr/local/Cellar/ruby@2.3/2.3.8_1/lib/pkgconfig/ruby-2.3.pc
/usr/local/Cellar/ruby@2.3/2.3.8_1/lib/ruby/ (1211 files)
/usr/local/Cellar/ruby@2.3/2.3.8_1/lib/ (3 other files)
/usr/local/Cellar/ruby@2.3/2.3.8_1/share/emacs/ (7 files)
/usr/local/Cellar/ruby@2.3/2.3.8_1/share/man/ (4 files)
/usr/local/Cellar/ruby@2.3/2.3.8_1/share/ri/ (13487 files
$ bundle env | head -n 40
## Environment
```
Bundler 2.0.1
Platforms ruby, x86_64-darwin-18
Ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
Full Path /Users/ceasar/.rbenv/versions/2.3.8/bin/ruby
Config Dir /Users/ceasar/.rbenv/versions/2.3.8/etc
RubyGems 2.5.2.3
Gem Home /Users/ceasar/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0
Gem Path /Users/ceasar/.gem/ruby/2.3.0:/Users/ceasar/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0
User Path /Users/ceasar/.gem/ruby/2.3.0
Bin Dir /Users/ceasar/.rbenv/versions/2.3.8/bin
Tools
Git 2.19.2
RVM not installed
rbenv rbenv 1.1.2
chruby not installed
```
## Bundler Build Metadata
```
Built At 2019-01-04
Git SHA d7ad2192f
Released Version true
```
## Bundler settings
```
build.libv8
Set for the current user (/Users/ceasar/.bundle/config): "--with-system-v8"
build.mysql2
Set for the current user (/Users/ceasar/.bundle/config): "--with-mysql-config=/usr/local/Cellar/mysql@5.7/5.7.24/bin/mysql_config"
path
Set for your local app (/Users/ceasar/Desktop/beacon/.bundle/config): "vendor/bundle"
disable_shared_gems
Set for your local app (/Users/ceasar/Desktop/beacon/.bundle/config): true
```
我在这里没有看到任何让我觉得应该使用2.3.7的东西.
I don't see anything here which would make me think it shouuld be using 2.3.7.
我不确定还能尝试什么.
I'm not sure what else to try.
Bundler如何决定使用哪个版本的Ruby,以及如何配置它以使用rbenv或我的自制Ruby安装?
How does Bundler decide which version of Ruby to use, and how can I configure it to use either rbenv or my homebrew Ruby installation?
推荐答案
如何尝试使用"rvm"?
How about to try to use 'rvm'?
rvm install 2.4.2
此命令将安装另一个版本的ruby 2.4.2
This command will install another version of ruby, 2.4.2
您只需检查所有版本即可
And you can simply check the versions which all you have as
rvm列表
.
在此之后,运行以下所需的版本,
After this, run the version which you wish as the below,
rvm< version>
或 rvm use< version>
希望这对您有帮助!
这篇关于捆绑器使用了错误的Ruby版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!