how to update gem command in ubuntu? - ruby

my gem version is 1.3.5 and I can't install certain gems because of that.I tried to update the gem on my computer by
sudo update --system
and it gives me an error
ERROR: While executing gem ... (RuntimeError)
gem update --system is disabled on Debian.
RubyGems can be updated using the official
Debian repositories by aptitude or apt-get.
so according to some people, the source need to be downloads and it needs to executed by ruby. i downloaded the file, did
sudo ruby setup.rb
and it gave me
RubyGems 1.8.24 installed
== 1.8.24 / 2012-04-27
1 bug fix:
Install the .pem files properly. Fixes #320
Remove OpenSSL dependency from the http code path
RubyGems installed the following executables:
/usr/bin/gem1.8
but when I hit ruby gem -v it still gives me 1.3.5 rather than the one I installed which is 1.8.
Do I need to uninstall the older version manually? or some other thing I need to do first?

RubyGems installed the following executables: /usr/bin/gem1.8
As the line says, the name of the program is gem1.8, not gem. Ergo, you need to call
gem1.8 -v
not
gem -v

Please try make a symbolic link.
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Related

Error installing Jekyll, requires Ruby >= 2.0.0

I get the error
Error installing jekyll:
jekyll requires Ruby version >= 2.0.0.
when I run
sudo gem install jekyll
"ruby -v" says I have ruby version 1.9.3
How do I install Jekyll? Do I need to upgrade ruby? If so, how?
Update - I installed ruby 2.0.0 with rvm but get the same error. Since trying to install with gem, could that still be trying to install with the older version of ruby? If so, how to find and change?
Try
sudo gem install jekyll -v 2.5
The default command apparently tries to install Jekyll 3, which was released on October 27th 2015. The 2.5 version still works with Ruby 1.9.3, and its quite allright for me, probably for you too.
I solved this issue the following way (assuming the ruby2.0 package is installed):
sudo rm /usr/bin/ruby
sudo rm /usr/bin/gem
sudo ln -s /usr/bin/ruby2.0 /usr/bin/ruby
sudo ln -s /usr/bin/gem2.0 /usr/bin/gem
Quick explanation:
/usr/bin/ruby and /usr/bin/gem are symlinks, you can check their target by entering:
ll /usr/bin/ruby
ll /usr/bin/gem
Changing the target of these links results in changing your default ruby and gem execution. Switching to version 2.0 for instance, lets you install Jekyll 3.
You can give a try to:
sudo apt-get install ruby2.0 ruby2.0-dev
sudo gem2.0 install jekyll-import
I try the following on Ubuntu 14.04:
sudo apt-get install ruby2.0 ruby2.0-dev
sudo apt-get install zlib1g-dev
sudo gem2.0 install jekyll
If you've already installed a later version of Ruby AND you're using rbenv, and gem gives the same error, it is because you are still using the old version of gem. There are now two executables called gem in your filesystem. Figure out which gem is the default with "which":
$ which gem
If you see something like */.rbenv/shims/gem, this is not the version of gems that you want to use. The correct version of gem will be in /.rbenv/versions/[your preferred version, i.e. 2.0.0]. You can run that version of gem by including the full path to the executable:
$ sudo /path/to/correct/gem install jekyll

Why do I get "ERROR: While executing gem ... (Gem::FilePermissionError)"?

I uninstalled RVM and re-installed using a single user installation using:
\curl -L https://get.rvm.io | bash -s stable
When I do bundle, it prompts for:
Enter your password to install the bundled RubyGems to your system:
I tried using the answer in "ERROR: While executing gem … (Gem::FilePermissionError)" which did not fix it.
Then, while trying to install the gem manually, I got:
Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.
then running gem install nokogiri -v '1.6.0' returned:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
I checked all the similar posts on SO, but they didn't solve the problem. What am I missing?
I spent a lot of time fixing this issue on my MacBook. The gem update --system does not work for me.
At last, putting the following code in the ~/.zshrc file and create a new zsh session works for me.
export GEM_HOME="$HOME/.gem"
export GEM_PATH="$HOME/.gem"
after you install RVM you still need few more steps:
Load RVM to the current shell:
source ~/.rvm/scripts/rvm
Usually this would not be needed if you close and open your terminal again
Install ruby:
rvm install ruby
Use ruby:
rvm use ruby
The last step is very important as your error message mentioned system ruby not the one controlled by RVM.
Make sure to update your system rubygems with this command : sudo gem update --system --no-user-install.
bundler use it instead your local version and your bundler version could be incompatible with your system rubygems.
It works for me ;)

json_pure/rubygems cyclic dependencies

I have an issue when trying to set up rvm, where gems weren't installing due to them being dependent on json_pure. I tried to install json_pure, but rubygems itself seems to depend on json_pure. I have tried removing all versions of json_pure, but rubygems still complains.
$ sudo gem install json_pure
/Library/Ruby/Site/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem json_pure (>= 0) (Gem::LoadError)
I have tried downloading the gem and installing it locally, but rubygems still complains about the dependency.
I had this exact problem, and the above solutions didn't work for me. (I don't use rvm, and re-installing RubyGems didn't resolve the issue.)
This is what I did to fix my setup on my Mac. (Ruby 1.8.6, Mac OS X 10.5.8)
1) Go to http://rubygems.org/gems/json_pure
2) Download the json_pure gem to ~/Downloads
3) cd ~/Downloads/
4) sudo gem install json_pure-1.4.6.gem
(You'll still see the "Could not find RubyGem json_pure" error, but the install does work. To double-check you can redo 'sudo gem install json_pure-1.4.6.gem' and you shouldn't see the error the second time.)
5) Verify that json_pure is now installed:
gem list
I fixed this issue by copying the json and json_pure gems and their specs from a working ruby directory into the .rvm gem directory of the broken ruby. Not sure why rubygems itself ever relies on another gem.
cp -r ~/.rvm/gems/ruby-1.8.7-p249/gems/json* ~/.rvm/gems/ruby-1.8.6-p399/gems/
cp -r ~/.rvm/gems/ruby-1.8.7-p249/specifications/json* ~/.rvm/gems/ruby-1.8.6-p399/specifications/
I can't understand if you are having an issue installing RVM or using RVM.
If you need to install RVM, don't use sudo.
Just type
$ gem install rvm
RubyGems will install it in your home directory.
Then, proceed with rvm-install and follow the instructions.
When using RVM, never use sudo.
This issue came about when I removed all the json-pure versions in my main $PATH. To resolve the issue I reloaded RubyGems 1.3.7 from source and was able to reinstall the json-pure gem. Note: I was not using RVM.
Steps:
1) Download RubyGem 1.3.7.tgz
2) Use these commands at the command prompt
tar xzvf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo /opt/local/bin/ruby setup.rb
3) Try a gem command
gem list
4) If it works, install the json-pure gem // might need to install the json gem also.
sudo gem install json
sudo gem install json-pure

RubyGems - my system can't seem to find any remote gems to install

Trying to install the 'less' gem. I type sudo gem install less as instructed at http://lesscss.org/, and I get the following error:
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find less (> 0) in any repository
Alright, so I figure maybe I just need to update RubyGems. Trying 'gem update --system' gets me
Updating RubyGems...
Attempting remote update of rubygems-update
ERROR: While executing gem ... (Gem::InstallError)
rubygems-update requires builder >= 0
Arrgh. Alright, then let's try 'sudo gem install builder':
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find builder (> 0) in any repository
Seems that no matter what gem I try to install, it can't be found in any repository. I check my environment, and rubyforge is listed:
RubyGems Environment:
- VERSION: 0.9.4 (0.9.4)
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- GEM PATH:
- /usr/local/lib/ruby/gems/1.8
- REMOTE SOURCES:
- http://gems.rubyforge.org
Any idea what's going on? I'm on OSX 10.4, and I installed Ruby 1.8.6 before this.
I think rubygems 1.3.x requires ruby 1.8.7 so you might install that first. Then update rubygems to 1.3.7. via gem update --system
The version of rubygems bundled in osx uses gemforge as its offical source of gems - this has since been replaced with gemcutter. You should be able to do
sudo gem update --system
To upgrade to update the latest version of ruby gems, which will then use gemcutter as the sources link
That's a really old version of rubygems! How did you install this?
Is it a manual install? If so, perhaps you could try a manual upgrade the same way.
Do the following:
sudo gem update --system
to update your install of RubyGems. Then, add the Github gem repository to your sources. I suggest github because you'll find a lot of useful things there:
sudo gem sources -a http://gems.github.com

Can't install gemcutter as a Ruby Gem source

I'm trying to install the thinking sphinx gem, which is on gemcutter.org
When I run the command
gem sources -a http://gemcutter.org
I get the error:
Error fetching http://gemcutter.org:
bad response Not Found 404 (http://gemcutter.org/specs.4.8)
If I change the above URL to http://gemcutter.org.specs.4.8.gz it finds a file. How do I tell rubygems to download with the .gz extension?
It looks like a temporary Gemcutter failure. It works fine to me.
Make sure you are running the latest RubyGems version and install the latest gemcutter gem.
$ gem install gemcutter --source http://gemcutter.org
With the gemcutter GEM you type gem tumble to add Gemcutter as source.
$ gem tumble
EDIT. I just noticed you are using a really outdated RubyGems version.
Update RubyGems first.
$ gem update --system
If it tells you there's nothing to update, you have a buggy version (RubyGems 1.2 selfupdate was buggy). Upgrade with the following command.
$ gem install rubygems-update
$ update_rubygems
Then add the source.
What version of Rubygems are you running (gem --version)? If less than 1.3.5, you may want to update Rubygems and try again. (gem update --system)
This is working for me with the following sources defined:
http://gems.rubyforge.org/
http://gems.github.com
as I said this is working for me:
gem install thinking-sphinx \
> --source http://gemcutter.org
If you're upgrading, you should read this:
http://freelancing-god.github.com/ts/en/upgrading.html
Successfully installed thinking-sphinx-1.3.2
Successfully installed activesupport-2.3.4
2 gems installed
Installing ri documentation for thinking-sphinx-1.3.2...
Installing ri documentation for activesupport-2.3.4...

Resources