ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

reposman.rb activeresource error when run under crontab

Added by Jason Bell at 2011-12-27 05:50 pm

Hello!

I'm running chiliproject under the user 'chiliproject' using RVM in a localized install to manage the gems and such. Currently, everything is working perfectly... except when reposman.rb is run from crontab, I get the following error:

This script requires activeresource.
Run 'gem install activeresource' to install it.

my crontab entry looks like this:

10 * * * * /opt/chiliproject/extra/svn/reposman.rb -r 192.168.1.12 -s /srv/svn -o chiliproject -g daemon -u http://192.168.1.12/svn/ -k xxx -v >> /opt/chiliproject/log/reposman.log

When I run this command manually as the chiliproject user, it works perfectly. No errors, and the repositories are created and registered properly.

chiliproject@Atlas:/opt/chiliproject$ /opt/chiliproject/extra/svn/reposman.rb -r 192.168.1.12 -s /srv/svn -o chiliproject -g daemon -u http://192.168.1.12/svn/ -k xxx
repository /srv/svn/reposman-test registered in Redmine with url http://192.168.1.12/svn/reposman-test
repository /srv/svn/reposman-test created

I'm new to ruby, so I'm probably just not doing something correctly. Can anyone tell me what would cause reposman.rb to not see the activeresource gem only when being run from crontab? Below, I've tried to include anything about my environment that I thought could be helpful:

@
chiliproject@Atlas:/opt/chiliproject$ rvm info

ruby-1.8.7-p352@chiliproject:

system:
uname: "Linux Atlas 2.6.37.6 #3 SMP Sat Apr 9 22:49:32 CDT 2011 x86_64 AMD Phenom(tm) 8750 Triple-Core Processor AuthenticAMD GNU/Linux"
bash: "/usr/bin/bash => GNU bash, version 4.1.10(2)-release (x86_64-slackware-linux-gnu)"
zsh: "/bin/zsh => zsh 4.3.11 (x86_64-slackware-linux-gnu)"
rvm:
version: "rvm 1.10.0 by Wayne E. Seguin (xxx) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2011-06-30"
platform: "x86_64-linux"
patchlevel: "2011-06-30 patchlevel 352"
full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]"
homes:
gem: "/home/chiliproject/.rvm/gems/ruby-1.8.7-p352@chiliproject"
ruby: "/home/chiliproject/.rvm/rubies/ruby-1.8.7-p352"
binaries:
ruby: "/home/chiliproject/.rvm/rubies/ruby-1.8.7-p352/bin/ruby"
irb: "/home/chiliproject/.rvm/rubies/ruby-1.8.7-p352/bin/irb"
gem: "/home/chiliproject/.rvm/rubies/ruby-1.8.7-p352/bin/gem"
rake: "/home/chiliproject/.rvm/gems/ruby-1.8.7-p352@chiliproject/bin/rake"
environment:
PATH: "/home/chiliproject/.rvm/gems/ruby-1.8.7-p352@chiliproject/bin:/home/chiliproject/.rvm/gems/ruby-1.8.7-p352@global/bin:/home/chiliproject/.rvm/rubies/ruby-1.8.7-p352/bin:/home/chiliproject/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/mysql/bin:/usr/lib64/java/bin:/usr/lib64/qt/bin:/usr/share/texmf/bin:."
GEM_HOME: "/home/chiliproject/.rvm/gems/ruby-1.8.7-p352@chiliproject"
GEM_PATH: "/home/chiliproject/.rvm/gems/ruby-1.8.7-p352@chiliproject:/home/chiliproject/.rvm/gems/ruby-1.8.7-p352@global"
MY_RUBY_HOME: "/home/chiliproject/.rvm/rubies/ruby-1.8.7-p352"
IRBRC: "/home/chiliproject/.rvm/rubies/ruby-1.8.7-p352/.irbrc"
RUBYOPT: ""
gemset: "chiliproject"

chiliproject@Atlas:/opt/chiliproject$ bundle list
Gems included by the bundle: * actionmailer (2.3.14) * actionpack (2.3.14) * activerecord (2.3.14) * activeresource (2.3.14) * activesupport (2.3.14) * bundler (1.0.21) * coderay (0.9.8) * fastercsv (1.5.4) * i18n (0.4.2) * json (1.6.3) * mysql2 (0.2.18) * net-ldap (0.2.2) * rack (1.1.2) * rails (2.3.14) * rake (0.9.2.2) * rdoc (3.12) * ruby-openid (2.1.8) * rubytree (0.5.3)
@


Replies (2)

RE: reposman.rb activeresource error when run under crontab - Added by Holger Just at 2011-12-27 05:57 pm

Cron typically runs with a very restricted environment. That doesn't include the shell extensions required for RVM.

I typically run reposman.rb from a custom script like so:

#!/bin/bash

# load RVM
source /home/chiliproject/.rvm/scripts/rvm
# optional: select the correct ruby and gemset
#rvm 1.8.7@chiliproject

# run reposman
/opt/chiliproject/extra/svn/reposman.rb -r 192.168.1.12 -s /srv/svn -o chiliproject -g daemon -u http://192.168.1.12/svn/ -k xxx -v >> /opt/chiliproject/log/reposman.log

This script can then be scheduled to be run by cron. It sets up RVM and then runs your command.

--Holger

RE: reposman.rb activeresource error when run under crontab - Added by Jason Bell at 2011-12-27 07:46 pm

Thanks!

I was digging through the RVM website (Specifically http://beginrescueend.com/integration/cron/) and came to the same conclusion, albeit with a slightly different approach. This also works, since it calls the RVM wrapper for the specific gemset prior to running reposman.rb:

10 * * * * /home/chiliproject/.rvm/bin/ruby-1.8.7-p352\@chiliproject /opt/chiliproject/extra/svn/reposman.rb -r 192.168.1.12 -s /srv/svn -o chiliproject -g daemon -u http://192.168.1.12/svn/ -k xxx >> /opt/chiliproject/log/reposman.log

I now have a fully functional chiliproject with automated subversion control on slackware. :D

(1-2/2)