How to Use Platypus with Ruby and Gem Dependencies

Platypus is a very cool program that turns scripts (like Perl, Ruby, or Python) into standalone applications for macOS.

I found very little information on how to install Ruby gem dependencies within a Platypus app, so hopefully this post will help.

To install a gem dependency in Platypus, follow these steps:

1. Download the .gem from RubyGems.org.
2. Make a gems/ folder. Put the .gem inside.
3. Using a command-line terminal, cd to just above the gems/ folder.
4. Install the gem locally. This should create a bunch of folders within gems/. At the terminal enter:

export GEM_HOME=$PWD/gems/ gem install –local gems/(gem_name) 5. Create your Platypus app, add the gems/ folder to the list of files to be bundled. 6. Then at the top of your script add:
require 'rubygems'
Gem.use_paths(nil, Gem.path << 'gems/')

This will tell Platypus to look in the gems/ folder for the libraries you need.

Hope this helps!

4 Comments

  1. James

    This:
    gem install –local gems/(gem_name)

    Should actually be this:

    gem install –-local gems/(gem_name)

    • Ah, thank you thank you! The text in the editing box for the post had double hyphens; it was auto-changed. I put “pre” HTML tages around it to mark it as code and fix it.

      Thanks again!

Leave a Reply

Your email address will not be published.