0

I want to automate the installation of perlbrew into the vagrant box. I use .sh file to accomplish this.

provision.sh

apt-get update
sudo -H -u vagrant bash -c " \curl -kL https://install.perlbrew.pl | bash"
sudo -u vagrant bash -c "source ~/perl5/perlbrew/etc/bashrc"

After ssh into the vagrant i expect that

$ which perlbrew

will return

/home/vagrant/perl5/perlbrew/bin/perlbrew

but unfortunately it returns nothing.

Kamran
  • 71
  • 1
  • 1
  • 7

1 Answers1

1

There is no way the settings applied by your source ~/perl5/perlbrew/etc/bashrc command would be visible in another bash session (and a SSH session executes a new bash process).

You need to add the command source ~/perl5/perlbrew/etc/bashrc to one of the bash "rc" files.

  • For a single user with the following command:

    echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc
    
  • For all users with the following command:

    echo "source ~/perl5/perlbrew/etc/bashrc" >> /etc/bash.bashrc
    

This way every time a new bash session is started, it will run source ~/perl5/perlbrew/etc/bashrc and apply the settings.

techraf
  • 64,883
  • 27
  • 193
  • 198