Tscott
Tscott

Reputation: 485

Mac system can't find Ruby file to execute

I'm trying to execute my Ruby file that just prints out a string of text: this is literally the file:

puts "System Initialized"

but I keep getting an error every time I try it.

When I execute it, it looks like this:

My-Mac-mini:event_manager my_name$ ruby lib\event_manager.rb

The error message is as follows:

dyld: Library not loaded: /usr/local/lib/libgmp.10.dylib
 Referenced from: /Users/crystalchoi/.rvm/rubies/ruby-2.1.3/bin/ruby
 Reason: image not found
Trace/BPT trap: 5

I'm pretty new to using a Mac when it comes to programming, and I'm following a tutorial to do this, so I'm not sure what I'm doing wrong.

If anyone can help me decipher this error message and let me know how to correct it or can point me in the right direction, I would be very grateful.

Upvotes: 1

Views: 681

Answers (2)

Jared Beck
Jared Beck

Reputation: 17528

Does the specified library (/usr/local/lib/libgmp.10.dylib) exist?

I just checked and I could not find it at all.

GMP (libgmp) is an optional dependency of ruby. When you installed ruby, it was configured to use GMP, but you don't have the library file (/usr/local/lib/libgmp.10.dylib)

That's OK, you can get GMP ( The GNU Multiple Precision Arithmetic Library) from homebrew.

brew update
brew install gmp

You may need to re-install ruby afterward.

See https://superuser.com/questions/820364/ruby-installation-issues-with-rvm where other people had the same problem.

Advanced

If you're compiling ruby the old school way (./configure && make) then you could try using the --without-gmp config. option.

See https://bugs.ruby-lang.org/issues/8796

Upvotes: 0

the Tin Man
the Tin Man

Reputation: 160551

ruby lib\event_manager.rb

Mac OS, like other *nix-based systems, uses / to separate the path components of files. Only Windows uses \. Instead use:

ruby lib/event_manager.rb

A Ruby tutorial isn't going to help a whole lot unless you understand the *nix command-line so you can move around and execute things, so I'd STRONGLY suggest you learn a lot more about how *nix works. Having developed on Linux for years, I have had to use my command-line knowledge just as much as my programming-language skills daily.

Upvotes: 1

Related Questions