louismullie / treat

Natural language processing framework for Ruby.
Other
1.37k stars 128 forks source link

[Rspec Load Error] `require': cannot load such file -- engtagger (LoadError) #87

Closed cbarraford closed 9 years ago

cbarraford commented 9 years ago

I'm seeing a weird issue with treat and rspec.

I have treat installed and ran the ruby command to install the jar files and other dependencies. That succeeded without an issue. I am using the latest stable version of rvm. When i go into irb i can load engtagger no problem.

2.1.3 :001 > require 'pp'
 => true
2.1.3 :002 > pp Gem.path
["/Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev",
 "/Users/cbarraford/.rvm/gems/ruby-2.1.3@global"]
 => ["/Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev", "/Users/cbarraford/.rvm/gems/ruby-2.1.3@global"]
2.1.3 :003 > require 'engtagger'
 => true

And i can load it no issue when I run a ruby script.

#!/usr/bin/env ruby

require 'engtagger'
puts "success!"
bash$ ruby proof.rb
success!

But when i load engtagger (and other treat dependency gems) inside an rspec file, i get a load error.

require 'spec_helper'
require 'pp'
pp Gem.path
require 'engtagger'
[cbarraford@chad-mbp svo]$ rspec spec/proof_spec.rb
fatal: Not a git repository (or any of the parent directories): .git
["/Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev",
 "/Users/cbarraford/.rvm/gems/ruby-2.1.3@global"]
/Users/cbarraford/workshop/svo/spec/proof_spec.rb:6:in `require': cannot load such file -- engtagger (LoadError)
    from /Users/cbarraford/workshop/svo/spec/proof_spec.rb:6:in `<top (required)>'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/configuration.rb:1105:in `load'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/configuration.rb:1105:in `each'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/runner.rb:96:in `setup'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/runner.rb:84:in `run'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/runner.rb:69:in `run'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/runner.rb:37:in `invoke'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/exe/rspec:4:in `<top (required)>'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin/rspec:23:in `load'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin/rspec:23:in `<main>'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin/ruby_executable_hooks:15:in `eval'
    from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin/ruby_executable_hooks:15:in `<main>'

Here is my gem environment info

[cbarraford@chad-mbp svo]$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.3 (2014-09-19 patchlevel 242) [x86_64-darwin13.0]
  - INSTALLATION DIRECTORY: /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev
  - RUBY EXECUTABLE: /Users/cbarraford/.rvm/rubies/ruby-2.1.3/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin
  - SPEC CACHE DIRECTORY: /Users/cbarraford/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-13
  - GEM PATHS:
     - /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev
     - /Users/cbarraford/.rvm/gems/ruby-2.1.3@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://rubygems.org/"]
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin
     - /Users/cbarraford/.rvm/gems/ruby-2.1.3@global/bin
     - /Users/cbarraford/.rvm/rubies/ruby-2.1.3/bin
     - /Users/cbarraford/.rvm/bin
     - /usr/local/heroku/bin
     - /usr/local/bin
     - /usr/local/heroku/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/bin
     - /Users/cbarraford/bin
     - /sbin
     - /usr/sbin
     - /usr/local/lib/luarocks/bin

Has anyone seen this? I'm running the latest version rspec, treat, and ruby.

cbarraford commented 9 years ago

It looks like this may not be a treat specific problem. If i install a random gem,

gem install thor

Rspec can't load that one either.

[cbarraford@chad-mbp svo]$ rspec spec/proof_spec.rb
fatal: Not a git repository (or any of the parent directories): .git
["/Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev",
 "/Users/cbarraford/.rvm/gems/ruby-2.1.3@global"]
/Users/cbarraford/workshop/svo/spec/proof_spec.rb:6:in `require': cannot load such file -- thor (LoadError)
        from /Users/cbarraford/workshop/svo/spec/proof_spec.rb:6:in `<top (required)>'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/configuration.rb:1105:in `load'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/configuration.rb:1105:in `each'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/runner.rb:96:in `setup'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/runner.rb:84:in `run'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/runner.rb:69:in `run'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/lib/rspec/core/runner.rb:37:in `invoke'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/gems/rspec-core-3.1.5/exe/rspec:4:in `<top (required)>'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin/rspec:23:in `load'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin/rspec:23:in `<main>'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin/ruby_executable_hooks:15:in `eval'
        from /Users/cbarraford/.rvm/gems/ruby-2.1.3@svo-dev/bin/ruby_executable_hooks:15:in `<main>'

But if anyone has any ideas on what I can try to fix it, it would be appreciated.

cbarraford commented 9 years ago

Ah ha! The reason why rspec wasn't able to load some gems is because the gem (ie engtagger) wasn't listed in the gemfile. The treat gem was listed, but because engtagger is a dependency of treat and its not listed as dependency in the gemspec file, rspec didn't know that it was going to need it.

Is there a reason why the treat gemspec doesn't list all of the dependencies??

louismullie commented 9 years ago

The reason why we don't list all dependencies is because many of them are C extensions and will fail to install on certain platforms. Another reason is to keep from installing 40 dependencies when a user may only use one or two of them. Therefore, the preferred way is to add these gems to your gemfile.