New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activate.bat and deactivate.bat fail on 64-bit windows #35

Closed
vbabiy opened this Issue Mar 14, 2011 · 4 comments

Comments

Projects
None yet
2 participants
@vbabiy
Contributor

vbabiy commented Mar 14, 2011

Problem:

On a 64-bit windows deactivate.bat fails with the following message:

    \xxxxx was unexpected at this time

where xxxxx is a subfolder in the "%systemdrive%\Program Files (x86)" folder.

activate.bat will also fail if run a second time in a row.

A precondition to this failure is an application installed in the "%systemdrive%\Program Files (x86)" folder, which is added to the path.

Cause:

Consider the following piece of a batch file:

if defined path (
    echo %path%
    )

cmd.exe will expand the %path% variable, then find the closing parenthesis within and consider it the end of if-defined operator.
Then it will complain about the remaining part and exit.

Solution:

Don't use the above mentioned form of if operator with parentheses. For example, the following files work fine:

=================>> deactivate.bat

@echo off

if not defined _OLD_VIRTUAL_PROMPT goto NOVPROMPT
    set PROMPT=%_OLD_VIRTUAL_PROMPT%
    set _OLD_VIRTUAL_PROMPT=

:NOVPROMPT
if not defined _OLD_VIRTUAL_PATH goto END
    set PATH=%_OLD_VIRTUAL_PATH%
    set _OLD_VIRTUAL_PATH=

:END

================>> activate.bat

@echo off
set VIRTUAL_ENV=c:\virtualenv\aaaaa

if not defined PROMPT (
    set PROMPT=$P$G
)

if not defined _OLD_VIRTUAL_PROMPT goto NOVPROMPT
    set PROMPT=%_OLD_VIRTUAL_PROMPT%

:NOVPROMPT
set _OLD_VIRTUAL_PROMPT=%PROMPT%
set PROMPT=(aaaaa) %PROMPT%

if not defined _OLD_VIRTUAL_PATH goto NOVPATH
    set PATH=%_OLD_VIRTUAL_PATH%

:NOVPATH
set _OLD_VIRTUAL_PATH=%PATH%
set PATH=%VIRTUAL_ENV%\Scripts;%PATH%

@vbabiy

This comment has been minimized.

Show comment
Hide comment
@vbabiy

vbabiy Mar 14, 2011

Contributor

Original Comment By: s4g
Contributor

vbabiy commented Mar 14, 2011


Original Comment By: s4g
@vbabiy

This comment has been minimized.

Show comment
Hide comment
@vbabiy

vbabiy Mar 14, 2011

Contributor
  • Changed content.

Original Comment By: s4g
Contributor

vbabiy commented Mar 14, 2011

  • Changed content.

Original Comment By: s4g
@vbabiy

This comment has been minimized.

Show comment
Hide comment
@vbabiy

vbabiy Mar 14, 2011

Contributor

This is a duplicate of #3, this should be fixed in tip

Duplicate of #3.

are


Original Comment By: Philip Jenvey
Contributor

vbabiy commented Mar 14, 2011

This is a duplicate of #3, this should be fixed in tip

Duplicate of #3.

are


Original Comment By: Philip Jenvey
@uweschmitt

This comment has been minimized.

Show comment
Hide comment
@uweschmitt

uweschmitt Nov 29, 2015

I still have this problem. Was the fix included in virtualenv ?

I still have this problem. Was the fix included in virtualenv ?

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment