How do I uninstall an old version of Ruby, and is it a wise thing to do? - ruby

When logged in as root and I type ruby -v centOS server reports 'ruby 1.9.3p392'. This is what I want.
But if I put rvmsudo ruby -v then I get 'ruby 1.8.7'. I do not want to use this older version, it is causing problems for my gitlab install.
I would like to remove it and make sure only v1.9 is used, how can I do this? Or should I leave it there but try and require certain users to use a different version?
Also, in case doing this messes anything up, is it possible to either;
a.see if anything on the server requires v1.8?
b.reverse the uninstall if it causes a problem?

Before uninstalling, take note of the patch level of 1.8.7 just in case. rvmsudo ruby -v should return something like ruby 1.8.7p234. The p#{num} is your patch level.
You should be able to uninstall 1.8.7 with rvm uninstall 1.8.7 (or possibly rvmsudo uninstall 1.8.7). This version of Ruby shouldn't be used by anything on the system other than code you've written, so it should only affect your applications and scripts.
The best way to tell what else would be using 1.8.7 is to look for scripts and crontabs that are owned by the user that rvm is running under. I'm not sure there's a tool that can evaluate it for you.
The best way to roll back in case of an emergency is rvm install 1.8.7-p#{num_from_above}. Alternatively, if you're on a platform like AWS or have rsync backups enabled, you might consider taking a snapshot that you can roll back to if you get in over your head.
Hope that's helpful!

Try setting default
$ rvm --default use 1.9.2
$ ruby -v
#ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
to remove you can use:
sudo apt-get remove ruby 1.8.7
Docs here & here

As you mentioned the ruby version output for root is ruby 1.9.3p392 in my understanding you will not have any problems.
Sure, you can have more than one version of ruby installed and find them under ~/.rvm/rubies. Also there you can find out the default version which is used. For more information you can have a look here: set default ruby where it explains how to set a default ruby and how to reset to the systems default.

You can uninstall cocoapods and install cocapods in the right directory.
sudo gem uninstall cocoapods
sudo gem install -n /usr/local/bin cocoapods

Related

Rubocop installation (machine: linux-gnu, Ubuntu)

I go through the process of installing the rubocop gem install rubocop --version 0.86.0
And run rubocop -v afterwards to make sure everything is fine.
Instead, I receive the message below:
warning: parser/current is loading parser/ruby27, which recognizes
warning: 2.7.2-compliant syntax, but you are running 2.7.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
1.8.1
From what I can understand with my limited knowledge, it says that my ruby version is not compatible. Is that right? That I'm using 2.7.0 and I need to use 2.7.2 or above.
I run rvm ls
=* ruby-2.7.2 [ x86_64 ]
Then I try to run ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
I've gone through the process of rvm install 2.7.2 & rvm use 2.7.2 I have toggled-on 'Run command as a login shell' - because that was the only way I could get 'rvm' to work in the terminal.
If someone is able to help me with how I can upgrade my ruby version, it would be greatly appreciated.
Sidenote - I tried to follow the link https://github.com/whitequark/parser#compatibility-with-ruby-mri. 1.8.1 and I willingly admit I don't understand what's going on, on this page or how I can use it to solve the problem.
Lucas R
You can safely ignore this warning. The parser gem takes things very seriously; it is detecting that you are running a different patch version than it expects (2.7.2 instead of 2.7.0), but there are normally no syntax changes between patch versions.
Unrelated note: rubocop 0.86 is very old; you should upgrade if you can.

Trying to uninstall and fresh install Ruby on Ubuntu: do I still have Ruby installed?

I'm coming from Windows to Linux (Ubuntu) so I'm new to the CLI. I had issues trying to install Rails so I figured a fresh install would help. I'm following "Installing Ruby the Correct Way."
I thought I had uninstalled Ruby, but after installing 2.1.4 it still shows some Ruby folders. Have I completely uninstalled Ruby?
Downloading ruby-2.1.4.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/bf9952cdeb3a0c6a5a27745c9b4c0e5e264e92b669b2b08efb363f5156549204
Installing ruby-2.1.4...
Installed ruby-2.1.4 to /home/richard/.rbenv/versions/2.1.4
richard#richard-ThinkPad-T400:~$ rbenv global 2.1.4
richard#richard-ThinkPad-T400:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
richard#richard-ThinkPad-T400:~$ sudo rbenv global 2.1.4
richard#richard-ThinkPad-T400:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
Are the "the following packages" on my local system? or are they online?
EDIT
I've been getting this error when I try to install RVM (and some other applications):
GPG signature verification failed for '/home/richard/.rvm/archives/rvm-1.26.0.tgz' - 'https://github.com/wayneeseguin/rvm/releases/download/1.26.0/1.26.0.tar.gz.asc'!
try downloading the signatures:
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
they can be compared with:
https://rvm.io/mpapis.asc
https://keybase.io/mpapis
Does this have anything to do with it? I wouldn't really think so but I'm a noob.
Don't sudo rbenv anything or you will summon Cthulhu. Use rbenv by itself.
Also, don't randomly follow guides on the internet until you're more familiar with your OS; They go stale, or start out wrong, or don't accurately apply to what you're doing. Instead, go to the source and follow the directions there.
To find out what is installed on your machine, use locate to quickly find Ruby instances. Something like:
locate /bin/ruby | grep -v .rbenv
should narrow down whether multiple Rubies are installed outside the ~/.rbenv directory.
Traditionally, you'll find a normally installed system-wide Ruby in /usr/bin/ruby. A user installed one from source will probably be in /usr/local/bin/ruby unless you specifically said otherwise, probably with a PREFIX= directive.
rbenv will default to installing Ruby in the ~/.rbenv hierarchy since it acts like a sandbox manager and will put all Rubies it installs underneath that directory. RVM, a similar application, will use ~/.rvm, and in both cases, the purpose is to keep them where the user's permissions are sufficient to install and update gems without requiring the use of sudo. For general use, avoid sudo unless you understand what you're about to do, as it can turn a computer into an under-desk heater in seconds.
The shell uses the PATH variable to figure out where to look for executable commands. It sounds like your PATH isn't set correctly. If you followed the directions on the rbenv site, they say how to enable rbenv by modifying your ~/.bash_profile script. Doing that, then closing and reopening your shell should bring rbenv to life.
Following that blog post, you are installing Ruby using a tool called rbenv, and if you only uninstalled one Ruby, that doesn't mean that all Rubies are uninstalled.
The message that you posted shows that it is a local install: Installed ruby-2.1.4 to /home/richard/.rbenv/versions/2.1.4 which is a copy of the 4th line of your message.
You can find out from whence your Ruby executable is being invoked by issuing at the command line:
which ruby
You will then know if the program is available and which it is. Using ruby -v if it is there will tell you the version.
You have done some of these steps and are finding out that your system does not know how to get to the Ruby, if it is indeed installed.
Right now, it is effectively uninstalled, as it is unavailable to your environment.

Ruby Gems suddenly stopped working on ubuntu 12.04

After a couple of days of not doing pretty much anything on the ubuntu box, I decided to try out some ruby stuff. For this, I wanted to fire up pry. Unfortunately, I was presented with
Sorry, you can't use Pry without Readline or a compatible library.
Please gem install rb-readline or recompile Ruby --with-readline.
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require': libreadline.so.5: cannot open shared object file: No such
file or directory -
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-linux/readline.so
(LoadError)
Being quite new to linux in general, I figured I'd just do as it said, and install this rb-readline. The installation passes just fine, but doesnt seem to do anything at all. If I do gem list p, the package just doesn't appear.
So yeah, I just don't know what to do to get it working again, and the only thing I managed to find by searching was related to an installation without rbenv and had something to do with sudo etc.
Any ideas?
Without understanding the problem and following the advice in option 2 of the message:
Sorry, you can't use Pry without Readline or a compatible library.
Possible solutions:
* Rebuild Ruby with Readline support using `--with-readline`
* Use the rb-readline gem, which is a pure-Ruby port of Readline <==== Option 2
* Use the pry-coolline gem, a pure-ruby alternative to Readline
I added the gem into the Gemfile (as follows), bundled and pry was then available.
group :development, :test do
gem 'pry'
gem 'rb-readline'
end
I had this problem too. I am using rbenv and reinstalling ruby via
rbenv install -f 2.2.3
did fixed it for me. Of course you'd put in your respective version. -f forces the installation even though you already have that specific version installed. use rbenv global to find out what version you have installed and set.
I have some problem. But I don't want to add gem 'rb-readline'. So try it...
$ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
Do a sudo apt-get install libreadline-dev, seems like you're missing the readline shared library that pry is wanting. If it worked before, not sure why the library isn't there anymore.
I ended up doing rbenv uninstall, followed by rbenv install and re-installing all the gems, and got it back to working. Still no idea what caused it in the first place, but it works now.

Best way to update Ruby to the latest 1.9 version on OS X?

Does Mac OS X support ruby version 1.9.+? Is it recommended to update to 1.9 or should I wait?
The reason I ask is because I'm trying to use some plugins that only support Ruby 1.9+
Most people use RVM to install Ruby on the mac. Basically it allows you to have multiple versions of ruby installed on the same machine and to switch between them at will. You can also install gems on a project by project basis rather than installing them all globally using sudo like you probably do now.
You can install RVM by running
bash < <(curl -s https://rvm.ioinstall/rvm)
in terminal (assuming you have git installed). Full installation instructions can be found on the RVM site.
Here is a tutorial which I personally found invaluable when getting used to using RVM in my workflow at the start. It will probably help you too.
I wouldn't try to update the system Ruby, since OS X uses it for some stuff (I think). Instead, use RVM.
I won't recommend a "preferred" method, but just outline the possibilities:
Install ruby 1.9 from ports using port install ruby19 +nosuffix
Install using RVM as others suggested
Check out the stable version with svn, then
./configure --prefix=/opt/ruby --enable-shared
make && sudo make install
I prefer the third way, as it gives the most flexibility, and the latest stable version. Don't forget to add /opt/ruby/bin to path before everything else if you choose this path (no pun intended).
And as others said - don't touch the system ruby, Mac OS X depends on it.
You can install MacRuby.
It can be installed along with regular Ruby as the commands of MacRuby begins with "mac", so, irb is macirb and ruby is macruby.
Having both installed, you can choose which one use in each moment by prefixing the "mac" string or not
I'd leave the system Ruby alone. Most people would just use RVM to install 1.9, but Homebrew also has Ruby 1.9.2 available.
I'd recommend using Homebrew to install it (into /usr/local).

Where is the default Gem.dir path set?

This is really odd: I installed ruby 1.9.1 using a "191" suffix so that it will coexist with other versions. e.g. the executables look like ruby191, gem191 and the library directory where all of the vendor/site code lives is /usr/local/lib/ruby191. The version of RubyGems (1.3.1) that is included with ruby 1.9.1 works fine. The installation was performed with:
cd /usr/local/src/ruby-1.9.1-p429
./configure --prefix=/usr/local --program-suffix=191
make
sudo make install
However, when I upgrade my RubyGems installation with sudo gem191 update --system it appears to forget about all of the installed gems. When I checked it out with gem191 environment it is now looking in /usr/local/lib/ruby.
I know I can create a ~/.gemrc and change the location there, but that smells like a hack to me. I have spent a couple of hours trying to figure out where Gem.dir is set in the code, but have been unable to find it. Does anyone know where the default location is set?
Apparently the Gem engine didn't work properly under ruby 1.9.1, but has been fixed under ruby 1.9.2. After installing the latest build, all of my Gem issues have disappeared.
You should definitely use rvm gem for multiple ruby installations on one system.
P.S. You can view your gem installation path by using $ gem{suffix} env.

Resources