Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

`set_key` / `dotenv set` report a temp file path when the target's directory doesn't exist

Aberta
#710 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 12 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
cli

Direção de pesquisa

Start in src/dotenv/main.py at rewrite(), then inspect set_value and unset in cli.py. Compare their OSError handling with stream_file’s get/list behavior. Done means library errors name the target .env path, while the CLI prints a short error and exits with code 2 for missing or unwritable parent directories.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

When the parent directory of the target file doesn't exist, the error names an internal temp file instead of the .env path:

>>> dotenv.set_key("/tmp/nodir/.env", "A", "1")
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/nodir/.tmp_tjtn0_ek'

The CLI (dotenv -f /tmp/nodir/.env set A 1) prints a full traceback ending in the same message.

Cause: rewrite() in src/dotenv/main.py creates its NamedTemporaryFile in the target's directory before touching the target, so that's what fails first. set_value/unset in cli.py don't catch OSError.

Expected: the library raises an error that names the .env path. The CLI prints a short error and exits with code 2, as stream_file does for get/list. The same probably applies when the directory isn't writable.

Linguagem predominante
Python
Estrelas
8.9k
Forks
585
Merge médio
11d 5h
PRs com merge (30d)
2

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de theskumar/python-dotenv

Todas as issues de theskumar/python-dotenv

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.