GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — venv activate bash script has wrong line endings in Windows · Issue #76632 · python/cpython

venv activate bash script has wrong line endings in Windows #76632

New issue
Copy link
New issue
Copy link
Closed
Closed
venv activate bash script has wrong line endings in Windows#76632
Copy link
Labels
3.10 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifeOS-windowstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

Kevin
mannequin
opened on Dec 30, 2017
Issue body actions
BPO 32451
Nosy @pfmoore, @tjguk, @bitdancer, @embray, @zware, @eryksun, @zooba, @StingyJack

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2017-12-30.04:13:49.296>
labels = ['3.10', 'type-bug', '3.8', '3.9', 'OS-windows']
title = 'venv activate bash script has wrong line endings in Windows'
updated_at = <Date 2021-03-17.19:57:39.007>
user = 'https://bugs.python.org/Kevin'

bugs.python.org fields:

activity = <Date 2021-03-17.19:57:39.007>
actor = 'eryksun'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Windows']
creation = <Date 2017-12-30.04:13:49.296>
creator = 'Kevin'
dependencies = []
files = []
hgrepos = []
issue_num = 32451
keywords = []
message_count = 8.0
messages = ['309215', '309258', '339985', '340038', '340052', '340065', '340272', '388962']
nosy_count = 9.0
nosy_names = ['paul.moore', 'tim.golden', 'r.david.murray', 'erik.bray', 'zach.ware', 'eryksun', 'steve.dower', 'Kevin', 'astanton1978']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue32451'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

Activity

  1. Kevin commented on Dec 30, 2017

    @Kevin
    Kevinmannequin
    on Dec 30, 2017
    MannequinAuthor
    More actions

    attempts from within cygwin:

    1. The Posix way:
    $ python -m venv taco
    $ cd taco
    $ source bin/activate
    -bash: $'\r': command not found
    -bash: Scripts/activate: line 4: syntax error near unexpected token `$'{\r''
    'bash: Scripts/activate: line 4: `deactivate () {
    1. The windows way:
    $ python -m venv taco
    $ cd taco
    $ /full/path/to/venv/taco/scripts/activate.bat
    $
    1. the only solution from cygwin (still not 100% functional):
    $ python -m venv taco
    $ cd taco
    $ cd Scripts
    $ cmd
    C:\taco\Scripts\> activate.bat

    (taco) C:\taco\Scripts\>

    HOWEVER. when running "pip freeze" in number 3 it returns the system packages despite the "include-system-site-packages = False" in pyvenv.cfg
    When #3 is run inside command prompt "pip freeze" returns nothing correctly.

    Come on guys, please don't make me use command prompt or powershell.

  2. Kevin
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Dec 30, 2017
  3. bitdancer commented on Dec 30, 2017

    @bitdancer
    bitdancer
    on Dec 30, 2017
    Member
    More actions

    cygwin in not currently fully supported (there are people working on it, though). Can you determine if this is a bug in cygwin's bash support, or something else? It certainly works with bash shell on unix. I would presume that from cygwin one would want the posix way to work, and that it should be possible.

  4. StingyJack commented on Apr 11, 2019

    @StingyJack
    StingyJackmannequin
    on Apr 11, 2019
    Mannequin
    More actions

    I dont think this is a Cygwin only problem, as this is happening to me when running WSL (Windows subsystem for Linux). I can run Scripts\Activate.ps1 from powershell, Scripts\activate.bat from cmd, but running scripts/activate from wsl reports this same error.

  5. eryksun commented on Apr 12, 2019

    @eryksun
    eryksun
    on Apr 12, 2019
    Contributor
    More actions

    Why is the bash/zsh "activate" script getting distributed with CRLF line endings? Apparently Windows builds of bash (e.g. git-bash) can handle CRLF line endings, but Cygwin bash cannot.

    As to Linux bash in WSL, the activate script from a virtual environment created by Windows Python can't be used anyway. It modifies $PATH using a DOS path like "C:\taco" as opposed to a WSL path like "/mnt/c/taco".

    when running "pip freeze" in number 3 it returns the system
    packages despite the "include-system-site-packages = False"
    in pyvenv.cfg

    The 3rd attempt is just running activate.bat from a CMD shell. That should work, unless you exit out of CMD back to bash. Anyway, check where.exe pip after activating. It should find "C:\taco\Scripts\pip.exe" first.

  6. eryksun
    added
    OS-windows
    3.7 (EOL)end of lifeend of life
    3.8 (EOL)end of lifeend of life
    on Apr 12, 2019
  7. zooba commented on Apr 12, 2019

    @zooba
    zooba
    on Apr 12, 2019
    Member
    More actions

    It probably just needs a gitattributes fix so it doesn't get converted when cloned to make the release build.

    This is assuming that in all these cases people are installing Python for Windows and trying to use it from a non-Windows shell (both WSL and Cygwin have their own "native" Python builds that presumably work). I can't tell if there's something else going on here.

  8. eryksun commented on Apr 12, 2019

    @eryksun
    eryksun
    on Apr 12, 2019
    Contributor
    More actions

    This is assuming that in all these cases people are installing Python
    for Windows and trying to use it from a non-Windows shell (both WSL
    and Cygwin have their own "native" Python builds that presumably
    work).

    It should work from Cygwin and MSYS2 since they support DOS paths in $PATH. I don't have Cygwin installed, but I tried MSYS2 bash and Git bash, and it worked fine, even with CRLF line endings. Apparently only Cygwin bash has a problem with CRLF line endings.

    The issue with using Windows Python in this case is that the terminals for these environments emulate Unix PTYs with named pipes (e.g. "msys-0123456789abcdef-pty0-from-master" for stdin and "msys-0123456789abcdef-pty0-to-master" for stdout and stderr). Thus isatty() is false, and interactive mode has to be forced with the -i command-line option.

  9. embray commented on Apr 15, 2019

    @embray
    embray
    on Apr 15, 2019
    Contributor
    More actions

    Coincidentally I just encountered this myself when trying to activate a venv created by Python for Windows while in a Cygwin shell. Indeed, bash for Cygwin is just like bash anywhere else, and considers it a syntax error to encounter unexpected CR's.

    Alas, venv creates <path>/<to/<env>/Scripts/activate with CRLFs. After running dos2unix on it, this script can be sourced from Cygwin and otherwise works fine.

    The issue that arises with interactive mode is a known issue not specific to Python or venv. It can also be worked around by running python with winpty.

  10. eryksun commented on Mar 17, 2021

    @eryksun
    eryksun
    on Mar 17, 2021
    Contributor
    More actions

    The POSIX "Lib/venv/scripts/common/activate" script needs a line-ending exception in ".gitattributes":

    https://github.com/python/cpython/blob/master/.gitattributes

  11. eryksun
    added
    3.9 (EOL)end of lifeend of life
    3.10 (EOL)end of lifeend of life
    and removed
    3.7 (EOL)end of lifeend of life
    on Mar 17, 2021
  12. eryksun
    changed the title [-]python -m venv activation issue when using cygwin on windows[/-] [+]venv activate bash script has wrong line endings in Windows[/+] on Mar 17, 2021
  13. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  14. daytonb commented on Apr 21, 2023

    @daytonb
    daytonb
    on Apr 21, 2023
    More actions

    I was going to fix this issue, because I just ran into it this week while helping a co-worker. However, it's already been fixed in main 😃.

    The need to adjust .gitattributes was noted in issue #103088 and closed by merge request #103591, so this issue can be closed now.

    Reacted by Zachary Ware
  15. zware
    closed this as completedon Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifeOS-windowstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.