Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionError on Windows when running tests with AiiDA configuration #6783

Open
SatyajitRedekar opened this issue Mar 5, 2025 · 1 comment
Labels
type/feature request status undecided

Comments

@SatyajitRedekar
Copy link

SatyajitRedekar commented Mar 5, 2025

Describe the bug

When running tests on Windows, I encounter PermissionError and FileNotFoundError related to AiiDA's configuration file. This happens during the _atomic_write operation in aiida.manage.configuration.config.

Steps to reproduce

Set up a Python environment on Windows.

Install AiiDA and its dependencies.

Run tests using pytest tests/test_tasks.py -v.

Observe the following errors:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process
FileNotFoundError: [Errno 2] No such file or directory

Expected behavior

Tests should run without file permission errors.

Actual Behavior

Tests fail with PermissionError and FileNotFoundError.

Environment

  • Operating System: Windows 10/11

  • Python Version: 3.12.0

  • AiiDA Version: 2.x.x

  • pytest Version: 7.4.4

Additional context

The issue occurs specifically on Windows due to file locking behavior.

Temporarily disabling antivirus or running as Administrator resolves the issue, but this is not a permanent fix.

A workaround is to patch the _atomic_write method, but this should be addressed in the core library.

Proposed Solution

Consider using a different file-writing strategy for Windows, such as os.replace instead of os.rename, or adding retry logic for file operations.

@khsrali
Copy link
Contributor

khsrali commented Mar 5, 2025

Thanks @SatyajitRedekar for sharing the issue you are experiencing.

Consider using a different file-writing strategy for Windows, such as os.replace instead of os.rename, or adding retry logic for file operations.

As far as I know we don't support Windows, officially.
However, usually Windows fans open PRs to make AiiDA compatible with it. see here for example: #6715

If it doesn't go in opposite direction of our development, we usually accept and merge.
If you already have a solution you may open a PR on it so that we could have a look and review it.

P.S. I'm removing bug label, and replace with feature requests.

@khsrali khsrali added type/feature request status undecided and removed type/bug labels Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature request status undecided
Projects
None yet
Development

No branches or pull requests

2 participants