rubygems / bundler

Manage your Ruby application's gem dependencies
https://bundler.io
MIT License
4.88k stars 1.99k forks source link

LoadError: cannot load such file -- <file_name> #7606

Closed dmytro-sokolianskyi closed 4 years ago

dmytro-sokolianskyi commented 4 years ago

Ubuntu 18 Ruby 2.6.3 $gem -v 2.7.6 bundler -v 2.1.4 Installed using "gem install bundler"

When running "bundle install" in a Ruby project: path from gem which hosting on Github has been added to $LOAD_PATH but then when I open $LOAD_PATH over irb , this path is absent there. And when I try to run app that use this gem it throws an error: LoadError: cannot load such file -- I prepare the examples: "exam" gem on github - https://github.com/dmitriy-sokolyanskiy/exam "check" app that use the gem above - https://github.com/dmitriy-sokolyanskiy/check my@pc:/check$ bundle install / update my@pc:/check$ bundle info exam my@pc:/check$ ruby runner.rb

Traceback (most recent call last):
2: from runner.rb:1:in '<main>'
1: from /usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:92:in 'require'
/usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:92:in **'require': cannot load such file -- exam (LoadError)**

gem which exam

ERROR: Can't find Ruby library file or shared library exam

In irb:

require "exam"
LoadError (cannot load such file -- exam)
2.6.3 :001 > $LOAD_PATH << "/home/geek/.rvm/gems/ruby-2.6.3@check/bundler/gems/exam-90c9b70847c2/lib"
2.6.3 :003 > require "exam"
 => true 

gem env RubyGems Environment:

deivid-rodriguez commented 4 years ago

Hei @dmitriy-sokolyanskiy!

I think the problem is that by using ruby runner.rb you're not telling ruby anywhere to use bundler to setup the dependencies. What you're doing manually inside irb is what bundler/setup does.

So either bundle exec ruby runner.rb or ruby -rbundler/setup runner.rb should get you back on track.

Let me know if that works for you, and please close the ticket if that's the case :)

dmytro-sokolianskyi commented 4 years ago

Hello, @deivid-rodriguez Great. Thanks a lot. Sorry for the false issue.

deivid-rodriguez commented 4 years ago

No problem!