返回
Ruby开发者:MacOS High Sierra升级后报错的解决方案
前端
2023-11-16 15:36:16
Ruby 开发者,注意了!
随着 MacOS High Sierra 的推出,一些 Ruby 开发者遇到了一个令人头疼的问题。在升级系统后,使用 SASS 预编译器时出现了 Ruby 报错。
问题
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin17/rbconfig.rb:139: warning: failed to load universal driver: dlopen(/usr/local/opt/gcc/lib/gcc/10/gcc/x86_64-apple-darwin17.7.0/10.2.1/libgomp.1.dylib, 262): image not found - /usr/local/opt/gcc/lib/gcc/10/gcc/x86_64-apple-darwin17.7.0/10.2.1/libgomp.1.dylib
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin17/rbconfig.rb:139: warning: failed to load universal driver: dlopen(/usr/local/opt/gcc/lib/gcc/10/gcc/x86_64-apple-darwin17.7.0/10.2.1/libatomic.1.dylib, 262): image not found - /usr/local/opt/gcc/lib/gcc/10/gcc/x86_64-apple-darwin17.7.0/10.2.1/libatomic.1.dylib
解决方案:
这个问题的原因在于 High Sierra 默认安装了新版本的 GCC,导致 Ruby 无法正确加载必要的库。解决方法如下:
- 安装 Command Line Tools: 打开终端并运行以下命令:
xcode-select --install
- 更新系统版本: 安装 Command Line Tools 后,运行以下命令更新系统:
sudo softwareupdate -i -a
-
重新安装 XCode: 在 App Store 中重新安装 XCode 以获取最新的版本。
-
检查系统信息: 重启系统后,打开终端并运行以下命令检查 GCC 版本:
gcc --version
版本号应该为 10.2.0 或更高。
- 更新 Homebrew: 如果您使用 Homebrew,请运行以下命令更新它:
brew update
- 重新安装 SASS: 重新安装 SASS 以获取兼容新 GCC 版本的版本:
gem install sass
- 重启终端: 重新启动终端以使更改生效。
提示:
- 如果您仍然遇到问题,请尝试重新启动 Mac。
- 如果您已尝试以上步骤但问题仍然存在,请联系 Apple 支持或在 Ruby 社区论坛中寻求帮助。
通过遵循这些步骤,您应该能够解决 MacOS High Sierra 升级后 Ruby 出现的报错问题。祝大家代码无忧,开发顺利!