Automating running scripts with user ruby

I’ve hit this twice now this week when trying to automate running ruby scripts, once for setting up a cloud-init file, and just now when setting up a cron job. This is of course because I’m executing the scripts as my user account and because ruby is tied to my user account as it was installed with ruby-install and chruby. I of course could of used a “system” installed ruby, but that is a discussion for another day, I really just wanted these scripts to run as me.

The root issue is that your .bashrc file is returning early due to these lines that check if it is running “interactively” or not. So you can comment them out (lines 6-9):

   1 # executed by bash(1) for non-login shells.
   2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
   3 # for examples
   4  
   5 # If not running interactively, don't do anything
   6 #case $- in
   7 #    *i*) ;;
   8 #      *) return;;
   9 #esac