theKindOfMe

February 14, 2011

Fixing: /irb/completion.rb:9:in `require’: no such file to load — readline (LoadError) on rvm

Filed under: Uncategorized — Tags: , , , , , — yasi8h @ 10:25 am

Got this error to in one of the staging servers:

$ rails c production

/home/jooolaesa/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/irb/completion.rb:9:in `require’: no such file to load — readline (LoadError)
from /home/jooolaesa/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/irb/completion.rb:9:in `’
from /home/jooolaesa/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.0/lib/rails/commands/console.rb:3:in `require’
from /home/jooolaesa/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.0/lib/rails/commands/console.rb:3:in `’
from /home/jooolaesa/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.0/lib/rails/commands.rb:20:in `require’
from /home/jooolaesa/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.0/lib/rails/commands.rb:20:in `’
from script/rails:6:in `require’
from script/rails:6:in `’

It will appear if your ruby installation is not compiled with readline library. The solution is to recompile it with readline. If you are using RVM to manage your ruby installations you would go about doing it like this.

rvm package install readline

rvm remove 1.9.2 # note that 1.9.2 must be replaced with whatever ruby installation that you are going to recompile with readline support

rvm install 1.9.2 –with-readline-dir=$rvm_path/usr

Thats it!

Sources:

http://rbjl.net/20-rubybuntu-2-troubleshooting-common-ruby-ubuntu-problems
http://rvm.beginrescueend.com/packages/readline/

Advertisements

October 16, 2010

Task Scheduling with Cron, RVM and Rails

Filed under: Uncategorized — Tags: , , , — yasi8h @ 4:00 am

I wanted to do something every hour in my rails app. Basically a scheduled task. So i looked around and there were some plugins. But i choose to go with plain old cron. This should be a very straight forward task. However there are some pitfalls to be aware of. Specially if you are using RVM which depends on some environmental variables that are set on the shell. I created a bash script that is called from corn as scheduled. If you do the same be sure to make the script executable. chmod +x your_script.sh

my crontab -e looks like this

# m h dom mon dow command
#task1
0,30 05-07 * * * /home/foobar/script task1
0,10,20,30,40,50 08-18 * * * /home/foobar/script task1
0,30 19-21 * * * /home/foobar/script task1
#task2
0,30 19-21 * * * /home/foobar/script task2
#clean up the logs # once a week every saturday, at 00:00 (midnight)
0 0 * * 6 /home/foobar/script task3

for clean code get the gist

I have scheduled three tasks here. I am calling the same script with different arguments.

The script.

Note the source statement in the beginning. This loads RVM. And i am using the rails runner to call the methods i want to. These are located in some model classes within my rails app. Using the runner is just one option, but there are many you can use. Take look at here for more information on this topic.
If you are interested in using a gem to do the scheduling for you. Take a look at this.
After writing this i found some more post on the net that shows some what more elegant and better ways of doing the same thing. I think you should definitely give them a read.

Blog at WordPress.com.