theskumar / theskumar/python-dotenv
rewrite always finishes with an error when the file is on a Windows host
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 8.9k
- Fork
- 581
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- docker, python
- Lĩnh vực
- devops, operating-systems
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100