You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Ruby 3(RVM环境)执行脚本时遭遇LoadError问题

Ruby脚本require activesupport时触发LoadError(gem已安装)

Ruby脚本执行require 'activesupport'时出现LoadError,但各类检查均确认该gem已成功安装,无论使用bundle exec还是rvm do执行脚本,错误均一致。

命令输出

$ cat Gemfile | grep activesupport
gem 'activesupport'

$ bundle show activesupport
/Users/2b-software-mac/.rvm/gems/ruby-3.1.2/gems/activesupport-7.0.6

$ bundle exec ruby my_ruby_script.rb
Can I find the gem?
#<Bundler::StubSpecification name=activesupport version=7.0.6 platform=ruby>
Can I require the gem?
my_ruby_script.rb:4:in `require': cannot load such file -- activesupport (LoadError)
    from my_ruby_script.rb:4:in `<main>'

脚本内容

puts 'Can I find the gem?'
puts Gem::Specification.find_all{ |g| g.name.include? 'activesupport' }
puts 'Can I require the gem?'
require 'activesupport'

环境版本信息

  • rvm 1.29.12
  • ruby 3.1.2p20
  • gem 3.3.7
  • bundle 2.3.7
  • macOS 13.5.2 (M2)

内容的提问来源于stack exchange,提问作者Dominus.Vobiscum

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 05:46:04