Skip to content

CRLF line endings causing /usr/bin/env: ‘bash\r’: No such file or directory on WSL #508

Open
@stoneHee99

Description

@stoneHee99

Problem

When using pyenv-virtualenv on WSL (Windows Subsystem for Linux), some shell scripts can produce the following error:

/usr/bin/env: ‘bash\r’: No such file or directory

This happens when the repository is cloned with CRLF (Windows-style) line endings, which are incompatible with bash scripts on Linux.

Environment

  • WSL2 (Ubuntu 22.04)
  • Git default config with core.autocrlf=true
  • pyenv + pyenv-virtualenv
  • Zsh or Bash

Reproduction

  1. Clone the repository from Windows Git client (CRLF enabled)
  2. Add eval "$(pyenv virtualenv-init -)" to .zshrc or .bashrc
  3. Run source ~/.zshrc
  4. Error: /usr/bin/env: ‘bash\r’: No such file or directory

Proposed Solution

Add a .gitattributes file to enforce LF line endings for shell scripts:

*.sh text eol=lf

This will ensure shell scripts are always checked out with Unix-compatible line endings, even on Windows environments.

Additional Notes

  • This issue does not affect native Linux or macOS users
  • This change would improve developer experience for WSL users significantly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions