RVM PATH & Version Confusion

Hi folks.

Can someone show me how to properly set up my RVM path? I keep getting this while RVM seems to be set up properly. I’m pointing to 2.2.1 yet it barfs on 2.0.0 for some reason:

Warning! PATH is not properly set up, '/Users/rich/.rvm/gems/ruby-2.2.1/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.2.1’.

I’ve done that and the last line in my .bash_profile is this:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm”

In fact I only have 2.2.1 installed, so I have no clue why it’s looking for 2.0.0:

HQ:rubies rich$ gem update
/Users/rich/.rvm/gems/ruby-2.2.1/gems/psych-2.0.13/lib/psych.bundle: [BUG] Segmentation fault
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

Any help appreciated.

Cheers

I’ve done that and the last line in my .bash_profile is this:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm”

Does ~/.rvm/scripts/rvm exist?

If yes: Is there anything else that is executed after your ~/.bash_profile has
been sourced, e.g., in ~/.bashrc?

In fact I only have 2.2.1 installed, so I have no clue why it’s looking for
2.0.0:

HQ:rubies rich$ gem update
/Users/rich/.rvm/gems/ruby-2.2.1/gems/psych-2.0.13/lib/psych.bundle: [BUG]
Segmentation fault ruby 2.0.0p481 (2014-05-08 revision 45883)
[universal.x86_64-darwin14]

Because, I guess, your system ruby (v2.0.0) is actually used (see: ruby --
version), and I would further guess that it is because it is picked up before
your RVM-installed ruby.

Could you please provide the output of `echo $PATH' and `which ruby'?

      --- Eric

···

On Friday 27 March 2015 13:16:52, Bee.Lists <bee.lists@gmail.com> wrote:

Thanks for the reply.

~/.rvm/scripts/rvm does indeed exist.

~/.bashrc has the single command:

export PATH="$PATH:$HOME/.rvm/bin”

ruby —version => ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]

Here is $PATH:

/Users/rich/.rvm/gems/ruby-2.2.1/bin:/Users/rich/.rvm/gems/ruby-2.2.1@global/bin:/Users/rich/.rvm/rubies/ruby-2.2.1/bin:/Users/rich/.rvm/bin:~/.rvm:/Applications/RF\ Utilities:/Applications/RF\ Utilities/GPSBabel:/usr/local/bin:/usr/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/sbin:/usr/X11/bin:/opt/local/bin:/opt/local/sbin:/bin:/sbin:~/.rvm:/Applications/RF\ Utilities:/Applications/RF\ Utilities/GPSBabel:/usr/local/bin:/usr/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/sbin:/usr/X11/bin:/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/local/git/bin:/usr/local/git/bin

HQ:~ rich$ which ruby
/Users/rich/.rvm/rubies/ruby-2.2.1/bin/ruby

(I’ve since used: rvm use 2.2.1)

···

On Mar 27, 2015, at 1:23 PM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

On Friday 27 March 2015 13:16:52, Bee.Lists <bee.lists@gmail.com> wrote:

I’ve done that and the last line in my .bash_profile is this:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm”

Does ~/.rvm/scripts/rvm exist?

If yes: Is there anything else that is executed after your ~/.bash_profile has
been sourced, e.g., in ~/.bashrc?

In fact I only have 2.2.1 installed, so I have no clue why it’s looking for
2.0.0:

HQ:rubies rich$ gem update
/Users/rich/.rvm/gems/ruby-2.2.1/gems/psych-2.0.13/lib/psych.bundle: [BUG]
Segmentation fault ruby 2.0.0p481 (2014-05-08 revision 45883)
[universal.x86_64-darwin14]

Because, I guess, your system ruby (v2.0.0) is actually used (see: ruby --
version), and I would further guess that it is because it is picked up before
your RVM-installed ruby.

Could you please provide the output of `echo $PATH' and `which ruby'?

Hello,

~/.rvm/scripts/rvm does indeed exist.

Good.

~/.bashrc has the single command:

export PATH="$PATH:$HOME/.rvm/bin”

Hm, that might at least explain the error message. ~/.bashrc and
~/.bash_profile are executed for different shells. See bash(8) and have a look
at "INVOCATION". Also, read this:
<http://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch&gt;\.

However, after a `rvm use', the compilation should actually succeed. Does
`gem' also belong to the RVM ruby version? `which gem' and `gem --version'
should give hints.

Can you post the compile logs of "gem update"?

Cheers,
    Eric

···

On Friday 27 March 2015 13:38:22, Bee.Lists <bee.lists@gmail.com> wrote:

Sorry about the delay. Some emergencies on this side.

Is this for a login shell?

Invoked as an interactive login shell, or with --login

When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

The /etc/profile file:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
  eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
  [ -r /etc/bashrc ] && . /etc/bashrc
fi

test -f /etc/profile.d/rvm.sh && source /etc/profile.d/rvm.sh

There is no ~/.bash_login

The ~/.profile file:

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

But the login would have read .bash_profile because it takes all my aliases and directives. So when I’m asking for IRB, it shouldn’t be looking at 2.0.0 if rvm is set up properly. The new terminals/logins I get are looking to 2.0.0 for some reason, and I get crash reports indicating it’s looking for 2.0.0, including “gem update”.

Not sure where to go with this.

Cheers

···

On Mar 28, 2015, at 5:49 PM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

Hello,

On Friday 27 March 2015 13:38:22, Bee.Lists <bee.lists@gmail.com> wrote:

~/.rvm/scripts/rvm does indeed exist.

Good.

~/.bashrc has the single command:

export PATH="$PATH:$HOME/.rvm/bin”

Hm, that might at least explain the error message. ~/.bashrc and
~/.bash_profile are executed for different shells. See bash(8) and have a look
at "INVOCATION". Also, read this:
<http://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch&gt;\.

However, after a `rvm use', the compilation should actually succeed. Does
`gem' also belong to the RVM ruby version? `which gem' and `gem --version'
should give hints.

Can you post the compile logs of "gem update"?

Cheers,
    Eric

Hey,

Sorry about the delay. Some emergencies on this side.

hope everything went ok.

Is this for a login shell?

Yes, basically:

login shell:: /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profle
interactive shell:: ~/.bashrc

However, adding the stanza to both ~/.bash_profile *and* ~/.bashrc would do
the trick.

  [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

It could also be that your terminal does not start bash, but sh, in which case
only ~/.profile would be parsed.

Be careful: If ~/.bash_profile *and* ~/.profile exist, both are readable, and
the shell is started as /bin/bash, only ~/.bash_profile will be read.

You can check what interpreter is being run (/bin/sh or /bin/bash) by looking
at $SHELL.

I'd check all those files and the $SHELL variable just to make sure.

But the login would have read .bash_profile because it takes all my aliases
and directives. So when I’m asking for IRB, it shouldn’t be looking at
2.0.0 if rvm is set up properly. The new terminals/logins I get are
looking to 2.0.0 for some reason, and I get crash reports indicating it’s
looking for 2.0.0, including “gem update”.

If RVM is loaded correctly, it will set your ruby paths to the default ruby,
whatever that is. You can check that with `rvm list`.

Try also executing `which` on different commands, i.e.

  `which ruby`
  `which gem`
  `which irb`

Perhaps some tool is missing, and thus one from /usr/bin gets picked up.

HTH.

    --- Eric

···

On Thursday 09 April 2015 23:13:26, Bee.Lists <bee.lists@gmail.com> wrote:

> I'd check all those files and the $SHELL variable just to make sure.

/bin/bash

Ok, that looks good.

> login shell:: /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profle
> interactive shell:: ~/.bashrc

OK that’s where the confusion starts. The bash documentation says
/etc/profile first, then takes the first in order, starting with
~/.bash_profile, which I have.

Testing for both login and interactive, I found I have both. Possible? So
~/.bashrc seems to be doing something I’m not wanting.

It is still unclear weather you're using an interactive or a login shell.
Let's check that first:

  [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
  shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'

Next stop: The RVM error message.

I suspekt that your ~/.bashrc is sourcing ~/.bash_profile, or vice versa. It
could therefore be that RVM is sourced twice. Please run:

  grep source ~/.bashrc ~/.bash_profile

  `which ruby`

Used to be outside of the .rvm directory. Now it’s fixed.

> `which gem`

/usr/bin/gem

> `which irb`

/usr/bin/irb

> Perhaps some tool is missing, and thus one from /usr/bin gets picked up.

It seems the latter two are indeed just that in new sessions. Should this
be different?

Yes, it should basically look like this:

[eveith@basileia:~]% rvm list

rvm rubies

=* ruby-2.1.5 [ x86_64 ]
   ruby-2.2.0 [ x86_64 ]

# => - current
# =* - current && default
# * - default

[eveith@basileia:~]% which ruby; which irb; type gem
/home/eveith/.rvm/rubies/ruby-2.1.5/bin/ruby
/home/eveith/.rvm/rubies/ruby-2.1.5/bin/irb
gem is a shell function

This is what I get in a new shell session, without any priour call to RVM. I'm
also running an interactive, but not a login shell.

We should get that PATH-related error message cleared. Check your ~/.bash*
files just as I wrote. If you want, you can upload them on a pastebin/github
gist and let me have a look at it.

Eric, thanks for the continued attention. I appreciate it.

You're welcome!

      --- Eric

···

On Thursday 16 April 2015 17:28:58, you wrote:

I'd check all those files and the $SHELL variable just to make sure.

/bin/bash

Ok, that looks good.

login shell:: /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profle
interactive shell:: ~/.bashrc

OK that’s where the confusion starts. The bash documentation says
/etc/profile first, then takes the first in order, starting with
~/.bash_profile, which I have.

Testing for both login and interactive, I found I have both. Possible? So
~/.bashrc seems to be doing something I’m not wanting.

It is still unclear weather you're using an interactive or a login shell.
Let's check that first:

  [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
  shopt -q login_shell && echo 'Login shell' || echo 'Not login shell’

Yes, that’s what I used. Here’s the output in a current bash session that is looking for 2.0.0:

ich$ [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
Interactive
HQ:~ rich$ shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
Login shell

So Interactive Login shell. I am under the impression that the ~/.bashrc file is not read.

Next stop: The RVM error message.

I suspekt that your ~/.bashrc is sourcing ~/.bash_profile, or vice versa. It
could therefore be that RVM is sourced twice. Please run:

  grep source ~/.bashrc ~/.bash_profile

rich$ grep source ~/.bashrc ~/.bash_profile
/Users/rich/.bashrc:[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
/Users/rich/.bash_profile:alias sourceme="source ~/.bash_profile"
/Users/rich/.bash_profile:[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

So neither are sourcing eachother, but RVM is indeed sourced twice.

  `which ruby`

Used to be outside of the .rvm directory. Now it’s fixed.

  `which gem`

/usr/bin/gem

  `which irb`

/usr/bin/irb

Perhaps some tool is missing, and thus one from /usr/bin gets picked up.

It seems the latter two are indeed just that in new sessions. Should this
be different?

Yes, it should basically look like this:

[eveith@basileia:~]% rvm list

rvm rubies

=* ruby-2.1.5 [ x86_64 ]
  ruby-2.2.0 [ x86_64 ]

# => - current
# =* - current && default
# * - default

[eveith@basileia:~]% which ruby; which irb; type gem
/home/eveith/.rvm/rubies/ruby-2.1.5/bin/ruby
/home/eveith/.rvm/rubies/ruby-2.1.5/bin/irb
gem is a shell function

This is what I get in a new shell session, without any priour call to RVM. I'm
also running an interactive, but not a login shell.

This is what I get, with more references to RVM:

rich$ which ruby; type gem
/Users/rich/.rvm/rubies/ruby-2.2.2/bin/ruby
gem is a function
gem ()
{
    \typeset result;
    ( \typeset rvmrc;
    rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc");
    if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]; then
        rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc");
    fi;
    for rvmrc in "${rvm_rvmrc_files[@]}";
    do
        [[ -s "${rvmrc}" ]] && source "${rvmrc}" || true;
    done;
    unset rvm_rvmrc_files;
    command gem "$@" ) || result=$?;
    hash -r;
    return ${result:-0}
}

We should get that PATH-related error message cleared. Check your ~/.bash*
files just as I wrote. If you want, you can upload them on a pastebin/github
gist and let me have a look at it.

Yes that RVM loading happens twice:

https://gist.github.com/daBee/d7261f1c58c06c2822ac

Eric, thanks for the continued attention. I appreciate it.

You're welcome!

Cheers

Bee

···

On Apr 17, 2015, at 8:14 AM, Eric MSP Veith <eveith@wwweb-library.net> wrote:
On Thursday 16 April 2015 17:28:58, you wrote:

Just as an idea: rename ~/.bashrc. It doesn't seems as if you'd need it
anyways. The additional `export PATH=...` for RVM there looks suspicious.

Afterwards, start with a fresh terminal window and have a look at `rvm list`
as well as `which ruby`. If that looks good, try `which gem`, which should
also return the bash function just as previously. Building an extension
*should* actually succeed, then.

HTH.

      --- Eric

···

On Friday 17 April 2015 12:03:13, Bee.Lists <bee.lists@gmail.com> wrote:

So Interactive Login shell. I am under the impression that the ~/.bashrc
file is not read.

[...]

Yes that RVM loading happens twice:

https://gist.github.com/daBee/d7261f1c58c06c2822ac

OK, .bashrc is renamed .bashrcOLD

Here’s the output of a new terminal:

HQ:~ rich$ rvm list
Warning! PATH is not properly set up, '/Users/rich/.rvm/gems/ruby-2.2.2/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.2.2'.

rvm rubies

   ruby-2.2-head [ x86_64 ]
   ruby-2.2.1 [ x86_64 ]
=* ruby-2.2.2 [ x86_64 ]

# => - current
# =* - current && default
# * - default

HQ:~ rich$ which ruby
/Users/rich/.rvm/rubies/ruby-2.2.2/bin/ruby
HQ:~ rich$ which gem
/usr/bin/gem

I’m still getting errors on gem update

···

On Apr 17, 2015, at 12:33 PM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

On Friday 17 April 2015 12:03:13, Bee.Lists <bee.lists@gmail.com> wrote:

So Interactive Login shell. I am under the impression that the ~/.bashrc
file is not read.

[...]

Yes that RVM loading happens twice:

https://gist.github.com/daBee/d7261f1c58c06c2822ac

Just as an idea: rename ~/.bashrc. It doesn't seems as if you'd need it
anyways. The additional `export PATH=...` for RVM there looks suspicious.

Afterwards, start with a fresh terminal window and have a look at `rvm list`
as well as `which ruby`. If that looks good, try `which gem`, which should
also return the bash function just as previously. Building an extension
*should* actually succeed, then.

HTH.

      --- Eric

Cheers

Bee

In fact, in ~/.bash_profile is also an export PATH=~/.rvm... stanza. That
isn't necessary can as as well be the source of the error message.

      --- Eric

···

On Friday 17 April 2015 18:33:50, Eric MSP Veith <eveith@wwweb-library.net> wrote:

On Friday 17 April 2015 12:03:13, Bee.Lists <bee.lists@gmail.com> wrote:
> So Interactive Login shell. I am under the impression that the ~/.bashrc
> file is not read.
>
> [...]
>
> Yes that RVM loading happens twice:
>
> https://gist.github.com/daBee/d7261f1c58c06c2822ac

Just as an idea: rename ~/.bashrc. It doesn't seems as if you'd need it
anyways. The additional `export PATH=...` for RVM there looks suspicious.

OK, .bashrc is renamed .bashrcOLD

And from the other e-mail I see you also removed the additional "export
PATH=..." lines?

rvm rubies

   ruby-2.2-head [ x86_64 ]
   ruby-2.2.1 [ x86_64 ]
=* ruby-2.2.2 [ x86_64 ]

# => - current
# =* - current && default
# * - default

HQ:~ rich$ which ruby
/Users/rich/.rvm/rubies/ruby-2.2.2/bin/ruby
HQ:~ rich$ which gem
/usr/bin/gem

I’m still getting errors on gem update

Meh. :frowning:

Does it work after "rvm use ruby-2.2.2"?

      --- Eric

···

On Friday 17 April 2015 14:17:42, Bee.Lists <bee.lists@gmail.com> wrote:

All updated, still the following comes up on gem list:

Warning! PATH is not properly set up, '/Users/rich/.rvm/gems/ruby-2.2.2/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.2.2'.

···

On Apr 17, 2015, at 12:51 PM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

In fact, in ~/.bash_profile is also an export PATH=~/.rvm... stanza. That
isn't necessary can as as well be the source of the error message.

Cheers

Bee

And from the other e-mail I see you also removed the additional "export
PATH=..." lines?

Correct.

rvm rubies

  ruby-2.2-head [ x86_64 ]
  ruby-2.2.1 [ x86_64 ]
=* ruby-2.2.2 [ x86_64 ]

# => - current
# =* - current && default
# * - default

HQ:~ rich$ which ruby
/Users/rich/.rvm/rubies/ruby-2.2.2/bin/ruby
HQ:~ rich$ which gem
/usr/bin/gem

I’m still getting errors on gem update

Meh. :frowning:

Does it work after "rvm use ruby-2.2.2"?

Yes. Which is strange because it doesn’t change the ruby version. So I get an error on gem update with 2.2.2, then I say “rvm use 2.2.2” then it works.

Is there a way I can restart all of this? I tried an implode before, but it didn’t change anything.

Cheers

Bee

···

On Apr 17, 2015, at 2:27 PM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

Yes. Which is strange because it doesn’t change the ruby version. So I get
an error on gem update with 2.2.2, then I say “rvm use 2.2.2” then it
works.

Yes, really strange. The only thing I could add would be: Try "rvm use 2.2.2
--default"

Is there a way I can restart all of this? I tried an implode before, but it
didn’t change anything.

Since RVM should be self-contained, deleting ~/.rvm would do the trick. Oh,
and of course removing the RVM-dependend lines from ~/.bash_profile.

Cheers!

      --- Eric

···

On Friday 17 April 2015 14:52:13, Bee.Lists <bee.lists@gmail.com> wrote:

Yes. Which is strange because it doesn’t change the ruby version. So I get
an error on gem update with 2.2.2, then I say “rvm use 2.2.2” then it
works.

Yes, really strange. The only thing I could add would be: Try "rvm use 2.2.2
—default"

That’s what I’ve been using. It gets old quickly. Heh.

Is there a way I can restart all of this? I tried an implode before, but it
didn’t change anything.

Since RVM should be self-contained, deleting ~/.rvm would do the trick. Oh,
and of course removing the RVM-dependend lines from ~/.bash_profile.

OK I erased everything, started new. It seems to be working now.

Thanks for the notes. Seems I am only half mad.

Cheers

Bee

···

On Apr 17, 2015, at 4:28 PM, Eric MSP Veith <eveith@wwweb-library.net> wrote:
On Friday 17 April 2015 14:52:13, Bee.Lists <bee.lists@gmail.com> wrote:

> Yes, really strange. The only thing I could add would be: Try "rvm use
> 2.2.2 —default"

That’s what I’ve been using. It gets old quickly. Heh.

Yeah. :-/

OK I erased everything, started new. It seems to be working now.

Thanks for the notes. Seems I am only half mad.

Depends on your willpower roll. But I guess you gained at least 1d10 instanity
points and 1d5 points corruption. :wink:

Have fun with your working ruby installation!

      --- Eric

···

On Friday 17 April 2015 19:19:41, Bee.Lists <bee.lists@gmail.com> wrote:

Heh, now it won’t let me require ‘mysql2'

Cheers

Bee

···

On Apr 18, 2015, at 11:09 AM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

Depends on your willpower roll. But I guess you gained at least 1d10 instanity
points and 1d5 points corruption. :wink:

Have fun with your working ruby installation!