Installation hiccup possibly due to recursive .profile call

(happycollision) #1

While installing Discourse using Digital Ocean and 12.04 Ubuntu (64) and following the steps outlined at, I found that switching back to the ‘discourse’ user after installing missing components that rvm told me about would just hang.

So I finally checked out my .profile and here is what I found:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

That second-to-last line of actual code seems to be calling this very file again, causing an infinite loop. I commented it out and was able to log in as ‘discourse’ successfully.

I have no idea if this is somehow just a problem for me, or if others might have a similar issue. Just wanted to let someone know.

(Michael - #2

Yes, that seems like an error in the install guide. It was .bash_profile sourcing your .profile but these instructions make it recursive:

# rvm added shell initialization code to ~/.bash_profile,
# move it to ~/.profile instead
cat ~/.bash_profile >> ~/.profile
rm ~/.bash_profile

I think this bit could/should be deleted, not just because it creates a loop but it also throws away everything that used to be in .profile

@supermathie what was the reason for putting it like this?

(Kane York) #3

Actually, no, it doesn’t throw anything away from .profile, I think – shouldn’t >> be append?

(happycollision) #4

I believe that putting everything into .profile is because rvm won’t be loaded as a function unless .profile is read at login. And, if I am not mistaken, .profile is not read at login if .bash_profile exists.

So I see the necessity (in theory), but I am not familiar enough with bash to suggest a fix.

(Michael Brown) #5

When originally written, the rvm installer added the following line to ~/.bash_profile:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

Nowadays, things have changed and the installer now adds:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

So yes, the instructions now cause .profile to source itself. I was trying to make the install instructions as simple as possible but I made the assumption that the changes RVM made would be stable. I’m fixing that now:

(Michael Brown) #6

This topic was automatically closed after 24 hours. New replies are no longer allowed.