Fix quarto create producing read-only files from read-only installations#14258
Open
Fix quarto create producing read-only files from read-only installations#14258
quarto create producing read-only files from read-only installations#14258Conversation
When Quarto is installed via system packages (e.g. .deb, Nix), resource files may be read-only. Files copied from these resources by `quarto create` inherit the read-only permissions, preventing users from editing them. Add ensureUserWritable() to src/deno_ral/fs.ts (alongside the safeModeFromFile/safeChmodSync it depends on) and call it after every file copy in artifact-shared.ts and project-create.ts.
Add unit tests (file-permissions.test.ts) covering: - ensureUserWritable fixes read-only files - ensureUserWritable is no-op for already-writable files - Simulated Nix/deb scenario (copyFile from read-only source) Extend create smoke test to verify all output files are user-writable. Extract withTempDir() helper to tests/utils.ts for reuse. Permission tests are skipped on Windows where chmod is not supported.
Deno.statSync().mode includes file-type bits (e.g. 0o100644 for regular files), not just permission bits. Use & 0o777 to compare only permission bits in assertEquals calls.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Quarto is installed in a read-only location (e.g. Nix store, where all files are
0o444),quarto createcopies resource files into the user's project directory preserving the source permissions. The created files end up read-only, preventing users from editing them.Standard
.debinstalls are not affected since installed resource files are0o644, but any installation method that places Quarto in an immutable or read-only filesystem can trigger this.Fix
Add
ensureUserWritable()tosrc/deno_ral/fs.tsalongsidesafeModeFromFile/safeChmodSync. Call it after every file copy inartifact-shared.tsandproject-create.ts. The function checks the user-write bit (0o200) and adds it if missing; no-op on Windows.Tests
file-permissions.test.ts) verifyensureUserWritableon read-only files, already-writable files, and a simulated scenario wherecopyFileSyncfrom a read-only source preserves read-only permissionsquarto createare user-writablechmodis not supportedFixes #14250