J-_-L
code needs smilies
29.04.10 14.05.10
10 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

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 sudo apt-get install libopenssl-ruby ?

03.09.10
11|

you?

name:
www:
7plus3: