Weird LoadError on a custom ruby ​​stone

I have my own gem and I encounter a really weird LoadError when I set it as a gem and try to require it in irb.

Everything works fine with my rspec checks inside the project folder. This only happens when using it as an actual gem in irb.

The file that throws a LoadError exception in ( /lib/mws/api/order_response.rb) actually exists. I tried to rename the file and update the required file ( /lib/mws.rb). I tried to recreate the file, thinking there might be a permission issue. Nothing works.

If I comment out the require line for this particular file, everything will work. There is nothing special about this file. There are 4 more files, almost identical to it ( *_response.rb).

It seems to me that I'm taking crazy pills. I have to ignore something, but I don’t see it.

Trace:

chris@Samus:~$ irb
1.9.3p194 :001 > require 'mws'
LoadError: cannot load such file -- mws/api/order_response
    from /Users/chris/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /Users/chris/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /Users/chris/.rvm/gems/ruby-1.9.3-p194/gems/mws-0.1.18/lib/mws.rb:14:in `<top (required)>'
    from /Users/chris/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
    from /Users/chris/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
    from /Users/chris/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from (irb):1
    from /Users/chris/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'

Request file ( /lib/mws.rb)

require 'mws/base'
require 'mws/connection'
require 'mws/utility'

require 'mws/api/seller'
require 'mws/api/product'
require 'mws/api/order'
require 'mws/api/report'

require 'mws/api/general_response'
require 'mws/api/product_response'
require 'mws/api/report_response'
require 'mws/api/seller_response'
require 'mws/api/order_response' # <--- the offending line

module MWS
  # @see Base#initialize MWS::Base for instantiation details.
  # @return [Base] returns MWS::Base object.
  def self.new(merchant_id, access_key, secret_key)
    MWS::Base.new(merchant_id, access_key, secret_key)
  end
end

# The below is for documentation generation purposes.

# MWS is a wrapper for the Amazon Marketplace Web Service (MWS) API.
module MWS
  # API handles all the Amazon MWS API specific stuff.
  module API
  end
  # Utilities contains various functions needed throughout MWS. Utilities is a mixin to multiple classes.
  module Utilities
  end
end

File I need ( /lib/mws/api/order_response.rb):

module MWS
  module API

    # Class for parsing Amazon XML responses into managable objects.
    class OrderResponse

      # Include GeneralResponse instance methods as class methods
      extend GeneralResponse

    end
  end
end

And my file structure

enter image description here

+5
source share
2 answers

Can check /Users/chris/.rvm/gems/ruby-1.9.3-p194/gems/mws-0.1.18/lib/mws/apiif the file is there (and does not have unclear permissions).

If this is not the case, you probably forgot to add it to your gemspec.

If it is, try loading / downloading it with an absolute path (for debugging purposes).

+2
source

, , Jeweler . , Jeweler Git gemspec.

Git, Jeweler gemspec rake gemspec.

+4

All Articles