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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadPackage() not to access the file system if the cache already exists #4736

Closed
whitphx opened this issue May 3, 2024 · 2 comments 路 Fixed by #4738
Closed

loadPackage() not to access the file system if the cache already exists #4736

whitphx opened this issue May 3, 2024 · 2 comments 路 Fixed by #4738
Labels
enhancement New feature or request

Comments

@whitphx
Copy link
Contributor

whitphx commented May 3, 2024

馃殌 Feature

pyodide.loadPackage() should not access the file system with nodeFsPromisesMod.mkdir when not necessary, or the cache dir already exists.
It can be done automatically, or by providing an option to skip the file system access.

Motivation

loadPackage() calls nodeFsPromisesMod.mkdir any time to ensure the directory exists.
However, it causes an error if the file system is read-only even when the directory and the cached packages already exist.
My actual use case is to ship Pyodide in an Electron app with the downloaded package files. In this case, the bundled files are visible to the Node process of the Electron app via fs module but not writable as they are packaged in an ASAR archive and the archive is read-only. It's whitphx/stlite#831 (comment).

Pitch

  • One option is to call mkdir only when the cache directory does not exist.
  • Another is to add an option to skip the file system access, e.g. loadPackage(packageName, { skipDownload: true }).
@whitphx whitphx added the enhancement New feature or request label May 3, 2024
@hoodmane
Copy link
Member

hoodmane commented May 3, 2024

One option is to call mkdir only when the cache directory does not exist.

This sounds good. PR welcome.

@ryanking13
Copy link
Member

Sounds good to me too. Actually, this behavior was problematic in Deno too: #4624.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants