Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source .rbenvrc breaks for non-interactive shells #40

Open
bjoernalbers opened this issue Oct 18, 2012 · 7 comments
Open

source .rbenvrc breaks for non-interactive shells #40

bjoernalbers opened this issue Oct 18, 2012 · 7 comments

Comments

@bjoernalbers
Copy link

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.

@bjoernalbers
Copy link
Author

This issue came up during a capistrano deployment when running bundler over ssh on the deployment machine.

@bjoernalbers
Copy link
Author

PS: great module (saved me a ton of time)!

@alup
Copy link
Owner

alup commented Oct 21, 2012

Did you try using the .profile instead of .bashrc? This should fix your problem.

@bjoernalbers
Copy link
Author

@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 bjoernalbers mentioned this issue Nov 2, 2012
@fgrehm
Copy link
Contributor

fgrehm commented Jan 29, 2013

@bjoernalbers Is this still an issue?

@cloudshark
Copy link

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.

@ghost
Copy link

ghost commented May 29, 2013

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'
}

@nvalentine-puppetlabs
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants