python-poetry / python-poetry/poetry
Issue with Accented Characters in Script Paths Generated by [project.scripts] on Windows 11 (PT-BR)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
Description
Description:
When using Poetry on Windows 11 in Portuguese, the generated .cmd files for scripts defined in [project.scripts] contain paths with accented characters that are incorrectly encoded. As a result, when executing the command, the system is unable to locate the specified path.
Steps to Reproduce:
-
Project Structure:
C:. │ .venv │ poetry.lock │ pyproject.toml │ README.md │ ├───example │ cli.py │ __init__.py │ └───tests __init__.py -
Contents of
example/cli.py:from typer import Typer app = Typer() @app.command(name="hello") def Hello(nome: str): print(f"Hello, {nome}") if __name__ == '__main__': app() -
Contents of
pyproject.toml:[project] name = "example" version = "0.1.0" description = "" authors = [ {name = "foo", email = "foo@email.com"} ] readme = "README.md" requires-python = ">=3.12" dependencies = [ "typer" ] [project.scripts] say-hello = "example.cli:app" [build-system] requires = ["poetry-core>=2.0.0,<3.0.0"] build-backend = "poetry.core.masonry.api" -
Execution:
Activate the virtual environment and run:say-hello "Word"
Expected Result:
The command say-hello "Word" should invoke the defined script, displaying the message Hello, Word or the corresponding behavior.
Observed Result:
The command fails with the following error message:
O sistema não pode encontrar o caminho especificado.
Translate:
The system cannot find the specified path.
Upon inspecting the file .venv\Scripts\say-hello.cmd (after removing the @echo off to view the commands), the content is as follows:
"C:\Users\jmoni\OneDrive\├ürea de Trabalho\scripts\clis-pyproject\example\.venv\Scripts\python.exe" "C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example\.venv\Scripts\\say-hello"
It can be observed that the folder Área de Trabalho appears as ├ürea de Trabalho, indicating an encoding issue with accented characters.
Additional Notes:
- The problem seems to be related to how Poetry generates the
.cmdfiles, not correctly handling the encoding of special characters present in the paths. - This error occurs specifically in environments with the Portuguese locale (Windows 11 PT-BR).
Workarounds
To work around the issue with locating the .cmd executable due to incorrect encoding of accented characters on Windows, you can modify the file .venv\Scripts\say-hello.cmd by adding the following line at the beginning of the file:
chcp 65001 >nul
This line changes the code page. Although this solution works for this specific case, it may not be suitable as a universal fix for all scenarios.
Poetry Installation Method
pipx
Operating System
Windows 11
Poetry Version
2.0.1
Poetry Configuration
cache-dir = "C:\\Users\\jmoni\\AppData\\Local\\pypoetry\\Cache"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs" # C:\Users\jmoni\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false
Python Sysconfig
sysconfig.log
Paste the output of 'python -m sysconfig', over this line.
Example pyproject.toml
[project]
name = "example"
version = "0.1.0"
description = ""
authors = [
{name = "foo",email = "foo@email.com"}
]
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"typer"
]
[project.scripts]
say-hello = "example.cli:app"
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"
Poetry Runtime Logs
poetry-runtime.log
poetry -vvv installLoading configuration file C:\Users\jmoni\AppData\Roaming\pypoetry\config.toml
Trying to detect current active python executable as specified in the config.
Found: C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example\.venv\Scripts\python.EXE
Using virtualenv: C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example\.venv
Installing dependencies from lock file
Finding the necessary packages for the current system
Package operations: 0 installs, 0 updates, 0 removals, 9 skipped
- Installing click (8.1.8): Pending...
- Installing click (8.1.8): Skipped for the following reason: Already installed
- Installing colorama (0.4.6): Pending...
- Installing colorama (0.4.6): Skipped for the following reason: Already installed
- Installing markdown-it-py (3.0.0): Pending...
- Installing markdown-it-py (3.0.0): Skipped for the following reason: Already installed
- Installing mdurl (0.1.2): Pending...
- Installing mdurl (0.1.2): Skipped for the following reason: Already installed
- Installing rich (13.9.4): Pending...
- Installing rich (13.9.4): Skipped for the following reason: Already installed
- Installing shellingham (1.5.4): Pending...
- Installing shellingham (1.5.4): Skipped for the following reason: Already installed
- Installing typer (0.15.1): Pending...
- Installing typer (0.15.1): Skipped for the following reason: Already installed
- Installing pygments (2.19.1): Pending...
- Installing pygments (2.19.1): Skipped for the following reason: Already installed
- Installing typing-extensions (4.12.2): Pending...
- Installing typing-extensions (4.12.2): Skipped for the following reason: Already installed
Installing the current project: example (0.1.0)
- Building package example in editable mode
- Removed example-0.1.0.dist-info directory from C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example\.venv\Lib\site-packages
- Adding example.pth to C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example\.venv\Lib\site-packages for C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example
- Adding the say-hello script to C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example\.venv\Scripts
- Adding the say-hello.cmd script wrapper to C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example\.venv\Scripts
- Adding the example-0.1.0.dist-info directory to C:\Users\jmoni\OneDrive\Área de Trabalho\scripts\clis-pyproject\example\.venv\Lib\site-packages
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the generated .venv\Scripts\say-hello.cmd and the [project.scripts] entry in pyproject.toml. Reproduce the issue on Windows 11 with the accented project path, then trace the script-generation entry point and existing tests. Done means the wrapper preserves the path encoding and say-hello runs successfully without the chcp workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100