info | twitter | github
J-_-L | Writings on Ruby Programming
29.04.10 29.06.11
28 comments

RubyBuntu -2- Troubleshooting common Ruby ubuntu problems

A common Ruby experience on ubuntu: You get some stupid error, saying something would be missing – and you don’t know what to do…

…so here are some of the error messages and how to get rid of them.

Common problems when using ubuntu repositories

openssl (1.8)

/var/lib/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:271:in `require_frameworks': no such file to load -- net/https (RuntimeError)
sudo apt-get install libopenssl-ruby

openssl (1.9.1)

/var/lib/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:271:in `rescue in require_frameworks': no such file to load -- net/https (RuntimeError)
sudo apt-get install libopenssl-ruby1.9.1

ruby1.8-dev

ERROR: Failed to build gem native extensions.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:8:in `require': no such file to load -- mkmf (LoadError)
sudo apt-get install ruby1.8-dev

ruby1.9.1-dev

ERROR: Failed to build gem native extensions.
/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
sudo apt-get install ruby1.9.1-dev

build-essential

make: g++: Command not found
sudo apt-get install build-essential

wrong gem path settings

The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails

Add export PATH=/var/lib/gems/1.8/bin:$PATH to the ~/.bash.rc file and restart your terminal (adjust the version number, if needed).

sudo some_gem is not possible

sudo: rake: command not found

See here.

Common problems when built from source

libreadline

Strange irb behavior or

/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
/usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `require':LoadError: no such file to load -- readline

Navigate to the Ruby source and enter:

sudo apt-get install libreadline5-dev
cd ext/readline
ruby extconf.rb
make
sudo make install

zlib

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError)
/usr/local/lib/ruby/1.9.1/rubygems/package.rb:10:in `require': no such file to load -- zlib (LoadError)

Navigate to the Ruby source and enter:

sudo apt-get install zlib1g-dev
cd ext/zlib
ruby extconf.rb
make
sudo make install

openssl

/var/lib/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:271:in `require_frameworks': no such file to load -- openssl (RuntimeError)
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:271:in `rescue in require_frameworks': no such file to load -- openssl (RuntimeError)

Navigate to the Ruby source and enter:

sudo apt-get install libssl-dev
cd ext/openssl
ruby extconf.rb
make
sudo make install

Gems

sqlite3

no such file to load -- sqlite3
Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
sudo apt-get install sqlite3 libsqlite3-dev
sudo gem install sqlite3-ruby

MySQL

no such file to load -- mysql
Error installing mysql:
ERROR: Failed to build gem native extension.
sudo apt-get install mysql-server libmysqlclient15-dev
sudo gem install mysql

PostgreSQL

Error installing pg:
ERROR: Failed to build gem native extension.
sudo apt-get install libpq-dev
sudo gem install pg

nokogiri

Error installing nokogiri:
ERROR: Failed to build gem native extension.
sudo apt-get install libxml2 libxml2-dev libxslt1-dev
sudo gem install nokogiri

RMagick

Error installing rmagick:
ERROR: Failed to build gem native extension.
...
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in ...
sudo apt-get install libmagickwand-dev
sudo gem install rmagick

memcached

Error installing memcached:
ERROR: Failed to build gem native extension.
...
rlibmemcached_wrap.c:13633: error: ‘SASL_OK’ undeclared (first use in this function)
make: *** [rlibmemcached_wrap.o] Error 1
sudo apt-get install libsasl2-dev libsasl2-dev
sudo gem install memcached

fcgi

Error installing fcgi:
ERROR: Failed to build gem native extension.
sudo apt-get install libfcgi-dev
sudo gem install fcgi

Problems solved?

Hopefully. If you still have problems, feel free to ask in the comments. You could also try to do a new installation. When everything is working, you can start customizing your command line :)

Creative Commons License

Comments

14.05.10

joe

Pretty helpful guys, thanks!

Perhaps you may add this one (concerning postgre and therefore heroku):

Error installing pg:
ERROR: Failed to build gem native extension.

sudo apt-get install libpq-dev
sudo gem install pq

14.05.10

anonym

Ops I got a typo at the last line: should have been pg ;)

14.05.10

J-_-L

Added postgres, thank you joe.

12.07.10

anonym

Incredibly helpful. Thanks a lot!

21.07.10

Jaz

Thanks for help. Got mysql working with Ruby after much searching on internet and a complete reinstall.

Owe you a pint...

06.08.10

anonym

I have done the "sudo apt-get install libpq-dev" comand and get:

Lendo listas de pacotes... Pronto
Construindo árvore de dependências
Lendo informação de estado... Pronto
libpq-dev já é a versão mais nova.
libpq-dev configurado para instalar manualmente.
Os seguintes pacotes foram automaticamente instalados e não são mais requeridos:
linux-headers-2.6.32-21 linux-headers-2.6.32-21-generic
Use 'apt-get autoremove' para removê-los.
0 pacotes atualizados, 0 pacotes novos instalados, 0 a serem removidos e 2 não atualizados.

In other words, it was already installed.

Then the comand "sudo gem install pg" and gets the same error:

Error installing pg:
ERROR: Failed to build gem native extension.


What should I do?

06.08.10

anonym

I have done:

$ export PATH=/var/lib/gems/1.8/bin:$PATH

then, i could install pg gem…
but i still get Please install the jdbcpostgresql adapter: `gem install activerecord-jdbcpostgresql-adapter` (no such file to load — java)
when i try to create databases

20.08.10

Saul

Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:271:in `require_frameworks': no such file to load -- openssl (RuntimeError)
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:134:in `process'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
from /home/saul/Sites/my_app/config/environment.rb:9
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:84
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:3

Help!!!!

20.08.10

Saul

Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:271:in `require_frameworks': no such file to load -- openssl (RuntimeError)
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:134:in `process'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
from /home/saul/Sites/my_app/config/environment.rb:9
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:84
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/server:3

Help!!!!

30.08.10

J-_-L

did you try <code>sudo apt-get install libopenssl-ruby</code> ?

27.09.10

pandora beads

Pretty helpful guys, thanks!
http://www.ukpandora.net/
Perhaps you may add this one (concerning postgre and therefore heroku):

02.10.10

roberto

Many thanks. Solved

21.10.10

Rusho

It was very helpful. Thanks.

23.10.10

djudji

Thank you, it is great to have some problems solved, I've been having a headache about using ruby on Ubuntu (a newcomer I am :) ).

20.11.10

chowder

Thanks! Solved :)

01.12.10

elsabio

This looks fundamental but I have not found the reason yet:

/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- initializer (LoadError)

Any ideas how to identify and correct this one please?

08.12.10

J-_-L

Hi elsabio,
what are you trying to use/install? What system do you use? How did you install Ruby?

29.01.11

mike

saved me a lot of time. My problem solved now. Thanks a lot.

05.05.11

lacemaker

Thanks!

11.05.11

anonym

ghmjhgjhgjgh

11.05.11

anonym

Hi,
Can Anyone suggest me the solution for following errors?

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- mysql (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from me_billing_script_10-05.rb:4

I am getting this error while running my script. thanks in advance.

Regards,
Nilesh.

11.05.11

J-_-L

Which version of the mysql gem do you have installed?

17.07.11

Josh

Holy shit this was helpful. Thanks a ton.

18.10.11

Maado

Great Thx .

27.10.11

sohussain

Excellent post! being one of those who develop completely on ubuntu these posts are super duper awesome! please keep the ubuntu rails developer love coming!

01.11.11

cj

great post.....thanks a lot!!!

12.01.12

Guy

Thanks this helped alot!

13.12.12

mark

Holy shit this was helpful my problem solved now. Thanks a lot.