Gem not found in Ruby cron job in RVM env

后端 未结 3 1710
再見小時候
再見小時候 2020-12-30 13:48

I\'m trying to run a simple ruby script on my old PPC machine running 10.5 in an RVM environment.

Searching on SO, I\'ve followed the chosen answer from this post.

3条回答
  •  执笔经年
    2020-12-30 14:18

    To load default RVM ruby environment for cron jobs, here is what I setup for user-mode RVM, assume the user is ohho, home folder is /home/ohho. To edit, enter crontab -e in command line:

    MAILTO=""
    SHELL=/bin/bash
    BASH_ENV=/home/ohho/.bash_profile
    HOME=/home/ohho
    
    * * * * * rails -v > /home/ohho/env.txt
    

    The last line is for testing rails (if installed) can be invoked properly. You should also check whether ~/.bash_profile loads the RVM environment (which is default for bash).

    A detail explanation of SHELL and BASH_ENV can be found in Daniel's answer.

提交回复
热议问题