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

Feature request: rvm get head could check all $PATH items vs rvm default #3212

Closed
e2 opened this issue Dec 18, 2014 · 117 comments
Closed

Feature request: rvm get head could check all $PATH items vs rvm default #3212

e2 opened this issue Dec 18, 2014 · 117 comments

Comments

@e2
Copy link
Contributor

e2 commented Dec 18, 2014

TL;DR - this feature would have saved me lots of time and frustration

Symptoms (which I didn't know how to debug):

  • rvm seemed correctly set up (login shells, zsh, versions, default, updated, rvm as shell function)
  • ruby -v correctly reported 2.1.5
  • rvm list showed 2.1.5 as default (* character) ... but it was not selected as current (no = character)
  • rvm use default fixed things, but new tmux sessions had the same problem
  • rvm get head (or stable) didn't help or even report issues

The cause: I had pasted my path into ~/.zshrc like so:

export PATH="/home/me/.rvm/gems/ruby-2.1.5/bin:/home/me/.rvm/gems/ruby-2.1.5@global/bin:/home/me/.rvm/rubies/ruby-2.1.5/bin:/home/me/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/heroku/bin:/home/me/.local/bin:/home/me/.rvm/bin"

I think this should have caused at least an error because:

  • it should have been strange for RVM to have a path that matched a default, but not have a default actually selected (my system Ruby is 1.9.3).

After browsing through rvm code I finally worked this out just by "bisecting" my zsh config (commenting thing out until it still worked or stopped).

I honestly would have preferred for RVM to have failed with a syntax error (which I could deal with).

But I'm glad I sorted this out, so I'm sharing this.

@mpapis
Copy link
Member

mpapis commented Dec 18, 2014

are you using OMZ? => ohmyzsh/ohmyzsh#1359

@e2
Copy link
Contributor Author

e2 commented Dec 18, 2014

Yes - I'm a bit confused though. I can't see how that's an issue, since I ruined the path myself.

I wish it was clear in the RVM docs how the path should be set up and at what point - then I could at least have a reference to know if the path is correct or not (I can debug shell code).

@mpapis
Copy link
Member

mpapis commented Dec 18, 2014

OMZ does set the PATH, I thought you were hit by the mentioned bug, as for setting default ruby it's documented here: https://rvm.io/rubies/default

the problem with detecting wrongly set PATH is that it would be slowing down all commands

@e2
Copy link
Contributor Author

e2 commented Dec 18, 2014

From what I understand the path looks good: https://github.com/robbyrussell/oh-my-zsh/blob/master/templates/zshrc.zsh-template#L52

I don't mean the docs, I how RVM works internally.

E.g. the docs don't explain the relation between the PATH and how that affects RVM. So I have no idea what a "rvm-compatible" PATH looks like.

I even had no idea that no $GEM_HOME is an error.

the problem with detecting wrongly set PATH is that it would be slowing down all commands

That's why I suggested putting that in rvm get head - since users would run that when they have problems.

@e2
Copy link
Contributor Author

e2 commented Dec 18, 2014

Another idea: maybe the system ruby should be expected to be set explicitly - so rvm list would always show a select Ruby - or show an error. If the system ruby is selected and RVM ruby is called - that's an error. (Could be set just in an environment variable).

@mpapis
Copy link
Member

mpapis commented Dec 18, 2014

that's an idea to restrict the check to list and notes

@e2
Copy link
Contributor Author

e2 commented Dec 18, 2014

E.g. rvm use system could set e.g. $rvm_selected to 'system', and if a RVM ruby is used which doesn't match $rvm_selected, there would be an error.

@e2
Copy link
Contributor Author

e2 commented Dec 18, 2014

I'm a developer, so I ❤️ things like dumped callstacks, core files, exceptions, errors - because they help quickly find the cause. If RVM was crashing instead of "silently not working for unknown reasons", I'd just be sending PRs... ;)

Anyway, don't let this take your focus away from the great work you're doing!

And thanks for RVM! You're TOTALLY AWESOME!

@mpapis
Copy link
Member

mpapis commented Dec 19, 2014

the thing is that RVM only sets the environemnt, ther is no involvment of RVM when executing anything else, when you run ruby or gem there is no RVM involvment already - so it can not be checked if the environment is "properly configured"

when you run RVM commands it could be checked but this check should not be always on, as it would be a slowdown:
it's hard to tell if the environment you are using should be that way or it's a bug, remember it's all in bash - this is more like an asembler of languages, from back in time when mystic notations were daily routine, so for simple actions like iteratng over an array (PATH) and check if it has wrong paths (RVM ruby paths) it would require at least a half screen of code to work reasonably fast but still would be noticable slowdown, it's not how to check it but how big cost on everything else it would have

all that said I have few ideas and will try to add them today

@mpapis
Copy link
Member

mpapis commented Dec 19, 2014

please test it with rvm get head - you should get a warning when RVM is sourced and PATH is set but GEM_HOME is not

@e2
Copy link
Contributor Author

e2 commented Dec 19, 2014

Strange. I didn't get the warning from the commit you made at all.

Here's what happened:

  1. I added the PATH= without $PATH to ~/.zshrc
  2. rvm get head -> red warning about ~/.zshrc and missing $PATH in PATH=
  3. I moved the PATH= to ~/.badpath and put source ~/.badpath in ~/.zshrc
  4. rvm get head -> no warning
  5. but rvm now works ($GEM_HOME ok, rvm list shows current, etc.)

I checked from a virtual console to make sure - I just couldn't trigger the warning from the above commit (instead I got the ~/.zshrc one - and only when PATH= was in ~/.zshrc).

I might have had the zshrc warning during earlier rvm get head commands, but I might have not noticed them (small terminal windows, warning scrolled out of view).

I'm just letting you know, because I couldn't trigger the warning from the above commit (although checking $GEM_HOME would have worked, because previously they were unset when I used the path).

Anyway, it works beautiful. Thank you so much!

Have a great weekend!

@mpapis
Copy link
Member

mpapis commented Dec 19, 2014

and this adds a warning for rvm ... commands, let's hope it's not to slow

@e2
Copy link
Contributor Author

e2 commented Dec 19, 2014

I don't see any performance issues with checking $GEM_HOME.

If $GEM_HOME isn't set, people are using the system ruby, right?

@mpapis
Copy link
Member

mpapis commented Dec 19, 2014

yep it's usually system ruby - or a bug like in your case

@e2
Copy link
Contributor Author

e2 commented Dec 19, 2014

I works great! I'm a very happy RVM user :)

@mpapis mpapis added this to the rvm-1.26 milestone Dec 19, 2014
@mpapis
Copy link
Member

mpapis commented Dec 19, 2014

great, let me know if you hit more problems

@alessandrorubio
Copy link

So what's the solution to avoid Warning: PATH set to RVM ruby but GEM_HOME and/or GEM_PATH not set while using OMZ?

@mpapis
Copy link
Member

mpapis commented Jan 8, 2015

@rubmoa read the whole message and check your shell initialization files, it's out of RVM control.

@maus-
Copy link

maus- commented Jan 15, 2015

I'm seeing this issue as well after installing RVM on a vanilla chef/ubuntu1404 box via vagrant. Using a shell script to provision. No zsh or anything out of the ordinary here.

ubuntu_rvm ()
{
  gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
  curl -L https://get.rvm.io | sudo bash -s stable
  source /etc/profile.d/rvm.sh
  sudo usermod -a -G rvm $(whoami)
  rvm autolibs enable
  rvm install $SYSTEM_RUBY_VERSION --auto-dotfiles
  rvm use $SYSTEM_RUBY_VERSION@$SYSTEM_RUBY_GEMSET --default --create
  ubuntu_log_info "Finished installing RVM!"
}

@jxodwyer
Copy link

@rubmoa If you are using zsh, you can avoid this by adjusting the path in your .zshrc file. Refer to this: http://stackoverflow.com/questions/27784961/received-warning-message-path-set-to-rvm-after-updating-ruby-version-using-rvm

@edk
Copy link

edk commented Jan 27, 2015

Also, if you happen to be be root (from sudo) using rvmsudo can help. It did in my case.

@pkuczynski
Copy link
Member

@Albertc this issue is closed. If you encounter a problem, please open a new issue (you might include reference to this issue if you feel it is somehow connected)

@voltaaage
Copy link

voltaaage commented Oct 27, 2016

@Albertc
#3212 (comment)

@thomas-profitt
Copy link

None of this fixed it for me, here's what did:

(Sorry about the huge title, but there's way too much noise in this issue thread)

Like some others, I had no clobbering of $PATH in my .zshrc, or in my .zlogin, but still saw this warning every time a new shell was created.

~/.zlogin

# Squelch the warning by appending ' > /dev/null 2>&1' here
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" > /dev/null 2>&1

# RVM fixes whatever it considers the problem to be, on its own, in `rvm use`.
# It also prints some junk we don't care about, so we squelch its output in the same way.
rvm use default > /dev/null 2>&1

This is heavy-handed. It squelches all output of those two commands, and relies on rvm use to appease rvm, but it works.

@akbarbin
Copy link

akbarbin commented Feb 8, 2017

I have tried @voltaaage notes but I still not working. I have been wondering that because I upgrade the my ubuntu 14.04 to 16.04. I have Postgres in my ubuntu when I updated it. Thanks.

@andrakis
Copy link

The issue may be closed, but I'm still being directed here by RVM, with no good explanation of what is wrong. I'm using bash, not zsh, so the things to try just don't apply to me.

The error message in RVM directs me here, still (after updating to the latest version.) What's the point of directing people here if there's no solution listed here? Why are you still directing people to a closed issue you don't want them commenting on?

@pkuczynski
Copy link
Member

@andrakis could you please create a new issue and I will then look at it and try to help you. This thread is very cluttered...

@peter-umb
Copy link

Why does RVM direct us to this page? Very unhelpful.

@ChasManRors
Copy link

I started an emacs shell (running bash) and get the error

Warning: PATH set to RVM ruby but GEM_HOME and/or GEM_PATH not set, see:
    https://github.com/rvm/rvm/issues/3212

@denisinla
Copy link

Hey all, I ran into the same issue and after checking my export paths in ~/.zshrc I noticed I was missing $PATH

So then I changed:

export PATH="/Users/displayname"

to this

export PATH="$PATH:/Users/displayname"

Refreshed my shell and issue was solved.

@azzamsa
Copy link

azzamsa commented Apr 14, 2018

@ChasManRors how do you solve it ?

@Albertc
Copy link

Albertc commented Apr 16, 2018

#3212 (comment)

adamliter added a commit to adamliter/emacs.d that referenced this issue Aug 10, 2018
More details can be found here: rvm/rvm#3212

In brief, these environment variables need to be available if I want to
use rvm and rvm gemsets inside a terminal inside a buffer in Emacs.
@LightMan
Copy link

Just in case there is someone else like me suffering now that warning:
I am using RubyMine 2018.2 and there is a bug.
We can wait for the next patch or go to the previous version...

@mvherweg
Copy link

mvherweg commented Sep 18, 2018

Just in case there is someone else like me suffering now that warning:
I am using RubyMine 2018.2 and there is a bug.
We can wait for the next patch or go to the previous version...

You can also install the 2018.3 EAP if you prefer: contains a fix for the issue: https://youtrack.jetbrains.com/issue/RUBY-22254

@rnickmccandless
Copy link

Upgrading RubyMine to 2018.2.4 seem to have fixed the warning on $GEM_HOME issue.

@githubMichaelYang
Copy link

githubMichaelYang commented Apr 8, 2019

i understand this is closed, but AWS Cloud9 still references this link when it it's showing the warning below, when it's actually NOT exactly the same issue:

Warning: PATH set to RVM ruby but GEM_HOME and/or GEM_PATH not set, see:
https://github.com/rvm/rvm/issues/3212

And the reason for that is simply because some env. config are missing the complete path, here is how to fix it:

  1. edit ~/.rvm/environments/default, add /bin so to complete the path:
    export GEM_HOME='/home/ec2-user/.rvm/gems/ruby-2.6.0/bin'
    export GEM_PATH='/home/ec2-user/.rvm/gems/ruby-2.6.0/bin:/home/ec2-user/.rvm/gems/ruby-2.6.0@global/bin'
  2. exit/re-enter shell or reboot
  3. confirm the change:

admin:/environment $ echo $GEM_PATH
/home/ec2-user/.rvm/gems/ruby-2.6.0/bin:/home/ec2-user/.rvm/gems/ruby-2.6.0@global/bin
admin:
/environment $ echo $GEM_HOME
/home/ec2-user/.rvm/gems/ruby-2.6.0/bin
admin:~/environment $ echo $PATH
/home/ec2-user/.rvm/gems/ruby-2.6.0/bin:/home/ec2-user/.rvm/gems/ruby-2.6.0@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.0/bin:/home/ec2-user/.nvm/versions/node/v6.16.0/bin:/usr/local/bin:/bin:/usr/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/home/ec2-user/.rvm/bin

@pkuczynski pkuczynski added this to the rvm-1.27.0-before milestone May 8, 2019
@MyklClason
Copy link

I ran into this issue a few times using AWS Cloud9.

Recently fixed it by reinstalling the ruby version.

@hack-yu
Copy link

hack-yu commented Aug 4, 2019

terminal input -> rvm use default

  1. first input rails(not find rails installed by rvm )

ubuntu:~/environment $ rails
Traceback (most recent call last):
4: from /home/ubuntu/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in <main>' 3: from /home/ubuntu/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in eval'
2: from /home/ubuntu/.rvm/gems/ruby-2.6.3/bin/rails:23:in <main>' 1: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems.rb:302:in activate_bin_path'
/home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem railties (>= 0.a) with executable rails (Gem::GemNotFoundException)

  1. input result

ubuntu:~/environment $ rvm use default
Using /home/ubuntu/.rvm/gems/ruby-2.6.3

ubuntu:~/environment $ rails
Usage:
rails new APP_PATH [options]

Options:
[--skip-namespace], [--no-skip-namespace] # Skip namespace (affects only isolated applications)
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /home/ubuntu/.rvm/rubies/ruby-2.6.3/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
[--skip-yarn], [--no-skip-yarn] # Don't use Yarn for managing JavaScript dependencies
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-M, [--skip-action-mailer], [--no-skip-action-mailer] # Skip Action Mailer files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
[--skip-active-storage], [--no-skip-active-storage] # Skip Active Storage files
-P, [--skip-puma], [--no-skip-puma] # Skip Puma related files
-C, [--skip-action-cable], [--no-skip-action-cable] # Skip Action Cable files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
[--skip-listen], [--no-skip-listen] # Don't generate configuration that depends on the listen gem
[--skip-coffee], [--no-skip-coffee] # Don't use CoffeeScript
-J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
-T, [--skip-test], [--no-skip-test] # Skip test files
[--skip-system-test], [--no-skip-system-test] # Skip system test files
=> Rails 5.2.3 application starting in development
=> Run rails server -h for more startup options
Puma starting in single mode...

  • Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
  • Min threads: 5, max threads: 5
  • Environment: development
  • Listening on tcp://localhost:8080
    Use Ctrl-C to stop
    ^C- Gracefully stopping, waiting for requests to finish
    === puma shutdown: 2019-08-04 20:35:51 +0000 ===
  • Goodbye!
    Exiting

@javierojeda94
Copy link

javierojeda94 commented Oct 2, 2019

I don't know what the hell just happened but rvm suddenly started showing that ugly warning. I had to move my scripts and finally make it work by just appending $PATH at the beginning of the exports.

That is kinda confusing actually because rvm explicitly requested me that a specific gem must be at the beginning of the variable instead of that $PATH.

@ivarec
Copy link

ivarec commented Oct 9, 2019

For anyone arriving here from AWS Cloud9, what solved it for me without side effects was adding the following line to the end of my ~/.bash_profile file:

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

It seems that rvm expects to find itself at the end of PATH (I'm assuming, since this fixes the warning messages issue).

@XanderStrike
Copy link

I deleted the warning from $HOME/.rvm/scripts/rvm since everything seems to work and I couldn't care less.

If you're gonna hardcode a link in an error message, make it a link to an answer. Not a question.

@anand-siva
Copy link

I was struggling with this issue. What I found was that I had an older version of Ruby installed than I needed and it was causing this problem.

I had Ruby 2.6.6 and 3.0.4 installed. This conflict was causing a problem.

I uninstalled 2.6.6 and my problem was solved.

rvm uninstall 2.6.6

@lemin-ou
Copy link

Just in case there is someone else like me suffering now that warning:
I am using RubyMine 2018.2 and there is a bug.
We can wait for the next patch or go to the previous version...

Thank you @LightMan, this was the solution for me.

@ho757uff
Copy link

ho757uff commented Oct 9, 2023

After tinkering around for a full hour :

-Opened ~/.bashrc (your home folder) with nano
-Added those lines at the very bottom of the file

export GEM_HOME="$HOME/.rvm/gems/ruby-3.2.2"
export GEM_PATH="$HOME/.rvm/gems/ruby-3.2.2:$HOME/.rvm/gems/ruby-3.2.2@global"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Make sure you replace "ruby-3.2.2" with your actual 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