I wanted to learn a little about scraping,
Implemented with reference to Making scraping masters in 20 minutes using Ruby.
“Gem should be installed under vendor/bundle.”
--path vendor/bundle option when installing bundle as instructed.
If you write the code as in the article to main.rb and run main.rb,
training $ ruby main.rb Traceback (most recent call last): 2: from main.rb:2:in `<main>' 1: from /Users/yusaku/.rbenv/versions/2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' /Users/yusaku/.rbenv/versions/2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file --nokogiri (LoadError)
'require': cannot load such file --nokogiri (LoadError).
nokogiri has bundle installed under
training $ ls vendor/bundle/ruby/2.6.0/gems/ byebug-11.1.3 method_source-1.0.0 nokogiri-1.10.10 pry-byebug-3.9.0 coderay-1.1.3 mini_portile2-2.4.0 pry-0.13.1
Looking closely at the contents of the error,
It looks like I’m looking for
I was relieved, but I wasn’t doing bundle exec.
training $ bundle exec ruby main.rb
Now I can run main.rb without any error (require “nokogiri” was done).
bundle exec, it looks like it searched for the gem under the same directory.