Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Gems with MacRuby

How do you use gems from a MacRuby .5 application on Snow Leopard? Do I need to specify the gem path? If so, how do I do this?

Best scenario is to package the gems inside the application so the user would not have to install them when the app is distributed.

like image 776
Craig Williams Avatar asked Oct 17 '09 20:10

Craig Williams


People also ask

How do I install gems?

To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs.

Where are gems installed Mac?

By default, binaries installed by gem will be placed into: /usr/local/lib/ruby/gems/3.1. 0/bin You may want to add this to your PATH.

What is GEM Mac?

The interface for RubyGems is a command-line tool called gem which can install and manage libraries (the gems). RubyGems integrates with Ruby run-time loader to help find and load installed gems from standardized library folders.


2 Answers

To use gems in a MacRuby project you need to use:

$ sudo macgem install gem_name

Not all gems are compatible with MacRuby, yet.

like image 112
Craig Williams Avatar answered Oct 11 '22 04:10

Craig Williams


Yehuda Katz gem bundler is a very good option IMHO:

http://github.com/wycats/bundler

Anyway, there are many other options such as creating a vendor/ directory in your app bundle adding each vendor subdir to the ruby library search path in rb_main.rb:

$:.unshift File.join(File.dirname(__FILE__), 'vendor/rest-client/lib')
$:.unshift File.join(File.dirname(__FILE__), 'vendor/crack/lib')
require 'rest-client'
require 'crack'

I'm using the latter approach here:

http://github.com/rubiojr/canasto

like image 33
rubiojr Avatar answered Oct 11 '22 05:10

rubiojr