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)
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.
@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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With