Skip to content

what actually happens when l do rbenv init - without shell parameter? #1473

Answered by mislav
laptopmutia asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, the eval ... rbenv init line is not meant for cronjobs or other noninteractive scripts. It's only meant to be loaded into an interactive shell.

If you just want automatic Ruby version switching, add ~/.rbenv/shims to PATH instead of ~/.rbenv/bin. Adding ~/.rbenv/bin to PATH is only useful if your script needs to call the rbenv command, which your cron job (and most other scripts) don't have to ever do. https://github.com/rbenv/rbenv#how-rbenv-hooks-into-your-shell

For example:

1 12 * * * export PATH="$HOME/.rbenv/shims:$PATH"; cd [location of app]; ruby [app].rb

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by laptopmutia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants