Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Very new to Bash scripting...

I am trying to setup a script that starts with a minimal CentOS 6 install and provisions it for Ruby development.


# Add PostgreSQL Repo
rpm -i http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-redhat91-9.1-5.noarch.rpm

# Add NginX Repo
echo '[nginx]' > /etc/yum.repos.d/nginx.repo
echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo
echo 'baseurl=http://nginx.org/packages/centos/6/$basearch/' >> /etc/yum.repos.d/nginx.repo
echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo
echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo

# Update
yum update -y

# Install NginX, PostgreSQL, and Ruby Dependencies
yum install -y nginx postgresql91-server postgresql91-contrib gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison piconv-devel sqlite-devel git-core

# PostgreSQL Post Install
service postgresql-9.1 initdb
chkconfig postgresql-9.1 on

# Install rbenv system wide install
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv

# Install ruby-build
git clone git://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

# Add rbenv to the path
echo '# rbenv setup - only add RBENV PATH variables if no single user install found' > /etc/profile.d/rbenv.sh
echo 'if [[ ! -d "${HOME}/.rbenv" ]]; then' >> /etc/profile.d/rbenv.sh
echo '  export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
echo '  export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
echo '  eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
echo 'fi'  >> /etc/profile.d/rbenv.sh
chmod +x /etc/profile.d/rbenv.sh


# Install latest Ruby
rbenv install 1.9.3-p286

# Set Global Ruby
rbenv global 1.9.3-p286

I am getting a rbenv: command not found error when it gets to the point where it uses rbenv because my shell needs refreshed/restarted for it to recognize the command. How can I accomplish this? Thanks.

share|improve this question
up vote 6 down vote accepted

You could try sourcing the new environment files. Looking above, I guess,

source /etc/profile.d/rbenv.sh


source ${HOME}/.rbenv

plus any other files that have been created, that you need including in the current shell.

share|improve this answer
Thanks. This did the trick. In my case only 'source /etc/profile.d/rbenv.sh' was needed. – CT. Oct 19 '12 at 15:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.