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 :)
joe | May 14, 2010
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
Anonymous | May 14, 2010
Ops I got a typo at the last line: should have been pg ;)
J-_-L | May 14, 2010
Added postgres, thank you joe.
Anonymous | July 12, 2010
Incredibly helpful. Thanks a lot!
Jaz | July 21, 2010
Thanks for help. Got mysql working with Ruby after much searching on internet and a complete reinstall.
Owe you a pint...
Anonymous | August 06, 2010
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?
Anonymous | August 06, 2010
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
Saul | August 21, 2010
Booting WEBrick
=> Rails 2.3.8 application starting on https://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!!!!
Saul | August 21, 2010
Booting WEBrick
=> Rails 2.3.8 application starting on https://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!!!!
J-_-L | August 30, 2010
did you try <code>sudo apt-get install libopenssl-ruby</code> ?
pandora beads | September 27, 2010
Pretty helpful guys, thanks!
https://www.ukpandora.net/
Perhaps you may add this one (concerning postgre and therefore heroku):
roberto | October 02, 2010
Many thanks. Solved
Rusho | October 21, 2010
It was very helpful. Thanks.
djudji | October 23, 2010
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 :) ).
chowder | November 20, 2010
Thanks! Solved :)
elsabio | December 01, 2010
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?
J-_-L | December 08, 2010
Hi elsabio,
what are you trying to use/install? What system do you use? How did you install Ruby?
mike | January 29, 2011
saved me a lot of time. My problem solved now. Thanks a lot.
lacemaker | May 05, 2011
Thanks!
Anonymous | May 11, 2011
ghmjhgjhgjgh
Anonymous | May 11, 2011
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.
J-_-L | May 11, 2011
Which version of the mysql gem do you have installed?
Josh | July 17, 2011
Holy shit this was helpful. Thanks a ton.
Maado | October 18, 2011
Great Thx .
sohussain | October 27, 2011
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!
cj | November 01, 2011
great post.....thanks a lot!!!
Guy | January 12, 2012
Thanks this helped alot!
mark | December 13, 2012
Holy shit this was helpful my problem solved now. Thanks a lot.