title: `require': cannot load such file -- HTTParty (LoadError)
body: <p>First off I'm a Newbie in regards to Ruby, and I'm following the simple tutorial on <a href="https://www.distilled.net/resources/web-scraping-with-ruby-and-nokogiri-for-beginners/" rel="nofollow noreferrer">https://www.distilled.net/resources/web-scraping-with-ruby-and-nokogiri-for-beginners/</a></p>
  
  <p>I have a <code>test.rb</code> file that contains the following:</p>
  
  <pre><code>require 'rubygems'
  require 'Nokogiri'
  require 'HTTParty'
  require 'Pry'
  require 'csv'
  
  # this is how we request the page we're going to scrape
  page = HTTParty.get('https://newyork.craigslist.org/search/pet?s=0')
  Pry.start(binding)
  </code></pre>
  
  <p>When I try to run the ruby test script, I get the following error:</p>
  
  <pre><code>pjw@ubuntu:~/ruby/test$ ruby test.rb 
  /home/pjw/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- HTTParty (LoadError)
      from /home/pjw/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
      from test.rb:1:in `&lt;main&gt;'
  </code></pre>
  
  <p>I've verified HTTParty works properly by running:</p>
  
  <pre><code>httparty "https://newyork.craigslist.org/search/pet?s=0"
  </code></pre>
  
  <p>The problem seems to be the <code>require</code> statement.  If I mix the order or the required gems, the first one gives the same error as above. I've searched online and can't seem to find what I'm missing...</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/30584455/in-require-cannot-load-such-file-httparty-loaderror">in `require&#39;: cannot load such file -- httparty (LoadError)</a> - (No Answer)</li>
  <li><a href="https://stackoverflow.com/questions/21831880/kernel-require-rb55in-require-cannot-load-such-file-error">kernel_require.rb:55:in `require&#39;: cannot load such file error</a> - (bundle exec ruby test.rb "Could not locate Gemfile or .bundle/ directory")</li>
  <li><a href="https://stackoverflow.com/questions/33678945/unable-to-run-rb-files-on-mac-getting-rbenv-versions-2-2-3-lib-ruby-site-ru">Unable to run .rb files on mac - getting /.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require&#39;</a> - (GEMS already Installed)</li>
  </ul>
  
  <hr>
  
  <pre><code>pjw@ubuntu:~/ruby/test$ lsb_release -a
  No LSB modules are available.
  Distributor ID: Ubuntu
  Description:    Ubuntu 16.04.1 LTS
  Release:    16.04
  Codename:   xenial
  
  pjw@ubuntu:~/ruby/test$ ruby -v
  ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
  
  
  pjw@ubuntu:~/ruby/test$ gem list
  *** LOCAL GEMS ***
  actioncable (5.0.0.1)
  actionmailer (5.0.0.1)
  actionpack (5.0.0.1)
  actionview (5.0.0.1)
  activejob (5.0.0.1)
  activemodel (5.0.0.1)
  activerecord (5.0.0.1)
  activesupport (5.0.0.1)
  addressable (2.5.0)
  arel (7.1.4)
  autoprefixer-rails (6.5.3, 6.5.2, 6.5.1)
  bcrypt (3.1.11)
  bigdecimal (default: 1.2.8)
  bootstrap (4.0.0.alpha5)
  bootstrap-datepicker-rails (1.6.4.1)
  bootstrap-sass (3.3.7)
  builder (3.2.2)
  bundler (1.13.6)
  bundler-unload (1.0.2)
  byebug (9.0.6)
  cancancan (1.15.0)
  coderay (1.1.1)
  coffee-rails (4.2.1)
  coffee-script (2.4.1)
  coffee-script-source (1.10.0)
  commonjs (0.2.7)
  concurrent-ruby (1.0.2)
  connection_pool (2.2.1, 2.2.0)
  dashing-rails (2.5.0)
  debug_inspector (0.0.2)
  devise (4.2.0)
  did_you_mean (1.0.2, 1.0.0)
  erubis (2.7.0)
  execjs (2.7.0)
  executable-hooks (1.3.2)
  ffi (1.9.14)
  figaro (1.1.1)
  gem-wrappers (1.2.7)
  geocoder (1.4.0)
  globalid (0.3.7)
  gravatarify (3.1.1)
  httparty (0.14.0)
  i18n (0.7.0)
  io-console (0.4.6, default: 0.4.5)
  jbuilder (2.6.0)
  jquery-rails (4.2.1)
  json (2.0.2, default: 1.8.3)
  less (2.6.0)
  less-rails (2.8.0)
  listen (3.1.5, 3.0.8)
  loofah (2.0.3)
  mail (2.6.4)
  method_source (0.8.2)
  mime-types (3.1)
  mime-types-data (3.2016.0521)
  mini_portile2 (2.1.0)
  minitest (5.9.1, 5.8.3)
  multi_json (1.12.1)
  multi_xml (0.5.5)
  net-telnet (0.1.1)
  nio4r (1.2.1)
  nokogiri (1.6.8.1)
  orm_adapter (0.5.0)
  power_assert (0.3.1, 0.2.6)
  pry (0.10.4)
  psych (2.1.1, default: 2.0.17)
  public_activity (1.5.0)
  public_suffix (2.0.4)
  puma (3.6.0)
  rack (2.0.1)
  rack-test (0.6.3)
  rails (5.0.0.1)
  rails-dom-testing (2.0.1)
  rails-html-sanitizer (1.0.3)
  rails_serve_static_assets (0.0.5)
  rails_stdout_logging (0.0.5)
  railties (5.0.0.1)
  rake (11.3.0, 10.4.2)
  rb-fsevent (0.9.8)
  rb-inotify (0.9.7)
  rdoc (5.0.0, default: 4.2.1)
  redis (3.3.1)
  responders (2.3.0)
  ruby_dep (1.5.0)
  rubygems-bundler (1.4.4)
  rubygems-update (2.6.8)
  rufus-scheduler (3.2.2)
  rvm (1.11.3.9)
  sass (3.4.22)
  sass-rails (5.0.6)
  simple_calendar (2.2.0)
  simple_form (3.3.1)
  slop (4.4.1, 3.6.0)
  spring (2.0.0)
  spring-watcher-listen (2.0.1)
  sprockets (3.7.0)
  sprockets-rails (3.2.0)
  sqlite3 (1.3.12)
  table_print (1.5.6)
  test-unit (3.2.2, 3.1.5)
  thor (0.19.1)
  thread_safe (0.3.5)
  tilt (2.0.5)
  turbolinks (5.0.1)
  turbolinks-source (5.0.0)
  twitter-bootstrap-rails (3.2.2)
  tzinfo (1.2.2)
  uglifier (3.0.3, 3.0.2)
  warden (1.2.6)
  web-console (3.4.0, 3.3.1)
  websocket-driver (0.6.4)
  websocket-extensions (0.1.2)
  wunderground (1.2.0)
  </code></pre>