Reload .bashrc while vagrant

I am using a wrapper for Vagrant, and am trying to install rails using rbenv.

Following this tutorial:

https://gorails.com/setup/ubuntu/14.04

I came to this script working

# Update sources:
whoami
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev curl git-core sqlite3 libsqlite3-dev git libssl-dev


#install rbenv and Ruby 1.9.2
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
sudo mkdir /usr/local/share/ruby-build
~/.rbenv/plugins/ruby-build/install.sh
~/.rbenv/bin/rbenv install 2.1.2
~/.rbenv/bin/rbenv global 2.1.2

      

The above tutorial is used exec $SHELL

to add rbenv to $ PATH. I have this team bash

, source .bashrc

and more. Either they don't update the $ PATH variable, or they exit the script initialization earlier. So I have to call rbenv my full path right now. Is there a way to reload bash so that I can update $ PATH while the Vagrant script is serving?

+3


source to share


1 answer


Is there some reason other than just export PATH="$HOME/.rbenv/bin:$PATH"

your script as-is? This will change your environment for the current session. Alternatively, it should be used source ~/.bashrc

in your script after being added to the appropriate file ... If that doesn't work, something strange will happen.



Note that bash does not normally read the .bashrc file on startup. It does this on a specific basis when it is launched interactively, rather than as a login shell. Most bash program calls will be non-interactive. You can tell bash to read the file when invoked non-interactively by setting an environment variable BASH_ENV

before invoking the shell.

0


source







All Articles