When attempting to run cron files, and files remotely via SSH there were some issues. My default shell is
zsh and the
rvm setup is pretty standard too. ( Assuming that you already have rvm installed )
From the documentation page there is this note:
There are five startup files that zsh will read commands from:
If ZDOTDIR is not set, then the value of HOME is used; this is the usual case.
/etc/zsh/zprofile file there was a line that did this:
test -f /etc/profile.d/rvm.sh && source /etc/profile.d/rvm.sh
I commented that line out, which is loaded for interactive shells, and moved it instead to
/etc/zsh/zshenv which is loaded for both interactive and non-interactive shells.
This allows us to add the shebang
#!/usr/bin/env ruby to the top of my
.rb files, do a
chmod +x and then run them directly ( eg:
$ ./my-script.rb )
I don’t know if that is the most “proper” way of getting my scripts to work but it seems to work well for me.
For cron jobs ( in the file edited by
crontab -e ) you may want to add something like this as your first line:
That would basically change the default shell for cron jobs. Again, your milage may vary and this probably won’t work on shared hosting platforms.
You can also check your setup to make sure that rvm is installed correctly by typing
rvm info – if it gives you any errors search for solutions and fix them. If that command is not found then you probably need to install rvm again ( or perhaps try logging out and logging in again )