Issues

Issue #79 resolved

venvwrapper.sh doesn't like blanks in paths

Lukas Sobik
created an issue

When I want to initialize venvwrapper via:

{{{ source /usr/local/bin/virtualenvwrapper.sh }}}

I get the following error: {{{ source /usr/local/bin/virtualenvwrapper.sh

ERROR: Virtual environments directory '' does not exist. Create it or set WORKON_HOME to an existing directory. virtualenvwrapper_initialize:export:1: not valid in this context: HD/Users/Lukas/.virtualenvs }}}

I have my home directory on a separate drive: /Volumes/Macbook HD/Users/Lukas and on this one I'm using zsh.

When I switch to bash, executing

{{{ source /usr/local/bin/virtualenvwrapper.sh }}}

no error returns, but when I want to activate my venv

{{{ workon my-env

ERROR: Virtual environments directory '/Volumes/Macbook' does not exist. Create it or set WORKON_HOME to an existing directory. }}}

Comments (12)

  1. Lukas Sobik reporter

    The error in the bash was my mistake, i forgot to reference my .profile in the bashrc, where the WORKON_HOME value is set. It's now working.

    But the error in the zsh still remains.

    My .profile:

    export WORKON_HOME=$HOME/.virtualenvs
    
    

    and here is the value after my login:

    printenv WORKON_HOME
    /Volumes/Macbook
    
    

    After I run

    source .profile 
    
    

    the value is set correctly

    printenv WORKON_HOME
    /Volumes/Macbook HD/Users/Lukas/.virtualenvs
    
    

    but when i try to run source /usr/local/bin/virtualenvwrapper.sh

    virtualenvwrapper_initialize:export:1: not valid in this context: HD/Users/Lukas/.virtualenvs
    
    
  2. Doug Hellmann repo owner

    Try putting the value in quotes in your login script:

    export WORKON_HOME="$HOME/.virtualenvs"
    

    It does look like the way virtualenvwrapper.sh sets the default for WORKON_HOME leaves out the quotes. Line 146 should have quotes around the value of the value being assigned. Does adding quotes there fix the issue for you?

  3. Doug Hellmann repo owner

    Yes, I think there is a bug on line 146 of virtualenvwrapper.sh. If adding quotes *there* fixes the problem, then I'll know that I'm right and can prepare a fix.

  4. Doug Hellmann repo owner

    I can't reproduce this problem on my system. Can you send me all of the lines from your login file that are related to configuring virtualenv or virtualenvwrapper so I can make sure I'm doing it the same way you are?

    It sounds like you have it working with bash, but not zsh, is that right?

  5. Lukas Sobik reporter

    I have it now working with zsh. There was no problem with bash, I only have forgotten to reference my .profile in my .bashrc.

    Here are the lines in my .profile related to venvwrapper:

    export WORKON_HOME=~/.virtualenvs
    source /usr/local/bin/virtualenvwrapper.sh
    

    Like you suggested I added quotes on line 146 of virtualenvwrapper.sh:

    # Set up virtualenvwrapper properly
    virtualenvwrapper_initialize () {
    ->  export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)"
        virtualenvwrapper_verify_workon_home -q || return 1
        virtualenvwrapper_run_hook "initialize"
        if [ $? -ne 0 ]
        then
            echo "virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is set properly." 1>&2
            return 1
        fi
    }
    

    and now everything is working.

  6. Log in to comment