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

Why /etc/profile.d/rbenv.sh and not /etc/bash.bashrc? #103

Open
andrewhavens opened this issue Jun 3, 2014 · 3 comments
Open

Why /etc/profile.d/rbenv.sh and not /etc/bash.bashrc? #103

andrewhavens opened this issue Jun 3, 2014 · 3 comments

Comments

@andrewhavens
Copy link

I'm working with someone on a chef project. He suggested we add some code to initialize rbenv for all users. I thought this cookbook was already doing that by adding the /etc/profile.d/rbenv.sh file. He said that those files only load for interactive sessions, but not all (i.e. ssh $node "command").

Here's the code that he wrote. I hate to have duplicate/unnecessary code. Is this something that can/should be incorporated into the official rbenv cookbook, or is it an appropriate supplement to the cookbook?

# install Ruby
include_recipe 'rbenv::default'
include_recipe 'rbenv::ruby_build'

rbenv_ruby '2.1.2' do
  ruby_version '2.1.2'
  global true
end

rbenv_gem 'bundler' do
  version '1.6.2'
  ruby_version '2.1.2'
  action :install
end

# initialize rbenv for all users

execute 'add rbenv to $PATH' do
  command 'echo \'export PATH="/opt/rbenv/bin:$PATH"\' >> /etc/bash.bashrc'
  not_if 'grep -F "rbenv/bin" /etc/bash.bashrc'
end

execute "add rbenv to global .bashrc" do
  command 'echo \'eval "$(rbenv init -)"\' >> /etc/bash.bashrc'
  not_if 'grep -F "rbenv init" /etc/bash.bashrc'
end

execute "add rbenv to global .profile" do
  command 'echo \'eval "$(rbenv init -)"\' >> /etc/profile'
  not_if 'grep -F "rbenv init" /etc/profile'
end
@andrewhavens
Copy link
Author

I found this rbenv wiki article which list the various initialization scenarios https://github.com/sstephenson/rbenv/wiki/Unix-shell-initialization#shell-init-files. I don't see /etc/profile.d in the list, so I'm not sure where it falls in the load order.

I also found this helpful article which lists the various profile/rc files: http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/

@nicka
Copy link

nicka commented Apr 14, 2015

@andrewhavens May I ask what you ended up using?

@andrewhavens
Copy link
Author

@nicka Sorry, I don't even remember! I'm not an expert on this kind of stuff so I deferred to the person responsible for implementation.

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

2 participants