I’ve been writing a lot of utility scripts lately using CocoaDialog and its ruby wrapper to produce nice dialogs and Platypus to package them as simple Mac droplets.
Since the users of the droplets will not have any gems installed, they need to be unpacked and added to your project:
gem unpack NAME
Be sure to do this for all dependencies of the given gem(s). Bundler helps quite a bit in figuring out what those are (e.g. bundle package
), however bundle package
provides you the .gem
files and not the actual ruby scripts, so I use gem unpack
Next, put the unpacked gems within your project, e.g. vendor/gems
and add this to your script:
1 | Dir.glob(File.join(File.dirname(__FILE__), "vendor", "gems", "*", "lib")).each do |lib| |
I do NOT require rubygems in these scripts, however if you will be doing this, or you suspect a gem might be doing this, you’ll want to prepare in advance, with a slight mod to the above:
1 | require 'rubygems' |