Trouble on uninstalling RVM - ruby

I am running Ubuntu 10.04 Lucid and I was probably wrong to uninstall RVM and now it seams to be not completely removed from the system. Now I would like to install that again but I am in trouble.
What happens is that I have strange outputs generated when I try to execute some command lines:
# Note that following command lines don't output the version
# (between the word "version" and the word "is") as it should be.
$ rvm
$ rvm -v
> -bash: /usr/local/rvm/scripts/base: No such file or directory
> A RVM version is installed yet 1.10.3 is loaded.
> Please do one of the following:
> * 'rvm reload'
> * open a new shell
# Even if I use the 'cd' command I have problems...
$ cd ..
> -bash: /usr/local/rvm/scripts/initialize: No such file or directory
> -bash: /usr/local/rvm/scripts/hook: No such file or directory
That probably means that RVM is not correctly removed even if Ruby seams to be running as well:
$ which ruby
/usr/local/bin/ruby
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
So, what I can do to completely remove/uninstall RVM?
UPDATE
I solved part of the problem (or, maybe, all problems): that (those) was related to Phusion Passenger that was still loading the old path related to the Ruby version managed by RVM.

first try echo $rvm_path - if that shows anything - rm -rf it
second:
sudo rm -rf /ust/local/rvm /etc/rvmrc /etc/profile.d/rvm.sh ~/.rvm*
next check ls -l /usr/local/bin | grep rvm this will show links to rvm - rm -rf them
and last which rvm - if it shows anything try to check this path and remove at least this file.

RVM installs everything into ~/.rvm. To remove RVM from your system run 'rm -rf ~/.rvm'.
Refer this. and where is everything installed to?

From rvm help:
implode - (seppuku) removes the rvm installation completely.
This means everything in $rvm_path (~/.rvm || /usr/local/rvm).
This does not touch your profiles. However, this means that you
must manually clean up your profiles and remove the lines which source RVM.
Judging from your $PATH you can also (alternatively) remove all of the following files and directories:
/usr/local/rvm
/etc/rvmrc
/etc/profile.d/rvm.sh

Related

ERROR: Missing RVM environment file After Doing rvm upgrade command - Passenger 4.0.23

I was running ruby 2.0.0-p247 on my Mac Mini Server (Mavericks 10.9.1). I read that there was a security vulnerability so I decided to upgrade to use the latest Ruby patch 2.0.0-p353. I did the following commands:
gem update --system (RubyGems 2.1.11)
rvm get stable (RVM 1.25.0)
rvm upgrade 2.0.0-p247 2.0.0-p353 (which should have moved my gemsets)
There is nothing in my system that I can find that references 2.0.0-p247 in rvm which is what I expected. When I go to ~/myuser/.rvm/environments there is no file 2.0.0-p247.
I am now attempting to start passenger. I had version 4.0.23 enterprise installed. I attempted to run rvmsudo passenger-install-apache2-module but got an error.
cd /Users/myuser/.rvm/gems/ruby-2.0.0-p353#mygemset/gems/passenger-enterprise-server-4.0.23
/Users/myuser/.rvm/wrappers/ruby-2.0.0-p353# mygemset/rake apache2:clean apache2 RELEASE=yes
# /Users/myuser/.rvm/wrappers/ruby-2.0.0-p353# mygemset/rake apache2:clean apache2 RELEASE=yes
ERROR: Missing RVM environment file: '/Users/myuser/.rvm/environments/ruby-2.0.0-p247#LightBeCorp_Rails4Ruby2'
Here are statements in my .bashrc file related to rvm if this will help.
[[ -s "$HOME/.rvm/scripts/rvm" ]]
PATH="$PATH:$HOME/.rvm/gems/ruby-1.9.3-p327#mygemset/bin:/.rvm/rubies/ruby-1.9.3-p327/bin/ruby:/.rvm/rubies/ruby-1.9.3-p448/bin/ruby:/.rvm/rubies/ruby-2.0.0-p353/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
I did a rvm list rubies command. ruby-2.0.0-p247 is not listed.
Any help would be appreciated. I will continue looking. I plan to post a link to this in the Phusion Passenger group.
UPDATE 12/21/2013 12:20 pm
I updated my .bashrc file to the following since I no longer use the other rubies in my Rails applications. I still get the error when I try to run rvmsudo passenger-install-apache2-module.
[[ -s "$HOME/.rvm/scripts/rvm" ]]
PATH="$PATH:$HOME/.rvm/rubies/ruby-2.0.0-p353/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
looks like a bug, please open a ticket here: https://github.com/wayneeseguin/rvm/issues
Indeed this was a bug, to fix it run:
rvm get head
rvm gemset reset_env
you can repeat the reset_env operation for every gemset that is broken:
rvm ruby#gemset do rvm gemset reset_env
There might be a cached bin file in your RVM path. In my case, it's "/usr/local/rvm/bin/unicorn"
Also, you may not directly having the gem in your Gemfile. In my case, I do not have "unicorn" in my Gemfile although I had "capistrano-unicorn".
So that the system will try to use the global cached file "/usr/local/rvm/bin/unicorn".
The file's content may using a ruby that you no longer use.
if [[ -s "/usr/local/rvm/environments/ruby-2.0.0-p247" ]]
then
source "/usr/local/rvm/environments/ruby-2.0.0-p247"
exec unicorn "$#"
else
echo "ERROR: Missing RVM environment file: '/usr/local/rvm/environments/ruby-2.0.0-p247'" >&2
exit 1
fi

jekyll installed but 'command not found'

I installed jekyll, but surprisingly somehow osx doesn't recognise its installed.
$ sudo gem install jekyll
Password:
Successfully installed jekyll-1.2.1
Parsing documentation for jekyll-1.2.1
Done installing documentation for jekyll after 1 seconds
1 gem installed
$ jekyll
-bash: jekyll: command not found
gem environment ( - INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0 )
$ cd /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/
echo $PATH
/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Users/TheSpiritMolecule/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/TheSpiritMolecule/.rvm/bin
I have rbenv installed and the step I missed was to do an rbenv rehash after gem install jekyll. The rehash creates a link in ~/.rbenv/shims which is in included in $PATH.
Okay I had to check what exatly does the $PATH means, and for what it is.
The problem was simple, somehow my ruby installion directory wasnt in my $path variable.
Useful links: Mac OS X: Set / Change $PATH Variable
Okay so here is the thing how I solved it:
echo "$PATH"
gem uninstall jekyll
find / -name jekyll (to delete if there is any leftovers somewhere )
gem environment ( get EXECUTABLE DIRECTORY path )
nano $HOME/.bash_profile ( go to the end of document and insert a new line )
export PATH="/usr/local/Cellar/ruby/2.0.0-p247/bin:$PATH"
you can do this on a templorary way by just writing it in terminal and not saving it in your .bash_profile
Following steps solved my problem
gem uninstall jekyll
sudo gem install jekyll
Open ~/.bash_profile and add this code in the last line,
export PATH=$PATH:/usr/local/lib/ruby/gems/1.9.1/gems/jekyll-2.5.2/bin
Save and close the .bash_profile
Close and reopen the mac terminal, try running jekyll now, it should work

RVM warning when installing Passenger on the Mac

Installing Passenger on the Mac runs into this problem.
Any suggestions?
sudo passenger-install-apache2-module
...
* Checking for Zlib development headers...
Found: yes
Location: /usr/local/include/zlib.h
Your RVM wrapper scripts are too old, or some wrapper scripts are missing. Please update/regenerate them first by running:
rvmsudo rvm get stable && rvm reload && rvmsudo rvm repair all
If that doesn't seem to work, please run:
rvmsudo rvm wrapper [] --no-prefix --all
First I did:
$ rvmsudo rvm get stable && rvm reload && rvmsudo rvm repair all
Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. export rvmsudo_secure_path=1 to avoid the warning.
which re-installed rvm and then I did:
$ rvmsudo rvm wrapper [] --no-prefix --all
Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. Run:
export rvmsudo_secure_path=1
to avoid the warning, put it in shell initialization file to make it persistent.
In case there is no `secure_path` in `/etc/sudoers`. Run:
export rvmsudo_secure_path=0
to avoid the warning, put it in shell initialization file to make it persistent.
awk: nonterminated character class ^[]=
source line number 1
context is
>>> /^[]=/ <<<
sed: 1: "s#^[]=##
": unbalanced brackets ([])
Unknown ruby interpreter string component: '[]'.
Could not load ruby [].
Add to your ~/.profile or ~/.bash_profile
export rvmsudo_secure_path=0
You may try to install passenger without sudo.
$ passenger-install-apache2-module

Installing Ruby gems not working with Home Brew

The gems I install via sudo gem install ... can't be executed (I get a command not found).
They seem to install into /usr/local/Cellar/ which is Brew's install directory (also, the gems in /Library/Ruby/ don't work either). Is there anything else I need to do to make the gems executable? I'm using ZSH on Mac OS X 10.6 with Ruby v1.8 for the one in Brew.
EDIT: It seems to be working now. I just went out for a few hours and came back to try it again.
Homebrew is nice. However unlike brew and npm, gem does not make aliases in /usr/local/bin automatically.
Solution
I went for a very simple approach (as of March 2020):
# Based on "`brew --prefix ruby`/bin"
export PATH=/usr/local/opt/ruby/bin:$PATH
# Based on "`gem environment gemdir`/bin"
export PATH=/usr/local/lib/ruby/gems/3.0.0/bin:$PATH
Add this to your .bashrc (or .bash_profile, .zshrc, etc.).
That's it! Now all Ruby bins and installed gems will be available from your shell!
In older versions of Homebrew (before 2017), there was a separate package for Ruby 2 called ruby20, for which you'd use the following snippet instead:
export PATH=/usr/local/opt/ruby20/bin:$PATH
This line was the only line needed at the time. But, in Ruby 2.1 the gems got moved to a separate directory. No longer under /usr/local/opt/ruby/bin, but instead at /usr/local/lib/ruby/gems/2.0.0/bin (where "2.0.0" is the last major Ruby version for Gem's purposes).
How it works
Homebrew keeps track of where it installed a package, and maintains a symbolic link for you that points there.
$ brew --prefix ruby
/usr/local/opt/ruby
$ l /usr/local/opt/ruby
/usr/local/opt/ruby# -> ../Cellar/ruby/2.5.3_1
Effectively, adding /usr/local/opt/ruby to PATH is the same as the following:
export PATH=/usr/local/Cellar/ruby/2.5.3_1/bin:$PATH
Except, this long version hardcodes the currently installed version of Ruby and would stop working next time you upgrade Ruby.
As for Gem, the following command will tell you the exact directory Gem adds new packages to:
$ gem environment gemdir
/usr/local/lib/ruby/gems/2.7.0
Tools
These tools were meant to automatically bridge between Homebrew and Gem:
josh/brew-gem (no longer exists)
indirect/brewbygems (unmaintained)
I haven't used these but they might work for you.
brew unlink ruby; brew link ruby might add symlinks to /usr/local/bin/:
$ which sass
$ brew unlink ruby; brew link ruby
Unlinking /usr/local/Cellar/ruby/2.0.0-p0... 20 links removed
Linking /usr/local/Cellar/ruby/2.0.0-p0... 31 symlinks created
$ which sass
/usr/local/bin/sass
brew --prefix ruby is still pretty slow, but you could also just add /usr/local/opt/ruby/bin to the path.
$ time brew --prefix ruby
/usr/local/opt/ruby
0.216
$ time brew --prefix ruby
/usr/local/opt/ruby
0.076
$ stat -f%Y /usr/local/opt/ruby
../Cellar/ruby/2.0.0-p0
I like home brew. There's probably a better way to do this, but if you run:
gem environment
That will print out a nice list of all the relevant paths. Look for the one labeled EXECUTABLE DIRECTORY. That's the one you want to add to your path. In my case that's /usr/local/Cellar/ruby/1.9.3-p362/bin/ruby but I would imagine it would change with newer version of Ruby.
I'm using /bin/bash as my shell, but the process of adding it to your path should be pretty much the name.
I use TextWrangler (via the command line tools) to edit my .profile file. To do that, it's just:
edit ~/.profile
When your done, either close your terminal and open a new one, or run:
source ~/.profile
Using the info in Timo's answer, I've got this:
PATH=/usr/local/opt/ruby/bin:$PATH
GEMSDIR=$(gem environment gemdir)/bin
PATH=$GEMSDIR:$PATH
export PATH
Works for Homebrew, works for the separate gems directory, and doesn't hardcode a Ruby version.
You can be fine with ruby installed by homebrew too.. You just lack the functionality of custom gemsets with homebrew.
first do:
sudo nano /etc/paths
this will bring up nano editor,
then add the following to the paths:
/usr/local/Cellar/ruby/1.9.3-p194/bin
your version of ruby will probably vary.
Thats it. It should now detect your gems.
Oh, btw, you need to Ctrl+X > y > ENTER to save a file in nano.
Instead of using => $(cd $(which gem)/..; pwd)
You could use this instead => $(brew --prefix ruby)/bin
I think this evolve a bit.
Just add
export PATH=/usr/local/opt/ruby/bin:$PATH
To your .bashrc (or .bash_profile, .zshrc/.bashrc, .. – whatever you use).
If you have a problem with ruby itself
brew unlink ruby
brew link ruby

Build and run ruby without installing it to system directories

I've cloned the ruby 1.8.7 source tree. I can build ruby. But I can't figure out how to run it without installing it in system directories. How can I do it?
Background: I want to use "git bisect" to figure out which build of Ruby introduced a new behavior in my code. I need to build and run ruby against a test program, multiple times, but I don't want to clobber the ruby that the Debian package installed.
Here's what I get if I try to run the ruby I built from source:
$ ./ruby -e 'puts RUBY_VERSION'
ÀÇ ÀÇ : ÀÇ ÀÇ : cannot open shared object file: No such file or directory - ÀÇ ÀÇ (LoadError)
I've also tried installing it, but not to the system directories, and got a stack trace:
$ ./configure --prefix=/home/wayne/tmp/ruby/installed --exec-prefix=/home/wayne/tmp/ruby/installed
$ make
$ make install
$ /home/wayne/tmp/ruby/installed/bin/ruby -e 'puts RUBY_VERSION'
/home/wayne/tmp/ruby/installed/lib/ruby/1.8/openssl/ssl.rb:26: uninitialized constant OpenSSL::SSL::VERIFY_PEER (NameError)
from /home/wayne/tmp/ruby/installed/lib/ruby/1.8/openssl.rb:23:in `require'
from /home/wayne/tmp/ruby/installed/lib/ruby/1.8/openssl.rb:23
I've got the feeling that I'm close, but a miss is as good as a mile.
rvm is a great tool. and should be able to take care of the heavy lifting for switching between different ruby version (or even sets of gems).
Installation is very easy:
$ gem install rvm && rvm-install
$ echo "if [[ ! -z $HOME/.rvm ]] ; then source $HOME/.rvm ; fi" >> ~/.bash_profile
Then to install a specific version & patch level:
rvm install ruby-1.8.7-p160
Then to switch between versions:
$ rvm 1.8.7-p160
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 160) [i686-darwin10.0.0]
$ rvm 1.8.7-p174
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]
When I need to do something like that, I use the chroot command. Create a temporary directory, install ruby into a sbin subdirectory, and chroot into the temp folder. Depending on what you are testing, you may also have to copy some system libraries into the temporary directory tree (before you chroot in).
It's probably easier to use rvm to test your app against different rubies.

Resources