Updating RubyGems alongside an existing packaged installation on Joyent - ruby

On a Joyent accelerator I'm working with, Ruby and Rubygems were installed when the server was initially setup using Cool Stack.
The existing version of Rubygems is version 0.9.2. When it comes to upgrading RubyGems using the 'sudo gem install rubygems-update' and 'sudo update_rubygems' commands, it results in the following error:
./lib/rubygems.rb:124: uninitialized constant Gem::RbConfig (NameError)
from setup.rb:24:in `require'
from setup.rb:24
Without having much success in rectifying this issue, I wanted to install a fresh version of RubyGems alongside this one. As this is a production server, I want to minimize the amount of environment changes I make on the server.
If I install a fresh version of RubyGems from source, how do I set this new installed version of RubyGems as the default version of RubyGems to use?

I think RVM is what you're looking for: http://rvm.io/rvm/install/
And then setting one Ruby install as the default: http://rvm.io/rubies/default/

Related

Why can't bundler find rake when it's obviously installed?

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.

Trouble running RubyGems on Redhat 5.5

Am trying to install Ruby and RubyGems on a RedHat 5.5 machine. I'd got them by running the following two commands:
sudo yum install ruby
sudo yum install rubygems
Got both installed. However when i try to run gem, i got the following error:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require': undefined methodend_with?' for "no such file to load --
Win32API":String (NoMethodError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:55
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:inrequire'
from /usr/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:8
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in
gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:inrequire'
from /usr/bin/gem:9
Doesn't matter what kind of command i run, it throws that. (I tried gem -v, gem update)
The version of Ruby seems to be 1.8 but i have problem determining the RubyGems version. I'd vi into rubygems.rb and at the top it stats the version as 1.5.
Try to fix by running the downgrade command as proposed here, but it throws the same error as well.
Any help on fixing this issue? Just want to get this running so that i can run a RoR apps..
RedHat 5 ships with Ruby 1.8.5 and an equally old rubygems. Both, the rubygems and the ruby version is WAY too old to be supported by anything outside the base packages of the OS anymore. Even in the OS packages, they probably won't change anything on their own due to the age of their whole system.
If you really want/have to use Ruby on Red Hat 5, you probably need to get another source for it that the RPMs provided by the OS, e.g. rbenv / ruby-build or ruby-install or even rvm. You should use a newer Ruby version, i.e. a 2.1 or 2.2 version. All Ruby versions < 2.0 are unsupported by the language developers by now.
Alternatively, you should try to use a newer version of RedHat, i.e. RedHat 7 which doesn't need to support to 8 year old software...
Suspicious here is that yum installed ruby 1.8 which is pretty outdated version, it seems you have two versions of ruby on your system now and gem tries to use the old one.
Check the version of the package installed recently and try to force rubygems to use the new version(by removing the old ruby or linking to the path returned by which ruby)

Using chef-metal with Windows-7

I want to use chef-metal with on my windows workstation. Following are details of my setup :
OS : Windows 7, 32-bit
Chef client version : 11.12.0
I follow the instructions as mentioned here . I intend to use the Vagrant driver for chef-metal, so I have vagrant and virtualbox installed on my system. Next as the documentation says, I install 'chef-metal' gem, and then try to run the basic vagrant_linux and simple recipes. But the setup is giving me rubygems conflicts for gem 'ffi', the error is shown in the screenshot below :
Apparently, installing chef-metal gem is messing up my chef-client installation also. If I run chef-client -v, just to check if chef-client is working fine, i throws the same gem conflict error.
While installation of chef-metal gem, I observe that it is installing certain gems, that are already installed on the system(with the chef-client installation.) I tried to uninstalling a version of the gem throwing the error(ffi-1.9.3-x86-mingw32), but it showed me this info:
Same is the response i get when i try to uninstall ffi-1.5.0-x86-mingw32 gem.
Update :
As per Tensibai's suggestions, I removed teh older version of the gem and updated to use a new one. Following is the new gem dependency error I get :
Please help as I have reached a dead end on searching a solution for this one:
Gem documentation is HERE
To uninstall it is gem uninstall ffi -v 1.5.0
What the errors tells you is that it can't load it because ffi is in versino 1.5 and ohai require it in a version around 1.9.X (the ~> 1.9).
You best bet to resolve the problem is to run a gem update ffi -v 1.9.3
And update chef too to remove old depending: gem update chef

How can I manage rubygems version with bundler?

I just started learning Ruby, and for my sandbox I use latest Rubygems version, according to examples and tutorials.
At the same time I have Redmine, which requires Rubygems 1.6.2.
To manage gem versions I use bundler, but can I use it to manage Rubygems version too?
I dont think so - I believe it uses your current rubygem from the environment.
However you can use rvm to manage the rubygems version, so if you install it and have a project specific gemset in your .rvmrc file.
I think rvm is OSX/unix only - there is an alternative for Windows I believe.

Is it possible to install RubyGems on Ruby 1.8.6?

I'm trying to install RubyGems on a Fedora-based distribution that only has Ruby 1.8.6. I downloaded the RubyGems 1.6.2 package, unzipped and ran
$ ruby setup.rb
It bombs out with the rather unhelpful error message:
./lib/rubygems/custom_require.rb:54: warning: parenthesize argument(s) for future version
./lib/rubygems/custom_require.rb:57:in `require': undefined method `end_with?' for "no such file to load -- Win32API":String (NoMethod\
Error)
from ./lib/rubygems/config_file.rb:55
from ./lib/rubygems/custom_require.rb:36:in `gem_original_require'
from ./lib/rubygems/custom_require.rb:36:in `require'
from ./lib/rubygems/gem_runner.rb:8
from ./lib/rubygems/custom_require.rb:36:in `gem_original_require'
from ./lib/rubygems/custom_require.rb:36:in `require'
from setup.rb:25
Looking at the source of the exception, it seems that it first tries:
require "etc"
Etc.sysconfdir
and when that throws a NoMethodError it tries to require Win32API (which I assume isn't present on linux).
I'm guessing that this could be because I have an old version of Ruby, but I can't find the RubyGems version requirements documented anywhere. Can anyone suggest how to proceed with this?
How about installing RVM? Then you can manage multiple Ruby versions easily and, maybe, install a more recent version of Ruby. It works really well.
It is definitely possible to install RubyGems on Ruby 1.8.6, but not RubyGems 1.6.2. Support for Ruby 1.8.6 was dropped in RubyGems 1.4.0.
Why are you trying to circumvent your Linux distribution's package manager? They test interoperability between the packages they ship precisely to avoid situations like this.
In general, it is not a good idea to mix different package management systems. Ideally, you shouldn't be using RubyGems at all, when using Linux, since most distribution's package management systems are as good as RubyGems anyway. RubyGems is only needed on operating systems like Windows or OSX which are still stuck in the 1980s.
Thats what I do on my Redmine installation, for example: I just use the distribution packages of Rails, RedCloth, RMagick, Rack, Redmine, Ruby Enterprise Edition, Phusion Passenger, and whatever else I need. I don't even have RubyGems installed at all, neither from a distribution package nor from source.
If, however, for some reason, you need RubyGems, then you should move your entire Ruby environment out of the distribution package manager and manage it yourself. Just install whatever version and flavor of Rubinius, JRuby, IronRuby, YARV or whatever you want, install the latest version of RubyGems from source (or don't, since all of the above already ship with one pre-installed anyway) and install all of your Ruby libraries as Gems.
As was noted in other answers, RVM can be of help, but is generally unnecessary unless you want to manage multiple Ruby installations on the same machine.
You can't install RubyGems greater than 1.3.5 if you only have Ruby version 1.8.5.
RubyGems requires at least Ruby 1.8.6 to install.
My background:
- I have RubyGems 1.3.5 installed in
my CentOS Linux because Ruby is 1.8.6.
- What I did with Mac OS X, which comes
with Ruby 1.8.7, is to upgrade gem
from version 1.3.5 to version 1.6.2
by using the original gem.

Resources