1

I tried to solve my error by using relative_require, but this also does not seem to work. When I use the word require to run the following code:

APP_ROOT = File.dirname(__FILE__)

require File.join(APP_ROOT, 'lib')
require 'guide'

guide = Guide.new('restaurants.txt')
guide.launch!

I get this error:

/Users/catherinealvarado/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- ./lib (LoadError)
    from /Users/catherinealvarado/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from init.rb:11:in `<main>'

I tried to solve this error by doing gem install netrc && gem install heroku-api shown in the link below, but I get an error stating that I should install libyaml and reinstall ruby. https://github.com/gregburek/heroku-buildpack-toolbelt/issues/5

I then tried to install libyaml and reinstall ruby, but I get more errors. I followed the instructions on the link below:

Please install libyaml and reinstall your ruby

I am new to ruby and I have been stuck on this bug for quite some time. I don't think I have any syntax errors in the file I am trying to load. Any help is greatly appreciated.

Community
  • 1
  • 1
pandasCat
  • 159
  • 2
  • 11

1 Answers1

0

Where is the file located that you're running this from? The root?

If so you, you can just do:

require_relative 'lib/guide'

For me, I'm almost always requiring outside files from my spec director, so my calls look like this:

require_relative '../lib/guide'
Anthony
  • 15,435
  • 4
  • 39
  • 69
  • 1
    I tried to do require_relative 'lib/guide' but I get the error: Catherines-MacBookAir:food_finder catherinealvarado$ ruby init.rb init.rb:11:in `require_relative': cannot load such file -- /Users/catherinealvarado/Desktop/food_finder/lib (LoadError) from init.rb:11:in `
    '
    – pandasCat Jun 26 '14 at 00:12
  • Can you run ls in your terminal and show me the output? – Anthony Jun 26 '14 at 00:15
  • 1
    When I run ls I get the following: – pandasCat Jun 27 '14 at 04:54
  • 1
    Catherines-MacBookAir:food_finder catherinealvarado$ ls init.rb lib [note* inside the lib folder I have guide.rb and restaurant.rb ] – pandasCat Jun 27 '14 at 04:56
  • 1
    Catherines-MacBookAir:lib catherinealvarado$ ls guide.rb restaurant.rb – pandasCat Jun 27 '14 at 04:57
  • 1
    I was able to solve my bug. Thank you all for the suggestions. – pandasCat Jul 17 '14 at 18:00