rewrite always finishes with an error when the file is on a Windows host
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- docker, python
- Domain
- devops, operating-systems
Research direction
Start at save_envvar and trace set_key into the rewrite path shown in the report. Reproduce the .env update with a file on a Windows host or WSL2-mounted path, then verify that the update finishes without an error and that subsequent variables are written.
Written by the indexing model from the issue text.
Description
Trying to run iotedgedev in a docker container inside a WSL2 vm always yields the same error:
ERROR: Could not update the environment variable IOTHUB_CONNECTION_STRING in file /home/iotedge/.env
Funny thing is, the variable IS written to the file. What isn't written is the next variable, so clearly an error occurs AFTER having already written the value to the file.
Iotedgedev uses dotenv to update the .env file:
def save_envvar(self, key, value):
try:
dotenv_file = self.get_dotenv_file()
dotenv_path = os.path.join(os.getcwd(), dotenv_file)
set_key(dotenv_path, key, value)
except Exception:
raise IOError(f("Could not update the environment variable {key} in file {dotenv_path}"))
Now, set_key seems to be using rewrite to update the file, and rewrite does this:
if error is None:
shutil.move(dest.name, path)
else:
os.unlink(dest.name)
raise error from None
Instead of plain move it should first do an os.remove and only then move. That should make it work with files on a Windows host.
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 581
- PR merge metrics
- No merged PRs in 30d
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.
More from theskumar/python-dotenv
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
theskumar/python-dotenv#699 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
theskumar/python-dotenv#697 ·
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
theskumar/python-dotenv#693 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
theskumar/python-dotenv#683 · 4 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
theskumar/python-dotenv#644 · 2 comments ·
All issues in theskumar/python-dotenv
Similar issues
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openml/openml-python#1749 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sipyourdrink-ltd/bernstein#6191 ·