我正在尝试创建一个Rails应用程序,失败如下:
$ rails new blog
Rails 6 requires Ruby 2.5.0 or newer.
You're running:
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Please upgrade to Ruby 2.5.0 or newer to continue.
但是,根据我的系统,我的ruby版本是2.6.3:
$ ruby --version
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
$ which ruby
/Users/flaab/.rbenv/shims/ruby
Rbenv已激活2.6.5。
$ rbenv versions
system
* 2.6.5 (set by /Users/flaab/.ruby-version)
mruby-dev
但它也认识到了错误的一方。
$ which -a ruby
/Users/flaab/.rbenv/shims/ruby
/usr/bin/ruby
我的宝石环境是...
flaab@MBP-de-Arturo ~ $ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.6.5 (2019-10-01 patchlevel 114) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/flaab/.gem
- USER INSTALLATION DIRECTORY: /Users/flaab/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /Users/flaab/.rbenv/versions/2.6.5/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /Users/flaab/.gem/bin
- SPEC CACHE DIRECTORY: /Users/flaab/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/flaab/.rbenv/versions/2.6.5/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/flaab/.gem
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "echo \"gem" => "--no-document\" > ~/.gemrc"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/flaab/.rbenv/versions/2.6.5/bin
- /opt/local/libexec/rbenv
- /Users/flaab/.rbenv/shims
- /usr/local/bin
- /opt/local/bin
- /opt/local/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/flaab/bin
- /Users/flaab/.rbenv/shims
- /sw/bin
- /Users/flaab/.local/lib/npm/bin
- /Users/flaab/.composer/vendor/bin
我怎样才能让gem使用上面提到的ruby 2. 6. 5版本?
先谢了
4条答案
按热度按时间vsdwdz231#
无济于事。抛弃了mac,回到debian上开发。没有问题。
zbsbpyhn2#
运行
rbenv global 2.5.0
设置全局ruby,或者在app目录中创建一个.ruby-version
文件,指示rbenv使用特定版本。echo "2.5.0" >> .ruby-version
,然后重试。文件
cvxl0en23#
您是否已将此添加到
.bash_profile
中?如果没有将以上行添加到文件底部,则关闭并重新启动终端。
EXECUTABLE DIRECTORY
可能设置不正确。请尝试以下命令:此外,确保您位于新的空目录中,并执行以下操作
然后重试rails命令
cld4siwp4#
使用howebrew重新安装,请按照以下步骤操作:
或