I use Vagrant to create boxes with python, pip, virtualenv, virtualenvwrapper and some requirements. The reverse shell script adds the necessary lines for virtualenvwrapper to .bashrc . He does a very basic check that they are not there so that they do not duplicate them with each position:
if ! grep -Fq "WORKON_HOME" /home/vagrant/.bashrc; then echo 'export WORKON_HOME=/home/vagrant/.virtualenvs' >> /home/vagrant/.bashrc echo 'export PROJECT_HOME=/home/vagrant/Devel' >> /home/vagrant/.bashrc echo 'source /usr/local/bin/virtualenvwrapper.sh' >> /home/vagrant/.bashrc source /home/vagrant/.bashrc fi
This seems to work fine; after initialization is complete, the lines are in .bashrc , and I can ssh in the field and use virtualenvwrapper.
However, during initialization, virtualenvwrapper does not work. After the section above, the following example checks the pin requirements file and tries to install it using virtualenvwrapper:
if [[ -f /vagrant/requirements.txt ]]; then mkvirtualenv 'myvirtualenv' -r /vagrant/requirements.txt fi
But this begets:
==> default: /tmp/vagrant-shell: line 50: mkvirtualenv: command not found
If I try and echo $WORKON_HOME from this shell script, nothing will appear.
What am I missing to have these environment variables so that virtualenvwrapper will work?
UPDATE: Further attempts ... it seems that executing source /home/vagrant/.bashrc does not affect my shell script - I can put echo "hello" in the .bashrc , and this isn the output during preparation (but if I ran source /home/vagrant/.bashrc at login.
I also tried su -c "source /home/vagrant/.bashrc" vagrant in a shell script, but that is no different.
UPDATE 2: Removed the $BASHRC_PATH variable, which confused the problem.
UPDATE 3: One more question . I got an answer about why source /home/vagrant/.bashrc didnโt work: the first part of the .bashrc file did not allow it to do anything when launched โnon-interactivelyโ in this way.
python shell vagrant virtualenvwrapper
Phil gyford
source share