Marketing digital. Making results.

Rails console not starting up in Ubuntu 11.10

On trying to launch the Rails console from the command line by running the “rails console” command I got this error:

/home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /media/DATA/Development/www/cakephp/cake/console in PATH, mode 040777
/home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/completion.rb:9:in `require’: no such file to load — readline (LoadError)
from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/completion.rb:9:in `’
from /home/abou/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.11/lib/rails/commands/console.rb:3:in `require’
from /home/abou/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.11/lib/rails/commands/console.rb:3:in `’
from /home/abou/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.11/lib/rails/commands.rb:20:in `require’
from /home/abou/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.11/lib/rails/commands.rb:20:in `’
from script/rails:6:in `require’
from script/rails:6:in `’


So the issue was that for some reason, my install of the readline library was not getting picked up in my RVM 1.9.1 Ruby install, even thought i had these libraries installed through Aptitude. The next three hours were spent practicing extreme skills of google fu, with various workarounds that did not work for me, but this StackExchange post had something that worked for me, with some tweaks of course:

Edit ~/.rvm/scripts/functions/pkg file and remove this piece of code (Lines 65-81):

 if [[ "${rvm_skip_autoreconf_flag:-0}" == 0 ]] &&
which autoreconf >/dev/null 2>&1 &&
which libtoolize >/dev/null 2>&1 &&
[[ -f configure.ac || -f configure.in ]]
then
if [[ -z "${rvm_autoconf_flags:-}" ]]
then
if uname -s | grep -iE ‘cygwin|mingw’ >/dev/null
then # no symlinks on windows :(
rvm_autoconf_flags=”-ivf”
else
rvm_autoconf_flags=”-is –force”
fi
fi
__rvm_run “$package/autoreconf” “autoreconf ${rvm_autoconf_flags}” \
“Prepare $package in $rvm_src_path/$package-$version.”
fi

Now install the REE Dependencies libraries, which include Readline:

rvm pkg install ree_dependencies 

Now uninstall 1.9.2

rvm remove 1.9.2

Now undo the code deletion you did in the pkg file

Reinstall 1.9.2

rvm install 1.9.2

You should be good. I wasn’t. The post recommended reinstalling 1.9.2 using the following command, which i think was the source of my issue:

rvm install 1.9.2 –with-readline-dir=$rvm_usr_path –with-iconv-dir=$rvm_usr_path –with-zlib-dir=$rvm_usr_path –with-openssl-dir=$rvm_usr_path

On running “rails console” again, i got this error:

/home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’: no such file to load — zlib (LoadError)     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:7:in `<top (required)>’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/package.rb:78:in `<top (required)>’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/format.rb:7:in `<top (required)>’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:7:in `<top (required)>’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler/source.rb:3:in `<top (required)>’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler/dsl.rb:14:in `initialize’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler/dsl.rb:6:in `new’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler/dsl.rb:6:in `evaluate’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler/definition.rb:17:in `build’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler.rb:138:in `definition’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler.rb:126:in `load’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler.rb:110:in `setup’     from /home/abou/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.22/lib/bundler/setup.rb:7:in `<top (required)>’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require’     from /home/abou/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require’     from /media/DATA/Development/rails_projects/demo_app/config/boot.rb:6:in `<top (required)>’     from <internal:lib/rubygems/custom_require>:29:in `require’     from <internal:lib/rubygems/custom_require>:29:in `require’     from script/rails:5:in `<main>’  

I had again to remove 1.92. and reinstall it with the argument less syntax to get it to work. Pfff….