0

I want to run a Ruby script in Geektool that refreshes every 3 hours (so I set the refresh rate to 10,800 seconds) and the shell command in Geektool has this code in it:

ruby "/file.rb"

The file is located at root for convenience. Problem is, it won't run. I tried different commands, such as:

/Users/userhere/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /file.rb

But it still doesn't work. I don't want it to use my /usr/bin/ruby installation (which, by default, is 1.8.7), I want it to use 1.9.3. So doing: /usr/bin/ruby "/file.rb" won't work for me.

In Terminal, if I run any of those commands they all work (except for the latter, because of dependencies) and my script works fine, but Geektool fails to even execute it. I tried with and without double quotes around the file name, even single quotes don't work.

Any help would be greatly appreciated.

swiftcode
  • 3,039
  • 9
  • 39
  • 64
  • Oh, I tried making my file executable, with `chmod +x /file.rb` (my file has a `#!/usr/bin/env ruby` at the start), and then in Geektool doing this: `/./file.rb`, but it still doesn't work. Terminal works perfectly. – swiftcode Dec 16 '11 at 01:05
  • 1
    Add info to the original question, not as a comment :) – Dave Newton Dec 16 '11 at 01:13

1 Answers1

1

I needed an rvm gemset as well; I created a shell file:

/Users/Dave/.rvm/bin/rvm use 1.9.3-p0 > /dev/null
/Users/Dave/.rvm/rubies/ruby-1.9.3-p0/bin/ruby ~/foo.rb

With that shell file (which happens to reside in a directory off my ~) as the shell command it works fine.

Without the full paths to each command it doesn't work. GeekTool doesn't run your .bash_profile AFAICT. Also not sure that running an rvm Ruby w/o using it would do what you want anyway.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • I executed the first command you gave me and that made 1.9.3 default for `/usr/bin/ruby`, right? If so, it works perfectly via Terminal and all (again), but even with a file path such as this in Geektool: `/Users/foo/.rvm/rubies/ruby-1.9.3-p0/bin/ruby ~/Desktop/foo.rb`, it still won't run. – swiftcode Dec 16 '11 at 01:19
  • @Lovato rvm doesn't do anything to /usr/bin/ruby, that's the point--it points at your home dir's `.rvm` directory of rubies. If that doesn't work, then I have no clue--works perfectly for me. Are you using a gemset? – Dave Newton Dec 16 '11 at 01:28
  • I don't think so - I'm a newbie to Ruby, and I just have a Ruby file that I want to run every 3 hours. I used to do this in Applescript by simply typing `osascript pathtofile.scpt` in Geektool. I thought Geektool allowed me to do this with Ruby files without hassle, but it's proving very frustrating. – swiftcode Dec 16 '11 at 01:35
  • 1
    Did you put what I typed (using your own user name) into a shell file, chmod u+x it, and use that shell command as the geektool shell command? Also, please see my comment under the question and act upon it. – Dave Newton Dec 16 '11 at 01:41