New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Warning! PATH is not properly set up" when using RVM with tmux #2825

Closed
smaboshe opened this Issue May 4, 2014 · 10 comments

Comments

Projects
None yet
5 participants
@smaboshe

smaboshe commented May 4, 2014

Hello!

I'm learning how to use tmux and am running in to the following issue when working with rvm inside a tmux session. As a note, when I'm not using tmux, rvm works beautifully.

My setup has:

  • rvm 1.25.25 (stable)
  • tmux 1.6
  • Linux 3.8.0-39-generic #57~precise1-Ubuntu SMP Tue Apr 1 20:04:51 UTC 2014 i686 i686 i386 GNU/Linux (Ubuntu Linux 12.04 LTS)

Inside a tmux session, I get the following output:

$ tmux
$ rvm --version
Warning! PATH is not properly set up, '/home/user/.rvm/gems/ruby-2.1.0/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.1.0'.

rvm 1.25.25 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

Using rvm get stable --auto-dotfiles does not work for me.

Is there something else I could try?

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis May 4, 2014

Member

combining responses from http://superuser.com/questions/253786/how-can-i-make-tmux-use-my-default-shell I would say you have to add:

set-option -g default-shell "$SHELL -l"

in ~/.tmux.conf or /etc/tmux.conf

Member

mpapis commented May 4, 2014

combining responses from http://superuser.com/questions/253786/how-can-i-make-tmux-use-my-default-shell I would say you have to add:

set-option -g default-shell "$SHELL -l"

in ~/.tmux.conf or /etc/tmux.conf

@smaboshe

This comment has been minimized.

Show comment
Hide comment
@smaboshe

smaboshe May 4, 2014

Thanks @mpapis.

Using your suggestion, my tmux does not fire up. Instead I get:

$ tmux
[exited]
$

It got me searching in the right direction. I did not realise I could supply configuration options to tmux. Eventually, I came across http://askubuntu.com/questions/296377/how-do-i-change-the-default-shell-used-in-byobu-tmux/296388#296388 which starts to fix my problem.

My ~/.tmux.conf now looks like this:

set -g default-shell /bin/bash
set -g default-command /bin/bash

As a note: I'm guessing that "$SHELL -l" is a way to automatically detect my shell preference. I can't get that to behave right. I'd prefer to use it but have hard-coded the shell preference for now.

Now, RVM does not complain about paths.

Unfortunately, RVM gemsets are not picked up automatically when cding in to a folder with .ruby-version defined.

smaboshe commented May 4, 2014

Thanks @mpapis.

Using your suggestion, my tmux does not fire up. Instead I get:

$ tmux
[exited]
$

It got me searching in the right direction. I did not realise I could supply configuration options to tmux. Eventually, I came across http://askubuntu.com/questions/296377/how-do-i-change-the-default-shell-used-in-byobu-tmux/296388#296388 which starts to fix my problem.

My ~/.tmux.conf now looks like this:

set -g default-shell /bin/bash
set -g default-command /bin/bash

As a note: I'm guessing that "$SHELL -l" is a way to automatically detect my shell preference. I can't get that to behave right. I'd prefer to use it but have hard-coded the shell preference for now.

Now, RVM does not complain about paths.

Unfortunately, RVM gemsets are not picked up automatically when cding in to a folder with .ruby-version defined.

@smaboshe

This comment has been minimized.

Show comment
Hide comment
@smaboshe

smaboshe May 5, 2014

After more searching, I discovered http://unix.stackexchange.com/a/38475 and added the line

case $- in *i*) . ~/.bashrc;; esac

to my ~/.bash_profile.

Now, my ~/.tmux.conf looks like this:

set -g default-command "$SHELL --login"
set -g default-shell $SHELL

This gives me the interactive shell you recommended "$SHELL -i". It also allows RVM gemsets to be automatically selected when a folder has a .ruby-version file.

At this point, RVM is working as expected, although the warning is back:

Warning! PATH is not properly set up, '/home/silumesii/.rvm/gems/ruby-2.1.0/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.1.0'.

smaboshe commented May 5, 2014

After more searching, I discovered http://unix.stackexchange.com/a/38475 and added the line

case $- in *i*) . ~/.bashrc;; esac

to my ~/.bash_profile.

Now, my ~/.tmux.conf looks like this:

set -g default-command "$SHELL --login"
set -g default-shell $SHELL

This gives me the interactive shell you recommended "$SHELL -i". It also allows RVM gemsets to be automatically selected when a folder has a .ruby-version file.

At this point, RVM is working as expected, although the warning is back:

Warning! PATH is not properly set up, '/home/silumesii/.rvm/gems/ruby-2.1.0/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.1.0'.

@smaboshe smaboshe closed this May 5, 2014

@smaboshe smaboshe reopened this May 5, 2014

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis May 5, 2014

Member

can I see (in new tmux session):

echo $GEM_HOME
echo $GEM_PATH
echo $PATH

are you sure you have no PATH= without $PATH in your shell initialization files?

Member

mpapis commented May 5, 2014

can I see (in new tmux session):

echo $GEM_HOME
echo $GEM_PATH
echo $PATH

are you sure you have no PATH= without $PATH in your shell initialization files?

@smaboshe

This comment has been minimized.

Show comment
Hide comment
@smaboshe

smaboshe May 5, 2014

Here is the output of those shell variables from a new tmux session:

$ echo $GEM_HOME
/home/user/.rvm/gems/ruby-2.1.0
$ echo $GEM_PATH
/home/user/.rvm/gems/ruby-2.1.0:/home/user/.rvm/gems/ruby-2.1.0@global
$ echo $PATH
/home/user/bin:/home/user/.rvm/gems/ruby-2.1.0/bin:/home/user/.rvm/gems/ruby-2.1.0@global/bin:/home/user/.rvm/rubies/ruby-2.1.0/bin:[EDITED]:/home/user/.rvm/bin:/home/user/.rvm/bin:[EDITED]/home/user/.rvm/bin:/home/user/.rvm/bin

smaboshe commented May 5, 2014

Here is the output of those shell variables from a new tmux session:

$ echo $GEM_HOME
/home/user/.rvm/gems/ruby-2.1.0
$ echo $GEM_PATH
/home/user/.rvm/gems/ruby-2.1.0:/home/user/.rvm/gems/ruby-2.1.0@global
$ echo $PATH
/home/user/bin:/home/user/.rvm/gems/ruby-2.1.0/bin:/home/user/.rvm/gems/ruby-2.1.0@global/bin:/home/user/.rvm/rubies/ruby-2.1.0/bin:[EDITED]:/home/user/.rvm/bin:/home/user/.rvm/bin:[EDITED]/home/user/.rvm/bin:/home/user/.rvm/bin
@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis May 5, 2014

Member

something adds /home/user/bin to beginning of your PATH after RVM was loaded, check your shell initialization files for that path

Member

mpapis commented May 5, 2014

something adds /home/user/bin to beginning of your PATH after RVM was loaded, check your shell initialization files for that path

@smaboshe

This comment has been minimized.

Show comment
Hide comment
@smaboshe

smaboshe May 6, 2014

Yes, you are right. I managed to find and fix the offending line in my .bash_profile.
Everything is right as rain.

Thank you!

smaboshe commented May 6, 2014

Yes, you are right. I managed to find and fix the offending line in my .bash_profile.
Everything is right as rain.

Thank you!

@smaboshe smaboshe closed this May 6, 2014

@mpapis mpapis removed the feedback needed label May 6, 2014

@pkuczynski pkuczynski added help and removed support labels Oct 7, 2016

@srghma

This comment has been minimized.

Show comment
Hide comment
@srghma

srghma Feb 16, 2017

set -g default-command "$SHELL -l"
set -g default-shell "$SHELL"

didnt work for me, what I do:
start without tmux

$ echo $PATH 
/home/bjorn/.rvm/gems/ruby-2.4.0/bin:/home/bjorn/.rvm/gems/ruby-2.4.0@global/bin:/home/bjorn/.rvm/rubies/ruby-2.4.0/bin:/home/bjorn/.cabal/bin:/usr/local/heroku/bin:/home/bjorn/.node_modules/bin:/home/bjorn/.bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/bjorn/.rvm/bin

$ tmux 
$ tmux show-options -g G def
default-command "/bin/zsh -l"
default-shell "/bin/zsh"
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
$ zsh
$ echo $PATH 
...all great again

My tmux and others dotfiles at that moment

temporal solution: in zshrc
[[ $TMUX != "" ]] && rvm use default > /dev/null 2>&1

srghma commented Feb 16, 2017

set -g default-command "$SHELL -l"
set -g default-shell "$SHELL"

didnt work for me, what I do:
start without tmux

$ echo $PATH 
/home/bjorn/.rvm/gems/ruby-2.4.0/bin:/home/bjorn/.rvm/gems/ruby-2.4.0@global/bin:/home/bjorn/.rvm/rubies/ruby-2.4.0/bin:/home/bjorn/.cabal/bin:/usr/local/heroku/bin:/home/bjorn/.node_modules/bin:/home/bjorn/.bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/bjorn/.rvm/bin

$ tmux 
$ tmux show-options -g G def
default-command "/bin/zsh -l"
default-shell "/bin/zsh"
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
$ zsh
$ echo $PATH 
...all great again

My tmux and others dotfiles at that moment

temporal solution: in zshrc
[[ $TMUX != "" ]] && rvm use default > /dev/null 2>&1

@mpapis

This comment has been minimized.

Show comment
Hide comment
@mpapis

mpapis Feb 19, 2017

Member

@BjornMelgaard if you got a problem please open a new ticket, this one is solved already

Member

mpapis commented Feb 19, 2017

@BjornMelgaard if you got a problem please open a new ticket, this one is solved already

@edslocomb

This comment has been minimized.

Show comment
Hide comment
@edslocomb

edslocomb Mar 10, 2018

I'm seeing the same behavior as @BjornMelgaard .

I won't open a new ticket, though. This looks to me like a tmux issue, not an rvm issue; work around it in your dotfiles until tmux stops necromancing GEM_HOME and GEM_PATH back from the dead when it spawns a login shell.

I use bash, my fix goes in my .bash_profile after loading rvm (Your own setup might load rvm in another file, like .profile or .bashrc... put the fix in there after the load):

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# the fix
if [ -n $TMUX ] && [ 'function' = `type -t rvm` ]; then                                                                                                                                        
    # NOTE: rvm does some hanky-panky with STDERR so it can always shout                                                                                     
    #   its warnings at you, even when you're running the command to fix the                                                                                 
    #   thing it's warning you about.                                                                                                                        
    # We redirect file descriptor 6 here to circumvent this nonsense.                                                                                        
    rvm use default >/dev/null 2>&1 6>&1                                                                                                                     
    cd .                                                                                                                                                     
fi

edslocomb commented Mar 10, 2018

I'm seeing the same behavior as @BjornMelgaard .

I won't open a new ticket, though. This looks to me like a tmux issue, not an rvm issue; work around it in your dotfiles until tmux stops necromancing GEM_HOME and GEM_PATH back from the dead when it spawns a login shell.

I use bash, my fix goes in my .bash_profile after loading rvm (Your own setup might load rvm in another file, like .profile or .bashrc... put the fix in there after the load):

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# the fix
if [ -n $TMUX ] && [ 'function' = `type -t rvm` ]; then                                                                                                                                        
    # NOTE: rvm does some hanky-panky with STDERR so it can always shout                                                                                     
    #   its warnings at you, even when you're running the command to fix the                                                                                 
    #   thing it's warning you about.                                                                                                                        
    # We redirect file descriptor 6 here to circumvent this nonsense.                                                                                        
    rvm use default >/dev/null 2>&1 6>&1                                                                                                                     
    cd .                                                                                                                                                     
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment