Search code examples
rubyosx-mountain-lion

Load Error on Ruby 1.9.3 Mountain Lion


I am new to Ruby and just installed Ruby 1.9.3. on my Moutnain Lion MacOSx with RVM and Homebrew.

After I installed Ruby, I wrote my first Tutorial Program (with text, textmate and Tincta) and saved it as a file.rb. Now the problem is that i get this error message:

users-MacBook-Pro:~ user$ ruby calc.rb
ruby: No such file or directory -- calc.rb (LoadError)

The brew doctor command gives me this, but I don't even know if this has something to do with the issue:

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

    bashbug
    gcov-4.2
    git
    git-cvsserver
    git-receive-pack
    git-shell
    git-upload-archive
    git-upload-pack
    gitk

Consider amending your PATH so that /usr/local/bin occurs before /usr/bin in your PATH. Warning: Homebrew's sbin was not found in your path. Consider amending your PATH variable so it contains:

/usr/local/sbin

Solution

  • Ruby is complaining that it can't find calc.rb. According to your description, you saved the file as file.rb, and then you tried to run calc.rb. Try ruby file.rb.

    If that doesn't work, verify that ruby is working with

    echo "puts 'hello'" | ruby
    

    It should output hello. Then try running it from a file:

    echo "puts 'hello'" > test.rb
    ruby test.rb