quarto-dev / quarto-dev/quarto

Windows: `quarto.path` pointing at a `.cmd`-only dev binary is detected as a file but silently falls back to PATH

Open
#981 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug vscode
Dominant language
TypeScript
Stars
645
Forks
62
Avg merge
17h 42m
Merged PRs (30d)
13

Description

When the user sets quarto.path to an absolute path of a Quarto build that ships only quarto.cmd on Windows (typical for the in-repo dev binary at package/dist/bin/quarto.cmd after ./configure.cmd), the extension's existence check passes but the subsequent version probe fails. The extension then silently falls back to the system PATH, so the user-specified dev binary is never actually used.

Mechanism

detectUserSpecifiedQuarto validates the file exists and is a file (passes for quarto.cmd), then calls detectQuarto(quartoPath):

https://github.com/quarto-dev/quarto/blob/dec89b21972b16fc3da2807d51206cd7c165006c/packages/quarto-core/src/context.ts#L194-L211

readQuartoInfo calls execProgram(quartoPath, ["--version"]). On Windows, child_process spawn on an absolute path to a .cmd file fails without shell: true because Windows requires cmd.exe to interpret .cmd files. The catch block retries with quartoPath + ".cmd" — but when the user already passed …\quarto.cmd, the retry becomes …\quarto.cmd.cmd, which does not exist. Both attempts fail, detectQuarto returns undefined, and the extension falls through to the PATH branch.

There is no warning surfaced — detectUserSpecifiedQuarto only warns when fs.existsSync or isFile checks fail, not when the version probe silently fails:

https://github.com/quarto-dev/quarto/blob/dec89b21972b16fc3da2807d51206cd7c165006c/packages/quarto-core/src/context.ts#L224-L248

The useCmd flag only adjusts the execution-time path; it does not help at detection time:

https://github.com/quarto-dev/quarto/blob/dec89b21972b16fc3da2807d51206cd7c165006c/packages/quarto-core/src/context.ts#L138

Reproduction

On Windows:

  1. Clone quarto-dev/quarto-cli, run ./configure.cmd. This produces package/dist/bin/quarto.cmd with no quarto.exe sibling.
  2. In Positron/VS Code settings, set quarto.path to the absolute path of that quarto.cmd.
  3. Reload the window.
  4. Open a .qmd and run any Quarto extension command (Preview, Verify Installation, render).

Observed: the dev binary is not used. The extension picks up whatever quarto is on PATH (in my case, a quarto-prerelease install from Scoop).

Quarto output channel log
[info] Activating Quarto extension.
[info] Searching for Quarto CLI...
[info]   Checking quarto.path setting: C:/Users/chris/Documents/DEV_R/quarto-cli.worktrees/issue-14533/package/dist/bin/quarto.cmd
[info]   Checking system PATH...
[info]   Found Quarto 1.10.3 on system PATH
[info] Using Quarto 1.10.3 from C:\Users\chris\scoop\apps\quarto-prerelease\current\bin (found on system PATH)
[info] Activated Quarto extension.

Note: no warning between the quarto.path check and the PATH fallback. The user has no diagnostic indicating their setting was discarded.

Suggestion

We could either:

  • Detect a trailing .cmd on quartoPath at detection time and spawn with shell: true (or wrap in cmd /c).
  • Or trim the trailing .cmd from quartoPath before passing to readQuartoInfo, so the fallback at L208 can append .cmd cleanly without producing quarto.cmd.cmd.
  • Or at minimum, surface a warning when the existence check passes but the version probe fails, so users get a clear diagnostic instead of silent fallback.

This blocks testing dev binaries against the extension end-to-end on Windows, which is what I hit while validating a quarto-cli fix that surfaces only when the extension is the client. Related to #352, which describes a different mechanism (terminal env-var prepend race on non-bash shells) producing the same user-visible symptom ("quarto.path is ignored").

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/quarto-core/src/context.ts, reading detectUserSpecifiedQuarto, detectQuarto, readQuartoInfo, and the useCmd handling around the referenced lines. Reproduce the Windows setup with package/dist/bin/quarto.cmd and the quarto.path setting, then verify that the configured .cmd binary is version-probed and selected rather than silently falling back to PATH.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.