How to completely remove rvm from $PATH? Ruby gemfile specifity error - ruby-on-rails

I know this is a very common question with hundreds of answers and guides however I believe my problem is unique.
After removing rvm and installing Rbenv I now get an error when running rails s or similar commands, the error reads Your Ruby version is 2.6.3, but your Gemfile specified 2.6.4
ruby -v = ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-darwin19]
rails -v = Your Ruby version is 2.6.3, but your Gemfile specified 2.6.4
my $PATH: /Users/EthanMorganClark/.rbenv/shims:/Users/JohnDoe/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/JohnDoe/.rvm/bin
Now I can see .rvm/bin is still there, and it shouldn't. This leads me to believe it could be the source of my ruby version problem.
My process:
I ran rvm implode and then gem uninstall rvm, then I went into .bashrc, .profile and .bash_profile and removed any traces of rvm. (I did the same with zsh, although I currently am using bash)
I also then ran this script found on the second answer, but in the end it also thinks anything rvm related it gone.
edit - I have also deleted the gemfile.lock, bundled and then get the same error.
Any suggestions, links or answers would be much appreciated. Thanks.

Your PATH will be used in-order, so having .rvm/bin at the end shouldn't really affect anything. That being said, figuring out how/where your PATH is modified can definitely be tough if you haven't been keeping your .bashrc/.zshrc/.bash_profile/.zlogin etc organized.
A high level list of things you should do:
find out what shell you're using, bash or zsh, etc
look in all your corresponding rc files for the respective shell for the culprit (try searching all .* files in ~)
use which -a ruby/which -a rails/etc to see which executable is invoked when you call it
check out this answer for a suggested way to manage your ruby & gem environment

Related

Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2 without update Gemfile

When I execute the command:
rails s in my project, the console display the message:
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
I executed the command:
brew upgrade rbenv ruby-build
rbenv install --list
and the version 2.1.2 appears in the list.
Then, I executed the command: rbenv rehash, but appears the same message when I executed the command:
rails s.
In my Gemfile file, is listed the:
ruby '2.1.2'
but I'm not looking replace this value with the previous version.
And if I execute :
rvm use 2.1.2
Is displayed:
Warning! PATH is not properly set up,
'/Users/Jarvis/.rvm/gems/ruby-2.1.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.1.2'. Using /Users/Jarvis/.rvm/gems/ruby-2.1.2 Warning!
Executable 'ruby' missing, something went wrong with this ruby
installation! Warning! Executable 'gem' missing, something went wrong
with this ruby installation! Warning! Executable 'irb' missing,
something went wrong with this ruby installation!
What I'm doing wrong?
RVM and RBenv are actually similar tools. There are no practical reasons to keep them alongside each other in one session (and on one machine most of the time). They both rely on modifying PATH environment variable to get the Ruby and supplementary binaries closer for easy use.
And that's what RVM complains about: PATH is not what it expects to be. That said, RBEnv apparently tampered with it. Since these tools do their best to overtake ruby, gem, irb and stuff, they may very well conflict with each other on occasions.
So, remove one of them. Which one, is up to you. Removing RVM is as easy as:
rvm implode
...that will remove RVM's files, rubies and gems for them, but you might also want to inspect .bash_profile, .profile and .bashrc for relevant lines.
The uninstallation process for RBEnv seems to be the manual one: remove the folder, review the files listed above for relevant lines.

Error when executing rvm rubygems latest

I'm adding ruby 1.9.2 to a Mac running 10.6.8 and hitting a problem with rvm rubygems latest. I've run the following with no problem:
$ rvm install 1.9.2
$ rvm use 1.9.2
$ ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
Then hit this error:
$ rvm rubygems latest
Removing old Rubygems files...
Installing rubygems-1.8.10 for system ...
ERROR: Error running 'GEM_PATH=":#global" GEM_HOME="" "/usr/local/rvm/rubies//bin/ruby" "/usr/local/rvm/src/rubygems-1.8.10/setup.rb"', please read /usr/local/rvm/log/system/rubygems.install.log
WARN: Installation of rubygems did not complete successfully.
ln: /usr/local/rvm/rubies//lib/ruby/gems/: No such file or directory
The obvious thing here is the extra forward-slash in the bin/ruby and lib/ruby paths. Any ideas where this is coming from and how to fix it?
Note that I've also got the following line at the end of my .bash_profile file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
I'm doing all of this so that I can run Octopress. I've also got a Rails 2.3.8 project that I am developing on this same machine. This is the first time I've dealt with anything other then the system version of ruby (1.8.7).
I've had the same problem, and although I didn't really fully understood why it was happening, attacking the main symptom solved it for me.
It seems that you have already another version of ruby installed on your system. The line on the rvm rubygems script that generates the error is this:
__rvm_run "rubygems.install" \
"GEM_PATH=\"$GEM_PATH:${GEM_PATH%%#*}#global\" GEM_HOME=\"$GEM_HOME\" \"${rvm_ruby_binary}\" \"${rvm_src_path}/$rvm_gem_package_name/setup.rb\"" \
"Installing $rvm_gem_package_name for ${rvm_ruby_string} ..."
https://github.com/wayneeseguin/rvm/blob/master/scripts/rubygems#L104
I think that internally rvm is losing itself and creating paths with the double slash on it, probably because RVM is appending the RVM local dir with the output of some command similar to which ruby (or whatever the path rvm is searching for may be). I really don't know why it does that (doesn't RVM work in a system with ruby installed?).
Anyhow, to fix that in my machine I simply ran sudo aptitude purge ruby (you would of course run the MAC equivalent of that), to remove the ruby version that was messing with rvm.
If you have something related with ruby installed on your computer, I think a good idea would be to remove them all, and use RVM to manage all your ruby related goodness.
On linux (debian/ubuntu), a good approach is typing dpkg -l | grep ruby to see which packages related to ruby are installed on your machine, and then purge them all.
After that, run
$ rvm use 1.9.2
$ rvm rubygems latest
Everything should work like a charm. At least uninstalling ruby worked for me.
Hope it helps.
I just ran rvm default which allowed everything to work properly. I fields is right that rvm hasn't set something completely or at all. This has actually fixed this problem for me consistently.

I have too many versions of Ruby and Rails

I have both ruby and rails installed in:
/usr/local/bin/ruby
/usr/bin/ruby
/usr/local/bin/ruby
This is causing problems when I try to run certains commands like ruby script/console
How do I remove some of these installations of both ruby and rails?
RVM will help you for sure. Check out RVM here
Preventing this kind of situations is the very role of RVM and it's gemsets.
I encourage you to check it out.
There are a few options. First one would be to get your ruby system install in good order. There is no harm in renaming removing those multiple ruby file in your diverse bin folders. Get the stable release of 1.9.2 and gem install whatever you need then. Googling around to fill the gaps you may have here
Quick and dirty you can do:
Get the latest stable release of ruby 1.9.2, compile it on your system, I suppose the ruby that is under /usr/bin is the system's and you are using macosx. The one located in /usr/local/bin is probably something you installed yourself and even maybe you don't even need to reinstall ruby 1.9.2. If that's so get you .bashrc in proper order by making sure /usr/local/bin comes before /usr/bin and you won't have to worry so much about which version you might be using. Create a ~/.bash_profile and put this in.
export PATH="/usr/local/bin:$PATH"
Expected output (more or less):
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin
Others mentioned RVM. I used it, but I don't use it on a production server, I prefer a single sane ruby install to RVM. There is also rbenv and is seems much saner.
Final thought play around in your system remove symlink stuff, set your PATH variable or use RVM/rbenv.
Managing Ruby: Moving From RVM to rbenv
It's time to switch over, http://cantina.co/2011/10/08/managing-ruby-moving-from-rvm-to-rbenv/

no such file to load -- rubygems (LoadError)

I recently installed rails in fedora 12. I'm new to linux as well. Everything works fine on Windows 7. But I'm facing lot of problems in linux. Help please!
I've installed all the essentials to my knowledge to get the basic script/server up and running. I have this error from boot.rb popping up when I try script/server. Some of the details I'd like to give here:
The directories where rails, ruby and gem are installed,
[vineeth#localhost my_app]$ which ruby
/usr/local/bin/ruby
[vineeth#localhost my_app]$ which rails
/usr/bin/rails
[vineeth#localhost my_app]$ which gem
/usr/bin/gem
And when I run the script/server, this is the error.
[vineeth#localhost my_app]$ script/server
./script/../config/boot.rb:9:in `require': no such file to load -- rubygems (LoadError)
from ./script/../config/boot.rb:9
from script/server:2:in `require'
from script/server:2
And the PATH file looks like this
[vineeth#localhost my_app]$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin/ruby:$PATH"
I suppose it is something to do with the PATH file. Let me know what I need to change here. If there are other changes I should make, please let me know.
I have a hunch that you have two ruby versions. Please paste the output of following command:
$ which -a ruby
updated regarding to the comment:
Nuke one version and leave only one. I had same problem with two versions looking at different locations for gems. Had me going crazy for few weeks. Put up a bounty here at SO got me same answer I'm giving to you.
All I did was nuke one installation of ruby and left the one managable via ports. I'd suggest doing this:
Remove ruby version installed via ports (yum or whatever package manager).
Remove ruby version that came with OS (hardcore rm by hand).
Install ruby version from ports with different prefix (/usr instead of /usr/local)
Reinstall rubygems
I had a similar problem on Ubuntu due to having multiple copies of ruby installed. (1.8 and 1.9.1) Unfortunately I need both of them. The solution is to use:
$ sudo update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/ruby1.8 50 auto mode
1 /usr/bin/ruby1.8 50 manual mode
2 /usr/bin/ruby1.9.1 10 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in manual mode.
After doing that bundle install succeeded.
OK, I am a Ruby noob, but I did get this fixed slightly differently than the answers here, so hopefully this helps someone else (tl;dr: I used RVM to switch the system Ruby version to the same one expected by rubygems).
First off, listing all Rubies as mentioned by Eimantas was a great starting point:
> which -a ruby
/opt/local/bin/ruby
/Users/Brian/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
/Users/Brian/.rvm/bin/ruby
/usr/bin/ruby
/opt/local/bin/ruby
The default Ruby instance in use by the system appeared to be 1.8.7:
> ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10]
while the version in use by Rubygems was the 1.9.2 version managed by RVM:
> gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /Users/Brian/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
So that was definitely the issue. I don't actively use Ruby myself (this is simply a dependency of a build system script I'm trying to run) so I didn't care which version was active for other purposes. Since rubygems expected the 1.9.2 that was already managed by RVM, I simply used RVM to switch the system to use the 1.9.2 version as the default:
> rvm use 1.9.2
Using /Users/Brian/.rvm/gems/ruby-1.9.2-p290
> ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.3.0]
After doing that my "no such file" issue went away and my script started working.
I would just like to add that in my case rubygems wasn't installed.
Running sudo apt-get install rubygems solved the issue!
Try starting the project with:
./script/server
instead of script/server if you are using ruby 1.9.2 (from strange inability to require config/boot after upgrading to ruby 1.9.2)
In case anyone else is googling this problem: I was able to fix mine by finding the elusive "rubygems" folder that I wanted to use and adding it to my $RUBYLIB environment variable.
find / -name "rubygems" -print
Once you find it, add the parent directory to your environment. In bash, like so:
export RUBYLIB=/path/to/parent
Now if you run gem, it should pick up the right library directory, and you're off and running.
I had a similar problem, simply running a trivial ruby script that just required the gem i wanted...got that error message. When I changed the incantation from:
ruby test.rb
to
ruby -rubygems test.rb
Seemed to work.
I had a similar problem and solved that by setting up RUBYLIB env.
In my environment I used this:
export RUBYLIB=$ruby_dir/lib/ruby/1.9.1/:$ruby_dir/lib/ruby/1.9.1/i686-linux/:$RUBYLIB
If you have several ruby installed, it might be sufficient just to remove one of them, on MacosX with extra ports install, remove the ports ruby installation with:
sudo port -f uninstall ruby
I also had this issue.
My solution is remove file Gemfile.lock, and install gems again: bundle install
gem install bundler
fixed the issue for me.
This is the first answer when Googling 'require': cannot load such file -- ubygems (LoadError) after Google autocorrected "ubygems" to "rubygems". Turns out this was an intentional change between Ruby 2.4 and 2.5 (Bug #14322). Scripts that detect the user gems directory without taking into account the ruby version will most likely fail.
Ruby 2.4
ruby -rubygems -e 'puts Gem.user_dir'
Ruby 2.5
ruby -rrubygems -e 'puts Gem.user_dir'
I have also met the same problem using rbenv + passenger + nginx. my solution is simply adding these 2 line of code to your nginx config:
passenger_default_user root;
passenger_default_group root;
the detailed answer is here: https://stackoverflow.com/a/15777738/445908
Simply running /bin/bash --login did the trick for me, weirdly. Can't explain it.

Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again (I have rubygems 1.3.6!)

I'm running rails version 2.3.5 and rubygems version 1.3.6, when I script/server I get this error
Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again:http://rubygems.rubyforge.org
any ideas how to fix this?
The first thing you should do is run: gem env
This will output, amongst other things, the RUBYGEMS_VERSION and your GEM_PATHS. Verify that everything you think is true, is indeed true.
In the GEM_PATHS, you will probably see multiple paths, the top most being the primary path.
You can set GEM_HOME to the primary gem directory in the your .bash_login/etc file. Open a new terminal and run gem env again to make sure that it is being picked up.
As Gordon indicated, make sure these GEM paths are in your PATH.
Some other things to think about ownership/permissions. If you use sudo when working with gems on your system, they get installed in a different directory than when you install/update normally.
Perhaps you installed the rubygems using sudo, but rails is not running as root.
Read the installation notes if you still cannot figure it out: ruby gems installation
Maybe it’s not finding your correct gem path. I’ve had similar problems related to that. You might need to update your bash prefs eg in .basrc you might have something like this:
GEMS=/home/me/ruby1.8/lib/ruby/gems/1.8/bin/
export PATH=$RUBY:$GEMS:$HOME/bin:$PATH:$NGINX:$MONIT:$GIT
I just ran into this issue today, and for those of you who do something similar to what I did here is the fix and a little background.
I was installing some dependencies for rmagik, took the easy way out and used macports, it automatically went ahead and updated my default ruby to /opt/... so rubygems went missing since it only intalled ruby.
my advise, use rvm (http://rvm.beginrescueend.com/) like raphael_turtle says, since you will want RVM to be in charge of updating your links to ruby, rubygems and rails.
*Be wary when installing via macports or brew, just make sure you see what else is being installed, and don't accidently overwrite your local configs.
I had the same problem. My installation was done for me by technical support, so it was not me who did the installation (security problems).
The problem was that I didn't have some access rights, so this helped:
sudo - su user_name_with_enough_access_rights
And then run scripts/server again.
I couldn't figure out what was wrong so I installed rvm with a new version of rails and ruby.

Resources