Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rbenv: command not found in Jenkins execute shell after moving to rbenv from RVM

I moved to rbenv from RVM on Ubuntu Server.

When I use RVM, there is no trouble using bundle. After moving to rbenv I got a "command not found" error in Jenkins' execute shell.

I imploded and removed RVM and removed all RVM related lines from ~/.bashrc'. I still get this error after using:

rvm implode
rm ~/.rvm -rf
rm ~/.rvmrc 

gem install bundler
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc

. ~/.bashrc

rbenv versions

jenkins@testserver:~/jobs/myjob/workspace$ rbenv versions

* 1.9.3-p374 (set by RBENV_VERSION environment variable)
like image 219
pegatron Avatar asked Mar 13 '13 10:03

pegatron


2 Answers

You seem to have installed rbenv correctly in your shell. However, if Jenkins doesn't source your ~/.bashrc as well, it won't be aware there's rbenv on your system. So in Jenkins, you have to ensure that your PATH for executing commands also includes $HOME/.rbenv/bin and $HOME/.rbenv/shims.

There's no need to use eval "$(rbenv init -)" in Jenkins; that's only useful for interactive shells.

like image 115
mislav Avatar answered Nov 15 '22 07:11

mislav


@mislav's answer is probably right, but what actually worked for me was this:

sh '''
#!/bin/bash
export PATH=$PATH:/usr/local/bin:$HOME/.rbenv/bin:$HOME/.rbenv/shims
eval "$(rbenv init -)"
rbenv local
rbenv rehash
'''

In fact, I wasn't seeing rbenv as /usr/local/bin wasn't in my $PATH.

like image 22
GabLeRoux Avatar answered Nov 15 '22 07:11

GabLeRoux