4

I am writing an application for Mac OS X. It is a Cocoa application. Can I check if a specific RubyGem is installed from Cocoa, do I need to use NSTask or should I use the Ruby framework?

What is the best way to check this?

  • 1
    Here's a pretty simple way to do it using Ruby: http://stackoverflow.com/questions/1032114/check-for-ruby-gem-availability – Jon Gauthier Apr 04 '11 at 14:36
  • @Hans thanks, that's already 50% of the answer :) –  Apr 04 '11 at 14:37
  • 1
    I can't see how you'd do it in Cocoa, unless you knew for sure where the user's RubyGems directory was. You could also shell out, I suppose, but if it's possible to use Ruby I think the link I posted is a better solution. – Jon Gauthier Apr 04 '11 at 14:40

1 Answers1

1

Depending what the reason is for checking for the gem, it seems like it might be a good idea to shell out to a script you bundle with your application. Then have that script check for you. That way you can be sure to access the gem environment in a way that is as close as possible (or even identical) to the way the user will.

Using code like what Has Engel posted in that other SO thread looks like a good way to do it once you are out in the shell.

Chris Cherry
  • 28,118
  • 6
  • 68
  • 71