Skip to content

quarto use template --no-prompt only works in empty directory #11127

@allefeld

Description

@allefeld

Bug description

Interactively, it is possible to install a template into a directory which already contains files, even if one accepts the defaults:

$ quarto use template allefeld/ext-quarto/r-utils

Quarto templates may execute code when documents are rendered. If you do not 
trust the authors of the template, we recommend that you do not install or 
use the template.
? Do you trust the authors of this template (Y/n) › Yes
? Create a subdirectory for template? (Y/n) › Yes
? Directory name: › 
[✓] Downloading
[✓] Unzipping

Preparing template files...
[✓] Copying files...

Files created:
 - statsutils.R

With --no-prompt, under the same circumstances an error occurs:

$ quarto use template --no-prompt allefeld/ext-quarto/r-utils
ERROR: Unable to install in /home/ca/work/Projects/[censored] as the directory isn't empty.

Stack trace:
    at determineDirectory (file:///opt/quarto/bin/quarto.js:109925:19)
    at useTemplate (file:///opt/quarto/bin/quarto.js:109773:39)
    at eventLoopTick (ext:core/01_core.js:153:7)
    at async Command.actionHandler (file:///opt/quarto/bin/quarto.js:109760:9)
    at async Command.execute (file:///opt/quarto/bin/quarto.js:8017:13)
    at async Command.parseCommand (file:///opt/quarto/bin/quarto.js:7907:20)
    at async quarto (file:///opt/quarto/bin/quarto.js:118224:9)
    at async file:///opt/quarto/bin/quarto.js:118244:9
    at async mainRunner (file:///opt/quarto/bin/quarto.js:118128:9)
    at async file:///opt/quarto/bin/quarto.js:118235:5

Steps to reproduce

Run quarto use template --no-prompt in a directory which contains files.

Expected behavior

quarto use template --no-prompt should behave the same as interactively with accepting the default options.

Actual behavior

see above

Your environment

Debian 12.7

Quarto check output

Quarto 1.5.57
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.57
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/bin
      Version: 2022

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.11.2
      Path: /usr/bin/python3
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

[✓] Checking R installation...........OK
      Version: 4.4.1
      Path: /usr/lib/R
      LibPaths:
        - /home/ca/Store/R
        - /usr/local/lib/R/site-library
        - /usr/lib/R/site-library
        - /usr/lib/R/library
      knitr: 1.48
      rmarkdown: 2.27

[✓] Checking Knitr engine render......OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestextensionsrelates to Quarto extensions mechanismneeds-designneeds-discussionIssues that require a team-wide discussion before proceeding further

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions