Ruby 3.3.3安装Rubygems 2.6.9失败的异常报错求助
问题:Ruby 3.3.3降级Rubygems至2.6.9失败报错
尝试将Rubygems降级至2.6.9版本时失败,系统报错提示:
rubygems 2.6.9 is not supported on 3.3.3. The oldest version supported by this ruby is 3.3.3
当前使用的正是Ruby 3.3.3版本,相关命令及输出如下:
bundle -v # => Bundler version 2.4.22 ruby -v # => ruby 3.3.3 (2024-06-12 revision f1c7b6f435) [x86_64-linux] gem update --system # => Latest version already installed. Done. gem update --system 2.6.9 # => ERROR: rubygems 2.6.9 is not supported on 3.3.3. The oldest version supported by this ruby is 3.3.3 type bundle # => bundle is hashed (/home/me/.gem/ruby/3.3.3/bin/bundle) type ruby # => ruby is hashed (/home/me/.rubies/ruby-3.3.3/bin/ruby)
问题原因
- 报错信息表述存在歧义,实际是Ruby 3.3.3不兼容老旧的Rubygems 2.6.9版本,并非你的Ruby版本太旧。Ruby版本越高,对Rubygems的最低版本要求也越高,Rubygems 2.6.9是2017年的旧版本,完全无法适配Ruby 3.3.3。
- 报错中的"The oldest version supported by this ruby is 3.3.3"容易误导,实际指的是Ruby 3.3.3内置的Rubygems版本是它支持的最低兼容版本,而非Ruby版本本身。
解决方法
若必须使用Rubygems 2.6.9
- 降级Ruby版本到与Rubygems 2.6.9兼容的区间,比如Ruby 2.3.x ~ 2.5.x(Rubygems 2.6.9支持的最高Ruby版本为2.5.x),可以通过rbenv、rvm等版本管理工具安装对应Ruby版本。
若无需强制降级Rubygems
- 保持当前的最新版Rubygems即可,Ruby 3.3.3需要搭配适配的高版本Rubygems才能稳定运行。
若项目依赖要求旧版Rubygems
- 检查项目的
Gemfile.lock或依赖文档,确认是否存在版本匹配错误;要么升级项目依赖以适配Ruby 3.3.3,要么为项目创建独立的Ruby环境,安装兼容的Ruby版本来搭配Rubygems 2.6.9。
内容的提问来源于stack exchange,提问作者Jellicle
相关产品推荐
相关产品推荐

