Geektool Ruby script fails to load gems - ruby

I'm trying to use Ruby to write a couple scripts for geektool. However, I've found that geektool can't process
require "some_gem"
Where does geektool execute shell commands? Is it possible to make gems available to to it there, or force the scripts to run in the normal shell environment? Someone attempted to answer this question [here][1].
/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
However, this fails with RVM throwing an error, that it is not an application, and that I must enable login.
I'd really appreciate some help on getting Ruby gems to work in geektool

Related

Running Ruby Script

Can someone help me out?
So I installed Ruby 2.4 on my PC via the RubyInstaller from https://rubyinstaller.org/downloads/. I have Windows 10.
I've used Ruby 2.2 and this 2.4 version seems very different.
When I installed it, it created an MSYS2.exe and it now opens a bash shell.
I've not used a bash shell in a very long time (14+ years). I can navigate fine in it. But I receive the following error message when I try to run a ruby file:
$ ruby r1.rb
bash: ruby: command not found
I'm not sure how to run a ruby script on the bash shell from MSYS. I have added the C:\Ruby24-x64\bin to my environment variables. But I still get the same message.
I'd appreciate some assistance if possible. Thanks.

Cygwin - can't run ruby command

When I run ruby -v in cygwin, it shows me the ruby which I have installed in windows. FYI - I never installed any ruby as a part of my cygwin installation.
But when I run gem list, I get the error:
/cygdrive/c/ruby/bin/gem:
C:/dev/ruby/bin/ruby.exe^M: bad interpreter: Permission denied
I Googled and found this problem a lot. But there is no one who explained what it means and why it happens. Can someone please answer those questions for me and help me to fix this problem?
Thank you very much !
Under cygwin, your best bet is to run the cygwin version of ruby, installed using the cygwin setup tool.
You can use regular ruby, but you will have interoperability issues like this.
What you are seeing here is the shell complaining about a ^M at the end of the "shebang" line of the gem script (first line that tells it what interpreter to use). This ^M is an artefact of the windows environment where all lines end with this character as well as just the newline character that unix uses on its own.
You could solve this problem by removing the newlines e.g. by using dos2unix command on gem but it won't be long before you run into further issues ...

How can I use rvm within a Makefile?

Working on this project: https://github.com/cucumber/bool
There's a makefile to construct the various items, and I'd like to use RVM to be able to switch between rubies for the stuff within the ruby directory, however, when I give the makefile commands to switch rubies, I get a nasty error
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
Of course, it works just fine if I issue rvm use 1.9.3 on the command line, so this is a symptom of something else, but I'm not sure what.
When you call RVM from cron (or a Makefile, I would expect) it's important to set up the right environment. The Scout team have a great blog article explaining this:
http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production
The important part is ensuring you have a full login shell so you have access to RVM.
/bin/bash -l -c 'the_command_inside_makefile"
This seems like a good use for an RVM wrapper script, which will let you generate a shell script which loads a given RVM ruby instance into that environment without using the normal, interactive RVM setup.
For example:
rvm wrapper 1.9.3#bool ruby bool
... will create a wrapped script called 'bool' with a given Ruby selected.

What is the purpose of the RVM binary if it can be run as a function?

I've recently started using Ruby and was told to look into using RVM. I'm currently trying to understand how it operates but as far as I can tell from the website it can be run either as a binary or as a function in the shell by modifying .bash_profile.
What are the binaries for? I noticed they got installed to ~/bin, which felt sort of messy, and they did not seem to be invoked when using the rvm command. Are the binaries even needed when running RVM as a shell function?
It is normal and desirable for users of unix to put binaries in ~/bin (you would normally add that to your $PATH), so don't feel like it's messy to install stuff there.
That said, ~/bin/rvm is a script that will let you run rvm commands (like install), but is unable to edit your shell's environment (like all programs). Commands that need to edit the environment (like use), would not be possible without the rvm function. Not being super familiar with rvm, I am guessing the ~/bin/rvm exists for people that don't want to include the rvm stuff in all their shells. AFAICT, you don't need any of the stuff rvm puts in ~/bin if you are going to alter your ~/.bashrc as recommended.

The command "ruby" does nothing on my Mac

I can't get the Ruby interpreter to run on either of my Macs (one MacBook and one MacBook Pro, both running Snow Leopard). When I run it, by typing ruby in Terminal, nothing happens. It just sits there. I can kill it by pressing Ctrl+C, but that's it. I know the Ruby process is running, since I can see it in Activity Monitor, and running ruby --version works fine.
I have tried the following, all to no avail:
I have some bash customizations, so I tried disabling them, but that didn't help.
I installed a new copy of Ruby 1.8.7 using MacPorts, but that one had the same problem.
I tried quitting and restarting the Terminal application.
Some other information that might be useful:
I'm trying to run the version of Ruby that comes with Snow Leopard.
I have installed Apple's developer tools.
Other interpreters (Python, Io, etc.) work fine.
I spent a while tonight searching for this problem online, but haven't found any discussion of it. I'm at a loss for what could be causing it, so any help anybody can provide would be greatly appreciated.
Ruby command itself will just behave the way you said, either provide it with script file or use the -e option:
ruby -e ' puts "hello world" '
However I suspect that you want the IRB(interactive ruby). Run irb in your shell.
What are you trying to do, exactly? The ruby command expects input, in most cases a file that contains Ruby code that you want it to run. In that case you have to specify the name of the file:
> ruby my_ruby_file.rb
If instead you want to run the interactive Ruby shell, i.e. the REPL console that you can type Ruby code into and have it executed each time you press enter, the command you want is irb.

Resources