ruby-on-rails - Webpacker 安装给出错误:无法加载此类文件 — ubygems
问题描述
我在 rvm 和 nodejs15 下的 OS X 11.2.3 和 ruby 3.0.1、rails 6.1.3.2 上运行(但我也用 ruby 2.7.2 和 2.5 试过这个,我试过用内置的 ruby 和 macports包括删除每个非系统 ruby 文件并重新安装 ruby 和节点),每次我使用 rails new 或尝试运行命令 rails webpacker:install 时都会出现以下错误。
/Users/TruePath/Documents/Projects/math-site/bin/rails:in `require': 无法加载此类文件 -- ubygems (LoadError)
我尝试过创建没有链轮、没有弹簧的项目,并且我已经检查过 yarn 是正确的版本。我已经包含了当我在下面运行命令时生成的消息。
请帮助我现在花了整整 2 天的时间试图在没有运气的情况下找到它!请注意,不是 nodejs 警告的不稳定版本,因为我浪费了很多时间来撕掉 nodejs 的任何提示并重新安装稳定版本而没有运气。
ruby --verbose bin/rails webpacker:install
/usr/local/rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:49: warning: method redefined; discarding old require_relative
/usr/local/rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:57: warning: method redefined; discarding old load
/usr/local/rvm/gems/ruby-3.0.1/gems/sassc-rails-2.1.2/lib/sassc/rails/functions.rb:7: warning: method redefined; discarding old asset_data_url
/usr/local/rvm/gems/ruby-3.0.1/gems/sprockets-4.0.2/lib/sprockets/sass_processor.rb:274: warning: previous definition of asset_data_url was here
/usr/local/rvm/gems/ruby-3.0.1/gems/sassc-rails-2.1.2/lib/sassc/rails/compressor.rb:7: warning: method redefined; discarding old initialize
/usr/local/rvm/gems/ruby-3.0.1/gems/sprockets-4.0.2/lib/sprockets/sass_compressor.rb:39: warning: previous definition of initialize was here
/usr/local/rvm/gems/ruby-3.0.1/gems/sassc-rails-2.1.2/lib/sassc/rails/compressor.rb:17: warning: method redefined; discarding old call
/usr/local/rvm/gems/ruby-3.0.1/gems/sprockets-4.0.2/lib/sprockets/sass_compressor.rb:49: warning: previous definition of call was here
/usr/local/rvm/gems/ruby-3.0.1/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:23: warning: method redefined; discarding old require
/usr/local/rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:27: warning: previous definition of require was here
Warning: you are using an unstable release of Node.js (v15.14.0). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node
/Users/TruePath/Documents/Projects/math-site/bin/rails:in `require': cannot load such file -- ubygems (LoadError)
解决方案
看来这个错误是由我的 bashrc 设置 RUBYOPT=rubygems 引起的,这似乎导致代码问题的奇怪混合。不知道如何或为什么,但这似乎是问题所在,所以也许这将帮助其他人避免很多痛苦和痛苦,试图自己追赶它。
推荐阅读
- jquery - 遍历 ajax 响应
- .net-core - 如何仅使用 dotnet vstest 运行以前失败的测试
- r - 我想遍历主目录中的子文件夹,抓取两个 tif 并在每对上执行相同的功能
- python - CSV数据结构打印乱码
- eclipse - How to install the RED Robot Framework Editor plug-in manually into Eclipse?
- java - stringWidth it's very slow
- javascript - 发布 TypeScript 编译:未捕获的 SyntaxError:意外的令牌 {
- angular - Routing for components on same page in angular doesn't work
- go - How to read custom types from datastore
- anylogic - How can I connect two agents?