I had Ruby, jRuby, RubyGems and Rails installed in Ubuntu 14.04. I needed to upgrade or downgrade some packages to exact versions. I tried to uninstall each of the above packages completely.
First I removed all packages installed using gem install:
gem uninstall package
Then I used sudo apt-get --purge remove ruby1.9.1-dev ruby1.9.1-full rubygems jruby
But, still some binary files and folders are left:
/usr/local/bin/rails
/usr/local/bin/rake
/var/lib/gems/
/usr/lib/jruby/
/var/lib/jruby/
I want to get rid of all the above files and folders to avoid any future conflict. sudo apt-get remove showing that they are not installed. Shall I remove them manually one by one or is there some other way? I am afraid that any manual removal might mess up my system.
Related
I'm on Kali linux and I have a script that runs gem update --system. However I get the following error:
ERROR: Your RubyGems was installed trough APT, and upgrading it through RubyGems
itself is unsupported. If you really need the latest version of RubyGems (tip:
you usually don't), then you need to install RubyGems (and Ruby) manually,
maybe using tools like ruby-install, rvm, etc.
I have never touched Ruby in my life but I've done some research to try and solve the problem myself. I tried to download the rubygems .tgz file from this link here, extracted it with tar, and followed the only step there was, ruby setup.rb. I then tried gem update --system again but I got the same error. Then I decided to try and remove rubygems with apt like this: apt purge rubygems, but it said, NOTE: selecting 'ruby' instead of 'rubygems' and it did nothing. Then I tried to completely remove ruby with apt purge ruby but not only does it remove ruby, but other programs. Here's what apt says:
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
bundler* libruby2.7* metasploit-framework* rake* ruby* ruby-bundler*
ruby-dev* ruby-rubygems* ruby2.7* ruby2.7-dev*
0 upgraded, 0 newly installed, 10 to remove and 0 not upgraded.
After this operation, 423 MB disk space will be freed.
Do you want to continue? [Y/n]
I don't want to remove all versions of ruby nor do I want to remove the metasploit-framework or bundler since I might need them. To sum up, does anyone know how to manually install rubygems and get gem update --system to work?
I suggest using RVM (https://rvm.io/).
Using RVM, you can have different ruby installations, each with their own version of Ruby Gems. This is installed locally (in your home directory) and RVM manages your PATH variable so that you can switch between installations and gem sets (basically multiple local gem repositories, which is very useful for doing different projects).
I have not worked on Kali Linux, but you should be able to follow the process easily here: https://rvm.io/rvm/install
Take a few minutes to learn the RVM commands to install new Rubies and switch between them and managing gem sets. I believe it's worth it.
I've been working on a blog using Jekyll so I installed Ruby with this command from the Jekyll doc:
sudo apt-get install ruby ruby-dev build-essential
Then I installed the gems directory to my home folder. I tried out a lot of different themes and just run bundle install when my terminal said I was missing any dependencies. Now I have a lot of packages installed inside the gems folder. Is there a way for me remove unnecessary gems and start over without uninstall gems?
It is highly recommend to not use system ruby but use a ruby version manager. One reason is that you won't have to use sudo before your gem commands.
If you want to remove all your current gems you should be able to just do
gem uninstall --all
But you might need to prepend it with sudo gem uninstall --all
If you intend to do any longer term work / multiple projects with ruby, I recommend using RVM. You can find detailed install instructions here
Some prefer rbenv however it's install instructions seem to be focused on MacOS, so if you're on linux, I dunno.
You can just run:
gem uninstall [gemname]
to remove them one at a time.
When trying to bundle install on a Gemfile that contained only the GitHub Pages gem and nothing else, on Ubuntu 18.04, I got error messages telling me to try installing eventmachine using gem install. That always succeeds, but bundle install still fails. How can I get bundler to see that the gem is installed?
I fixed this after many hours of struggle, by noticing that on the GitHub Pages repo there's a note that says
Important: Make sure you have Bundler > v1.14 by running gem update bundler in your terminal before following the next steps.
I have no idea why this mattered but I removed my ruby packages from Ubuntu and reinstalled them, then installed bundler with rubygems, which gave me a newer version:
sudo apt-get remove ruby
sudo apt-get install ruby ruby-dev
sudo gem install bundler
bundler --version
If anyone knows why I needed that version of bundler, or how I should have diagnosed this faster, I'd be interested to hear it. I'm not new to programming but I'm new to Ruby.
From my understanding it might be the gem you are trying to install requires a specific feature provided by bundler. If you check the change log of bundler there is some changes related to install github based gems on how to correctly read the user git settings. So I think that might be where the problem is from.
I'm trying to migrate a version of Redmine from backup to a new server; I'm migrating from Redmine 3.2.3 to 3.3.0. I installed the new version of Redmine (from Bitnami Stack) on my new server and everything loads properly. When I move my old database into the new version, I have to run
bundle exec rake db:migrate
to migrate my database. But... bundler can't find rake somehow even though gem list shows it clearly installed. Can I force bundler to use the version of rake that I have installed that it says I don't?
I should mention I've done no customization at all, haven't installed any gems, or changed ruby versions or done anything. This is out of the box Redmine.
I noticed after I made the question that I had two versions of rake installed. I removed both and reinstalled rake 11.1.2 and have the same problem.
You are probably using the wrong ruby binary. Note that, the installers for Bitnami Stacks are completely self-contained and run independently of the rest of the software or libraries installed on your system.
Also, taking a look at the screenshots you have shared, you were using ruby 1.9.3 when you have executed ruby -v and the Redmine Bitnami Stacks uses ruby 2.1.9. Probably this is the reason of the issue you are having.
If you want to use the ruby (and the other components) shipped with the Bitnami Stack you need to run the following command:
cd *INSTALLDIR*
./use_redmine
This command will open a new console session with the environment configured to use the stack.
There are two things:
ruby gems available via gem list
ruby gems availbale via bundler
When you are using bundle then bundler is looking for gem from Gemfile. You can have multiple gems installed in your system, but when you are using Gemfile then gem version will be taken from Gemfile.lock
Summing up:
$ bundle exec rake ...
require to have rake gem inside Gemfile
$ rake ...
it will take the newest version of rake gem installed in system
I hope it helps you.
This is how I finally got my Redmine upgraded:
A version of ruby outside of the one provided by Bitnami somehow got installed on this machine as well as another version of bundler. The first thing I did was uninstall the apt-get version of bundler. I had to manually remove /usr/bin/bundler and /usr/bin/bundle for $ which bundle to stop finding bundler even after the removal.
I saw that the Bitnami stack's ruby was version 2.1.x but found Ruby 1.9.3 was installed to /usr/bin/ruby1.9.3/ with $ which ruby. I took the commands from here and removed that version of Ruby.
Running $ ruby -v now gave me nothing as Ruby wasn't installed anymore (even though it was in the Bitnami stack). Bitnami's Ruby then had to be (re?)added to my path in ~/.profile. $ ruby -v now gives me the correct version.
$ gem list was no longer telling me that rake was installed. I tried running $ bundle install where Gemfile is but was complaining about mime-types being locked at a lower version and wouldn't do anything. I got around that with $ bundle update but then ran into the infamous nokogiri problem where it complains that everything required by nokogiri isn't installed.
Since I'd dealt with this before (many many times) I went over to the Nokogiri Website's install page and followed the instructions for troubleshooting on Ubuntu:
sudo apt-get install build-essential patch
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
and now $ bundle update worked on my Gemfile. Redmine upgraded and my users are about as happy as users can get.
I am new to Ruby and RoR. I have a clean Linode instance with an Ubuntu image, and I want to compile Ruby from source instead of using apt-get. I have googled for instructions of doing this, but after some tries I keep on getting errors regarding missing zlib and some other packages when I try to run some tutorials samples.
Can anyone please give me detailed instructions (or a link) that would teach me how to get the necessary prerequisite packages installed before I compile Ruby from source?
My intent is to compile latest stable release of Ruby, then install Rubygems and Rails. Thanks for any help in advance!!!
This blog post covers the necessary packages and install process to compile ruby from source; it references Ruby 1.9.1 but it should work just fine with Ruby 1.9.2 as well. The real useful bit from this post is:
sudo apt-get -y install libc6-dev libssl-dev libmysql++-dev libsqlite3-dev make build-essential libssl-dev libreadline6-dev zlib1g-dev libyaml-dev
It looks like to me that a few of these are not essential unless you want to go on to use MySQL or SQLite, but otherwise this list of packages will get what you need to compile Ruby.
After that, I wouldn't recommend actually installing Ruby from source manually; I would use RVM (Ruby Version Manager) so you can install any version of Ruby you wish, now and later. RVM compiles the different versions of Ruby by downloading and compiling the source code, and will also install Rubygems for you.
Once you have installed rvm, you can use rvm requirements to get the current list of required packages.
You can use apt-get install all the build dependencies for any package. Enable your source repository and then run.
sudo apt-get build-dep ruby1.9 rails
This will install all the packages you will need to compile the source for these two packages. Then you can go get the latest source, and follow the instructions.
N.B.: Packages names may be wrong, depends on which version of Ubuntu you're using.
I HIGHLY recommend using 'RVM' to install all your rubies, especially if you're doing it just for your own use. RVM will do all the compilation for you, puts everything in ~/.rvm including the gems, and makes it easy to install multiple versions of Ruby and gems for testing.
Installation and using gems will get you running. RVM's Gemsets are powerful, and RVM's ruby command makes it nice for performing some action across all the installed Rubies RVM manages.
RVM also supports system-wide installations offering RVM's flexibility if you need it, but it's a bit more complicated and is unnecessary if you're on a single-user machine.
Why not install zlib? sudo aptitude install libz-dev
I've compiled from source, and it's pretty good at warning you when you are missing a dependency.