3

I'm always having trouble with RVM installs and non-interactive vs. interactive shell sessions. If the session isn't interactive I'm usually getting the command not found error on different programs/functions in the RVM/Ruby toolchain (i.e. gem, rvm, ruby etc.). There are three solutions to the issue I'm aware of:

  • Add/remove some lines from .bashrc for each user. The changes depend on the version of Ubuntu
  • Typing bash --login before working with RVM to get a interactive shell
  • Changing the 'Run command as login shell' option in gnome-terminal

All those solutions aren't exactly what I'm looking for because I have a couple of hosts with different versions of Ubuntu and for some applications the solutions outlined above don't work (i.e. daemonized Chef configuration management suite). As far as I could trace the problem down this is based on the fact that shell scripts in /etc/profile.d are only run if the user logs into a interactive shell session. Which seems not to be the case if a daemonized process runs or if I or an application logs in trough ssh.

What I'm basically searching for is a way to unify all different kinds of shell sessions to execute scripts in /etc/profile.d. Ideally this solution should work for all users that are able to login, and for different versions of Ubuntu (atm in use: 10.4, 11.10). It would also be good if it could be easily be set up using automated scripts or Chef recipes.

As a note: I don't know if not-running scripts in /etc/profile.d is the sole problem I'm facing, I know tough that doing a bash --login usually fixes my issues.

1 Answer 1

1

Your issue is gnome-terminal not using --login for bash by default: https://rvm.io/integration/gnome-terminal/

For scripting with RVM choose one of the methods described here: https://rvm.io/integration/cron/

There is more information on user rc files here: https://rvm.io/support/faq/#shell_login

8
  • In which way does this help? All informations you posted seem to be already mentioned in my question, don't they? Mar 13, 2012 at 21:39
  • the first link shows you how to enable the login shell in gnome-terminal ... I should be more clear about it
    – mpapis
    Mar 13, 2012 at 23:34
  • gnome-terminal doesn't work for processes running on a non-graphical server environment, ssh logins etc. I already knew both links you provided and they don't apply to my problem. The solutions outlined work for one type of login (graphical). I'm updating my question accordingly. Mar 14, 2012 at 0:01
  • @PizzaPill check the man page of ssh => ssh — OpenSSH SSH client (remote login program), as for using RVM in demonized scripts/cron - you should not use login shell there, it's dangerous, check this ticket for whenever: github.com/javan/whenever/issues/216#issuecomment-4336716 .
    – mpapis
    Mar 14, 2012 at 2:31
  • 1
    ok so any terminal (GUI or ssh) should be a login session - it's what you do when open those, so those will make use of interactive RVM. For scripting you should not use interactive RVM loaded ahead (globally via system), there is description on how to use RVM in scripting/cron rvm.beginrescueend.com/integration/cron.
    – mpapis
    Mar 14, 2012 at 3:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .