source .rbenvrc breaks for non-interactive shells
Installing rbenv with:
rbenv::install { $user:
require => User[$user],
rc => '.bashrc',
}
...works not for non-login shells:
deployer@precise32:~$ which ruby
/home/deployer/.rbenv/shims/ruby
deployer@precise32:~$ exit
logout
Connection to 127.0.0.1 closed.
$ ssh [email protected] -p 2222
which ruby
$ echo $?
1
...because .bashrc does only source .rbenvrc for interactive shells:
deployer@precise32:~$ egrep -A 1 '(interactive|rbenv)' .bashrc
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
--
source /home/deployer/.rbenvrc
Placing the source statement earlier would of course solve this.
This issue came up during a capistrano deployment when running bundler over ssh on the deployment machine.
PS: great module (saved me a ton of time)!
Did you try using the .profile instead of .bashrc? This should fix your problem.
@alup Thanks for having a look at this!
Unfortunately bash doesn't care about a my .profile when running over ssh (see bash(1)):
Bash attempts to determine when it is being run with its standard input connected to a net-
work connection, as when executed by the remote shell daemon, usually rshd, or the secure
shell daemon sshd. If bash determines it is being run in this fashion, it reads and exe-
cutes commands from ~/.bashrc and ~/.bashrc, if these files exist and are readable.
I'll fix this in my fork. Just send me a line, if you want to have a pull request.
@bjoernalbers Is this still an issue?
I was just having difficulties with my rbenv install command and switching over to @bjoernalbers fork solved my problem without having to change anything else. This was with a CentOS 6.3 image.
I added this step to my manifest, it may be worth adding into the rbenv module itself. It worked around the .bashrc / .bash_profile / .profile problem for me.
file { '/etc/profile.d/rbenv.sh':
ensure => present,
mode => '0644',
owner => 'root',
group => 'root',
content => '[ -e ~/.rbenvrc ] && . ~/.rbenvrc'
}
I was seeing the .profile get loaded on Ubuntu 14.x but not on CentOS 6.5 and @ghost's code to init.pp and then 'require ::rbenv' to rbenv::install makes it work on my nodes. I'll submit a PR if I get some time.