【问题标题】:Mysterious LoadError on installed gem with bundler使用捆绑程序安装的 gem 上的神秘 LoadError
【发布时间】:2015-01-12 22:35:05
【问题描述】:

以下终端会话解释了该问题。我不明白我怎么可能在安装的 gem 上遇到加载错误。

未加载的saithru gem 是我今天安装的,这可能是相关的。我确认它已安装到与我的其他 gem 相同的位置,并且我还尝试重新启动终端应用程序。我在 Mac 上使用 rbenv。但是,我至少有几个星期没有安装新版本的 ruby​​,并且直到现在每天都在使用它,没有任何问题。

感谢您的帮助。

$ gem list | grep sailthru
sailthru (1.1.2)
sailthru-client (4.0.1, 2.0.0)
$ cat Gemfile | grep sailthru
gem 'sailthru'
$ cat Gemfile.lock | grep sailthru
    sailthru (1.1.2)
  sailthru
$ bundle exec thin start
Using rack adapter
/Users/jg/Dropbox/sinatra/app.rb:5:in `require': cannot load such file -- sailthru (LoadError)
$ irb
irb(main):001:0> require 'sailthru'
=> true
irb(main):002:0> 

【问题讨论】:

    标签: ruby bundler rbenv


    【解决方案1】:

    没有需要 sailthru 文件。

    你应该看看project page

    require 'sailthru'

    应该是

    require 'sailthru/client'

    希望这会有所帮助。

    编辑

    刚刚注意到您提供irb 输出的最后一部分。

    sailthru.rb 文件是sailthru-client gem 的一部分。它正在通过irb 工作,因为irb 不是通过bundle exec 加载的。这意味着安装的每个 gem 都可以在 irb 中使用。

    要解决此问题(如果您的应用中需要 sailthru-client gem。将 gem 'sailthru-client' 添加到 gem 文件中。执行 bundle install,然后再次运行 bundle exec

    之后您应该不会看到该错误。记住。 bundle exec 仅使用在您的 Gemfile 中指定的 gem 库。

    【讨论】:

    • 原来我安装的是saithru而不是sealthru-client。只是一个愚蠢的错误。泰。
    猜你喜欢
    • 2019-03-08
    • 1970-01-01
    • 2011-12-11
    • 1970-01-01
    • 2022-11-15
    • 1970-01-01
    • 1970-01-01
    • 2016-01-27
    • 1970-01-01
    相关资源
    最近更新 更多