fileExecutionEngineAndTarget in src/execute/engine.ts accepts both relative and absolute paths. This means cached ExecutionTarget.source can be either form depending on the caller, which has caused downstream bugs:
We could normalize file to absolute at the top of fileExecutionEngineAndTarget to establish an "always absolute" contract for target.source. This is the single convergence point for all callers (preview, render, format resolution).
|
export async function fileExecutionEngineAndTarget( |
|
file: string, |
|
flags: RenderFlags | undefined, |
|
project: ProjectContext, |
|
): Promise<{ engine: ExecutionEngineInstance; target: ExecutionTarget }> { |
|
const cached = ensureFileInformationCache(project, file); |
|
if (cached && cached.engine && cached.target) { |
|
return { engine: cached.engine, target: cached.target }; |
|
} |
|
|
|
// Get the launched engine |
|
const engine = await fileExecutionEngine(file, flags, project); |
|
if (!engine) { |
|
throw new Error("Can't determine execution engine for " + file); |
|
} |
|
|
|
const markdown = await project.resolveFullMarkdownForFile(engine, file); |
|
const target = await engine.target(file, flags?.quiet, markdown); |
|
if (!target) { |
|
throw new Error("Can't determine execution target for " + file); |
|
} |
|
|
|
// Cache the ExecutionEngineInstance |
|
cached.engine = engine; |
|
cached.target = target; |
|
|
|
return { engine, target }; |
|
} |
Just registering this idea to look into it when we are ready to make things more robust.
fileExecutionEngineAndTargetinsrc/execute/engine.tsaccepts both relative and absolute paths. This means cachedExecutionTarget.sourcecan be either form depending on the caller, which has caused downstream bugs:quarto preview subdir/file.qmdcrashing with doubled path #14150 —projectPathdoubled subdirectories whentarget.sourcewas relativeQUARTO_DOCUMENT_PATHandcwdcomputationWe could normalize
fileto absolute at the top offileExecutionEngineAndTargetto establish an "always absolute" contract fortarget.source. This is the single convergence point for all callers (preview, render, format resolution).quarto-cli/src/execute/engine.ts
Lines 353 to 380 in 0f97e05
Just registering this idea to look into it when we are ready to make things more robust.