Skip to content
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

Sometimes, CD to a dir with .rvmrc doesn't set the Ruby version or gemset #1351

Closed
elado opened this issue Dec 3, 2012 · 25 comments
Closed
Assignees
Milestone

Comments

@elado
Copy link

elado commented Dec 3, 2012

It happens in several cases.

One of them is when iTerm2 new tab is set to Reuse previous session's directory, a CMD+T will create a new tab with

Using /Users/.../.rvm/gems/ruby-1.9.3-p286 with gemset xxx

But when I run any command, such as rake -T, I get an error that's related to missing gems.

✗ rake -T
... (at master) is not checked out. Please run `bundle install`

But if I run cd .. && cd web, it sets the version and gemset correctly.

rvm list and rvm gemset list show the right version/gemset:

✗ rvm list       

rvm rubies

=* ruby-1.9.3-p286 [ x86_64 ]

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

✗ rvm gemset list

gemsets for ruby-1.9.3-p286 (found in /Users/.../.rvm/gems/ruby-1.9.3-p286)
   (default)
   global
=> xxx
   yyy

Another case is when I use consular, and it fires several tabs in a row, seems like some tabs fail to set the version/gemset, randomly. As if the CD hook is either not loaded or not functioning.

This issue is quite new, it used to work before.

@mpapis
Copy link
Member

mpapis commented Dec 3, 2012

can you gist outputs of the following commands in new tab:

echo $PATH
echo $GEM_HOME
echo $GEM_PATH
gem env
which rake

@richo
Copy link
Member

richo commented Dec 3, 2012

This is an issue (not a bug) with iTerm.

It's spawning a new bash process with it's working directory already set, which of course never calls cd.

You could fix this with something like this in your .bashrc:

[[ "`pwd`" != "$HOME" ]] && [[ -f "./.rvmrc" ]] && cd .

@mpapis
Copy link
Member

mpapis commented Dec 3, 2012

the other issue might be that RVM was already loaded, and every new tab is only loading interactive shell without login, rvm when sourced first time in a dir with ./.rvmrc should try to load it ... in this case my guess is it was not an login shell and rvm was already loaded

@elado
Copy link
Author

elado commented Dec 3, 2012

Env vars (executed from a fresh tab in that directory):

Using /Users/username/.rvm/gems/ruby-1.9.3-p286 with gemset xxx

✗ echo $PATH
/usr/local/heroku/bin:/usr/local/mysql/bin:/Users/username/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/username/.rvm/bin

✗ echo $GEM_HOME
/Users/username/.rvm/gems/ruby-1.9.3-p286@xxx

✗ echo $GEM_PATH
/Users/username/.rvm/gems/ruby-1.9.3-p286@xxx:/Users/username/.rvm/gems/ruby-1.9.3-p286@global

✗ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286) [x86_64-darwin12.2.0]
  - INSTALLATION DIRECTORY: /Users/username/.rvm/gems/ruby-1.9.3-p286
  - RUBY EXECUTABLE: /Users/username/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/username/.rvm/gems/ruby-1.9.3-p286/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/username/.rvm/gems/ruby-1.9.3-p286
     - /Users/username/.rvm/gems/ruby-1.9.3-p286@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-rdoc --no-ri"
     - "update" => "--no-rdoc --no-ri"
  - REMOTE SOURCES:
     - http://rubygems.org/

✗ which rake
/Users/username/.rvm/bin/rake

My .zshrc first line is:

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

Tried to add

[[ "`pwd`" != "$HOME" ]] && [[ -f "./.rvmrc" ]] && cd .

both before and after but it didn't help.

After cd out and in, gem env shows the current gemset:

cd .. && cd web
Using /Users/username/.rvm/gems/ruby-1.9.3-p286 with gemset xxx

✗ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286) [x86_64-darwin12.2.0]
  - INSTALLATION DIRECTORY: /Users/username/.rvm/gems/ruby-1.9.3-p286@xxx
  - RUBY EXECUTABLE: /Users/username/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/username/.rvm/gems/ruby-1.9.3-p286@xxx/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/username/.rvm/gems/ruby-1.9.3-p286@xxx
     - /Users/username/.rvm/gems/ruby-1.9.3-p286@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-rdoc --no-ri"
     - "update" => "--no-rdoc --no-ri"
  - REMOTE SOURCES:
     - http://rubygems.org/

@mpapis
Copy link
Member

mpapis commented Dec 3, 2012

check for PATH= in ~/.zshrc - there are issues with oh-my-zsh ... ohmyzsh/ohmyzsh#1359

@elado
Copy link
Author

elado commented Dec 3, 2012

YES! I changed the first

export PATH=/path/to/something

into

export PATH=$PATH:/path/to/something

in .zshrc and it worked.

Thanks!

@elado elado closed this as completed Dec 3, 2012
@richo
Copy link
Member

richo commented Dec 3, 2012

We should implement rvm doctor which can check for some of these things.

Straight into RVM2 though, since it doesn't rely on any functionality from rvm1

@mpapis
Copy link
Member

mpapis commented Dec 3, 2012

@richo most of this issues can be detected at installation or runtime, we had rvm notes which was supposed to detect some problems and show overall warnings, I had re-factored it to be ran during installation and only new warnings are shown - this should be a good place to add it and maybe we could add an alias for doctor=notes.

@knoopx
Copy link

knoopx commented Dec 18, 2012

It complains with the following, and I guess it should not:

export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/libexec:$PATH # manual builds
export PATH=/usr/local/bin:/usr/local/sbin:$PATH # homebrew
export PATH=~/bin:$PATH # user scripts

@mpapis
Copy link
Member

mpapis commented Dec 18, 2012

@knoopx thx for reporting will fix it with #1394

@gabrielgendleryomtov
Copy link

EDIT: Fixed, sorry if I wasted anybody's time. I changed .bash_profile line 1 to:

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

I got confused by .zshrc but that had nothing to do with it.

/EDIT

Hi, when I run "rvm get stable" I get this warning:

My .zshrc file reads:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

My .bash_profile file reads:

export PATH="$HOME/bin:/Users/gabriel/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin:/Users/gabriel/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/gabriel/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/gabriel/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin"

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

Do you know where I'm going wrong?

@mpapis
Copy link
Member

mpapis commented Aug 31, 2013

yes it is your .bash_profile:

export PATH="$HOME/bin:/Users/gabriel/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin:/Users/gabriel/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/gabriel/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/gabriel/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin"

I would say either remove it or change to:

export PATH="$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin"

@ghost
Copy link

ghost commented Oct 9, 2013

I'm also getting this message when trying "rvm get stable" in Terminal (bash):

$ echo $PATH
/usr/local/bin:/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/ruby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin

A bit lost! Any help would be appreciated - especially in HOW I implement the change (do I literally type into the Terminal or go through and find the file/folder manually??)

@mpapis
Copy link
Member

mpapis commented Oct 9, 2013

@jk47999 this bug was closed for 1.18 and I'm working now on 1.23, please open new bug with the details, please add whole output of rvm --debug get head

@nhattan
Copy link

nhattan commented Jun 12, 2014

YES! I changed the first

export PATH=/path/to/something
into

export PATH=$PATH:/path/to/something
in .bashrc in my Mac home folder and it worked.

Thanks!

@samartioli
Copy link

I declare my path on multiple lines... so this is a false negative for me

export PATH=$JAVA_HOME/bin:
$P4_HOME:
$PATH:\

@yoosan
Copy link

yoosan commented Sep 15, 2015

I will say, if your .zshrc or .bashrc has the PATH format as PATH="$PATH:$HOME/.rvm/bin", just change the format as PATH=$PATH:$HOME/.rvm/bin . Remove the double quote ""

@MarcSteven
Copy link

I tried based on their guidance,but issue was still existing.

@MarcSteven
Copy link

2015-10-26 8 33 18
Cannot solve this issue based on your advice.Puzzled .Looking forward to seeing the good thoughts to deal with issue

@AbhimanyuAryan
Copy link

only adding export PATH =$PATH:"----------------" as suggested by @elado worked for me

@jbshirk
Copy link

jbshirk commented Jan 29, 2018

It's 2018 and I went to update the old ruby to current:

$ ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
$ \curl -sSL https://get.rvm.io | bash -s stable
...
Installing RVM to /Users/joe/.rvm/
...
Installation of RVM in /Users/joe/.rvm/ is almost complete:

 * To start using RVM you need to run `source /Users/joe/.rvm/scripts/rvm`
   in all your open shell windows, in rare cases you need to reopen all shell windows.
/Users/joe/.bash_profile:36:PATH=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/joe/go//bin:/usr/local/go/bin:/Users/joe/Library/Android/sdk/platform-tools:/Users/joe/Library/Android/sdk/tools:/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm:/opt/X11/bin:/usr/local/git/bin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/usr/X11R6/bin:/Users/joe/.local/bin

 * WARNING: Above files contains `PATH=` with no `$PATH` inside, this can break RVM,
   for details check https://github.com/rvm/rvm/issues/1351#issuecomment-10939525
   to avoid this warning prepend `$PATH`.

Which brought me to this issue (dated Dec 2, 2012).

It is not clear to me what, if anything I need to edit. Without modifying anything after running the above, I have this:

$ cat ~/.zshrc

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

and

$ cat ~/.bash_profile

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

##
# Your previous /Users/joe/.bash_profile file was backed up as /Users/joe/.bash_profile.macports-saved_2012-10-21_at_13:46:39
##

# MacPorts Installer addition on 2012-10-21_at_13:46:39: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.


# MacPorts Installer addition on 2012-10-21_at_13:46:39: adding an appropriate MANPATH variable for use with MacPorts.
export MANPATH=/opt/local/share/man:$MANPATH
# Finished adapting your MANPATH environment variable for use with MacPorts.


test -r /sw/bin/init.sh && . /sw/bin/init.sh

# added per: http://evothings.com/doc/build/cordova-install-osx.html
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

export GOPATH="$HOME/go/"
export PATH="$GOPATH/bin:$PATH"

# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
export PATH=$PATH:~/.local/bin
PATH=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/joe/go//bin:/usr/local/go/bin:/Users/joe/Library/Android/sdk/platform-tools:/Users/joe/Library/Android/sdk/tools:/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm:/opt/X11/bin:/usr/local/git/bin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/usr/X11R6/bin:/Users/joe/.local/bin

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

Am I to understand that export PATH in .bash_profile is causing a false positive?
Thanks in advance.

@jbshirk
Copy link

jbshirk commented Jan 29, 2018

Being an impatient risk-taker, I went ahead with

rvm install ruby-2.4.3

and

rvm install ruby-2.5.0

And all went well, so I guess the above can be closed.

@pkuczynski
Copy link
Member

Good to hear :)

@SarvarKh
Copy link

SarvarKh commented Nov 1, 2021

I am running OS X for Apple Silicon - Mac M1, have .zshrc script (not bash), and trying to install RVM following the below instructions to contribute to the open-source project:

  1. Install gpg using Homebrew to verify the integrity of the RVM installer.
    brew install gpg
    brew doctor
    And got Your system is ready to brew. which seems that I successfully added it.

  2. Download the public key for the RVM installer.
    gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
    and I am not getting any error, also seems to be successful.

  3. To install RVM and the latest version of ruby and rails, which is probably a good idea, use the following command.
    \curl -sSL https://get.rvm.io | bash -s stable --autolibs=enable
    which is returning the following with *Warning at the end:

Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: Signature made Fri Jan 15 23:46:22 2021 +05
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/Users/sarvarkhalimov/.rvm/archives/rvm-1.29.12.tgz'
Upgrading the RVM installation in /Users/sarvarkhalimov/.rvm/
    RVM PATH line found in /Users/sarvarkhalimov/.mkshrc /Users/sarvarkhalimov/.profile /Users/sarvarkhalimov/.bashrc /Users/sarvarkhalimov/.zshrc.
    RVM sourcing line found in /Users/sarvarkhalimov/.profile /Users/sarvarkhalimov/.bash_profile /Users/sarvarkhalimov/.zshrc /Users/sarvarkhalimov/.zlogin.
Upgrade of RVM in /Users/sarvarkhalimov/.rvm/ is complete.
/Users/sarvarkhalimov/.bash_profile:2:export PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
/Users/sarvarkhalimov/.bash_profile:5:export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
/Users/sarvarkhalimov/.bash_profile:6:export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
/Users/sarvarkhalimov/.bash_profile:7:export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin

  * WARNING: Above files contains PATH= with no $PATH inside, this can break RVM,
    for details check https://github.com/rvm/rvm/issues/1351#issuecomment-10939525
    to avoid this warning prepend $PATH


Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.

👉  Donate: https://opencollective.com/rvm/donate
  1. As a final step to verify that everything went well.
    type rvm | head -1
    which shall return rvm is a function.
    But, I am getting rvm is a shell function from /Users/sarvarkhalimov/.rvm/scripts/cli

Taken actions to resolve it:

I came across the following solution by @elado back in 2012, and I tried to change my first export PATH export PATH="$PATH:$HOME/.rvm/bin" to export PATH=$PATH:"$PATH:$HOME/.rvm/bin" but I am still getting the same output with same *warning when I run \curl -sSL https://get.rvm.io | bash -s stable --autolibs=enable.

So, could anyone advise how I can resolve the issues (in my view) in steps number 3 and 4?

@mayur-kambariya
Copy link

  1. Right clic Terminal from the Application/Utilities folder, Get Info, tick the "Open using Rosetta" box.
  2. Uninstall Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
rm -rf /opt/homebrew/*
sudo rm -rf /opt/homebrew
  1. Reinstall Homebrew
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Restart terminal
  3. Check Homebrew is working fine: brew doctor
  4. Reinstall openssl: brew install openssl
  5. Install Ruby: rvm install 2.7 Or any version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests