当我尝试启动 Rails 服务器时,出现以下错误:
$ 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 操作系统 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/[email protected] /cdn-cgi/l/email-protection/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 [email protected] /cdn-cgi/l/email-protection
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/bin/erb
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/bin/gem
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/bin/irb
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/bin/rake
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/bin/rdoc
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/bin/ri
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/bin/ruby
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/include/ruby-2.3.0/ (25 files)
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/lib/libruby.2.3.0.dylib
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/lib/pkgconfig/ruby-2.3.pc
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/lib/ruby/ (1211 files)
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/lib/ (3 other files)
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/share/emacs/ (7 files)
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/2.3.8_1/share/man/ (4 files)
/usr/local/Cellar/[email protected] /cdn-cgi/l/email-protection/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/[email protected] /cdn-cgi/l/email-protection/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 的内容。
我不知道还能尝试什么。
Bundler 如何决定使用哪个版本的 Ruby,以及如何将其配置为使用 rbenv 或我的自制 Ruby 安装?
尝试使用“rvm”怎么样?
rvm install 2.4.2
此命令将安装另一个版本的 ruby,2.4.2
你可以简单地检查你拥有的版本
rvm list
.
之后,运行您想要的版本,如下所示,
rvm <version>
or rvm use <version>
希望对你有帮助!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)