Skip to content

Fix quarto create producing read-only files from read-only installations#14258

Open
cderv wants to merge 3 commits intomainfrom
create/file-permissions
Open

Fix quarto create producing read-only files from read-only installations#14258
cderv wants to merge 3 commits intomainfrom
create/file-permissions

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Mar 23, 2026

When Quarto is installed in a read-only location (e.g. Nix store, where all files are 0o444), quarto create copies 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 .deb installs are not affected since installed resource files are 0o644, but any installation method that places Quarto in an immutable or read-only filesystem can trigger this.

Fix

Add ensureUserWritable() to src/deno_ral/fs.ts alongside safeModeFromFile/safeChmodSync. Call it after every file copy in artifact-shared.ts and project-create.ts. The function checks the user-write bit (0o200) and adds it if missing; no-op on Windows.

Tests

  • Unit tests (file-permissions.test.ts) verify ensureUserWritable on read-only files, already-writable files, and a simulated scenario where copyFileSync from a read-only source preserves read-only permissions
  • Smoke test extension checks all files created by quarto create are user-writable
  • Permission tests skipped on Windows where chmod is not supported

Fixes #14250

cderv added 3 commits March 23, 2026 16:06
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.
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Mar 23, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quarto create files missing write permission

2 participants