Using Rubygems on Debian: Cannot install gems - ruby

I seem unable to install any gems. When I try something like sudo gem install rails or sudo gem install rdiscount I get the following errors:
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args` for nil:NilClass
Can anyone please help me figure out the cause of this problem?

It seems this you have not installed all required libs for. the ruby works, either install it for the debian, or use rvm and install ruby version you need with it from sources.

Related

How to fix 'cannot load such file -- socket' error on gem install

I'm not able to do gem install of any gem. When I try I get following error message
ERROR: Loading command: install (LoadError)
cannot load such file -- socket
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
I use MacOS and rvm for versioning. Also, of note is that reinstall of ruby with openssl didn't work (which is referred as a solution for this problem on some answers on the internet).
Try this:
1. gem install bundler
2. bundle install

Why does 'gem update --system' give me an error

I'm going through a server setup guide and I'm trying to download rubygems:
gem update --system
I am on version 2.2.2 of ruby gems, version 2.1.2p95 of ruby, and ubuntu 14.04, but it doesn't appear to be working. Looking further into this, I found an alternative to the command
here on their official site.
However, when I run:
~/ruby-src/ruby-2.1.2$ sudo gem install rubygems-update
I'm still getting the same error which is:
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

JRuby 1.7.6 cannot install gems

I am using RVM and Homebrew on OS X Mavericks. JRuby 1.7.6 installs, but I cannot install any gems. I believe that JRuby comes with a semi-complete version of openssl. I have tried using http for gem sources, and even downloaded the gem for a local install. I see this same error regardless of gem locality or gem source.
$ jruby -S gem install bundler --trace
ERROR: Loading command: install (LoadError)
load error: openssl -- java.lang.IncompatibleClassChangeError: Implementing class
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
Others Rubies (1.8.7, 1.9.3, 2.0.0) are working without issue in RVM.
You need to use the ruby first:
rvm use jruby-1.7.6
It will ensure all jruby gems are available for it.
Is there a proxy blocking your access to the gemserver?
jruby -S gem source --add http://rubygems.org?

Zlib keeps causing problems in new ubuntu server/rvm/gemset

I've just installed RVM on a new ubuntu 10.04 LTS server and one ruby, 1.9.2-p180. I've made a new gemset in my project folder, which has a Gemfile. I realised that in order to install the gems in the gemfile, i need to install bundler, so i did
gem install bundler
but, i get this error:
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
I googled around a bit and tried this:
rvm pkg install zlib
which installed ok but didn't solve the problem. I also tried installing the rake gem but got the same error trying to do that.
Kind of stuck...any suggestions? thanks, max
EDIT - btw, i can install the bundler gem fine outside of rvm, ie using system ruby.
EDIT2 - I got past this problem by removing the version of ruby, then installing it again with zlib:
rvm remove 1.9.2-p180
rvm install 1.9.2-p180 -C --with-zlib-dir=$rvm_path/usr
Now i can install bundler and all my gems ok. Hooray. Except, when i try to open my rails env (with rails s, rails c or rake db:create) i get this fatal error:
/home/max/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/
1.9.1/rubygems/custom_require.rb:36:in `require':
/lib/libz.so.1: version `ZLIB_1.2.3.3' not found (required by
/home/max/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/i686-linux/zlib.so) -
/home/max/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/i686-linux/zlib.so (LoadError)
So, still not out of the woods zlib-wise. I don't know why zlib is causing such problems, any ideas?
Sorted it!
Running locate libz gives me
/home/max/.rvm/src/zlib-1.2.5/libz.a
/home/max/.rvm/src/zlib-1.2.5/libz.so
/home/max/.rvm/src/zlib-1.2.5/libz.so.1
/home/max/.rvm/src/zlib-1.2.5/libz.so.1.2.5
/home/max/.rvm/usr/lib/libz.a
/home/max/.rvm/usr/lib/libz.so
/home/max/.rvm/usr/lib/libz.so.1
/home/max/.rvm/usr/lib/libz.so.1.2.5
/lib/libz.so.1
/lib/libz.so.1.2.3.3
I just noticed that the version of libz in lib is 1.2.3.3 while the version i installed with rvm is 1.2.5. Is this the problem perhaps? In the /lib folder, zlib.so.1 is symlinked to it's neighbour file libz.so.1.2.3.3.
I tried symlinking it to /home/max/.rvm/usr/lib/libz.so.1.2.5 instead:
sudo rm /lib/libz.so.1
sudo ln -s /home/max/.rvm/src/zlib-1.2.5/libz.so.1 /lib/libz.so.1
and, that seems to have worked... i still don't really understand exactly what went wrong, though, so would welcome a more insightful solution/explanation :)

Using RubyGems on ubuntu server

I have installed Ruby on Rails on my Ubuntu 10.04 Server by official tutorial: https://help.ubuntu.com/10.04/serverguide/C/ruby-on-rails.html
But I have some troubles with it. Please, help me!
1) I can't install ANY gem!
sudo gem install sqlite3-ruby
returns
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native
extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:3:in `require': no such
file to load -- mkmf (LoadError) from
extconf.rb:3
Gem files will remain installed in
/var/lib/gems/1.8/gems/sqlite3-1.3.3
for inspection. Results logged to
/var/lib/gems/1.8/gems/sqlite3-1.3.3/ext/sqlite3/gem_make.out
2) When i'am trying to get Rails version by command
rails -v
Server prints:
getopt: invalid option -- 'v'
Terminating...
If you are not set on using the packages in the Ubuntu repos(and I see no reason why you'd be), I'd suggest following this guide:
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you
Consider going through and making sure your sqlite3 libraries are installed. It looks as though you may be missing the required dependencies to build your gem. In this case you might try running this before installing your gem:
sudo apt-get install libsqlite3-dev
Also, try
rails --version
instead.

Resources