views:

74

answers:

1

I'm learning basic game programming using Ruby and Gosu. I've installed Gosu from RubyGems, and it is currently sitting in /usr/local/lib/ruby/gems/1.9.1/gems/.

The full path is /usr/local/lib/ruby/gems/1.9.1/gems/gosu-0.7.24-universal-darwin/.

When I'm working on my game script, I can execute the file just fine using the terminal command ruby game.rb. However, when I'm editing the script in TextMate and try to execute the script using command-R, the standard execution window comes up, but does nothing, save for a spinning progress indicator.

I've changed the owner of gosu-9.7.24-universal-darwin/ to myself and even tried changing the owner of the whole ruby/ directory (/usr/local/lib/ruby/), but to no avail.

I'm using the standard Ruby bundle in TextMate.

Here is the script I'm trying to run, but the same event occurs on any of the example scripts:

require "rubygems"
require "gosu"

class  GameWindow < Gosu::Window
  def initialize
    super(640,360, false)
    self.caption = "Gosu Tutorial Game"
  end

  def update
  end

  def draw
  end

  def button_down(id)
    if id == Gosu::KbEscape
      close
    end
  end
end

window = GameWindow.new
window.show

[Update]
At Greg's suggestion, I installed RVM and set up a gemset for Ruby 1.9.2-p0 and Gosu. I set up TextMate integration but I am still getting the never-ending progress spinner when trying to execute my script in TextMate. The run command in the Ruby bundle of TextMate shows to be thus:

#!/bin/sh

export RUBYLIB="$TM_BUNDLE_SUPPORT/RubyMate${RUBYLIB:+:$RUBYLIB}"

/usr/bin/env ruby -KU -- "$TM_BUNDLE_SUPPORT/RubyMate/run_script.rb"

Perhaps something needs to change here?

[Update 2]
In my "Shell Variables" preference panel in TextMate, TM_RUBY is set to /Users/michael/.rvm/bin/rvm-auto-ruby and PATH is set to /Users/michael/.rvm/gems/ruby-1.9.2-p0@gosu/bin:/Users/michael/.rvm/gems/ruby-1.9.2-p0@global/bin:/Users/michael/.rvm/rubies/ruby-1.9.2-p0/bin:/Users/michael/.rvm/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin.

+1  A: 

TextMate doesn't inherit the same path as command-line apps, so you'll have to tell it where to look.

http://manual.macromates.com/en/shell_commands

For long term sanity, you might want to install RVM, use it to install your Rubies, then do the steps here: http://rvm.beginrescueend.com/integration/textmate/

Greg
I installed RVM, set up a 1.9.2@gosu gemset, set my PATH variable in TextMate, and still the same occurrence of nothing but a progress spinner. Using the 'ruby' command in the shell still works.
Michael
Here's the source of the Ruby.tmbundle 'run' command: http://pastie.org/1237589Does something need to be changed here?
Michael