quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
4k stars 328 forks source link

Render from vs code generates error when copying command to terminal #6634

Closed brianmsm closed 1 year ago

brianmsm commented 1 year ago

Bug description

Render from vs code generates error when copying command to terminal

In any .qmd file that you click on "Render", a new terminal instance is created and the command is not copied properly:

image

Render from vs code generates error when copying command to terminal

In any .qmd file that you click on "Render", a new terminal instance is created and the command is not copied properly.

I imagine the reason may be that in Garuda Linux, the terminal is pre-configured to display neofetch whenever it is opened, and the command is trying to run before neofetch is executed or displayed.

Steps to reproduce

This happens in any .qmd file

---
title: "Untitled"
format: html
---

```{r}
mtcars

### Expected behavior

That the command (`quarto preview /home/brian/data/Github/curso-tri-dicotomico-uni/sesion_03/test.qmd --no-browser --no-watch-inputs`) is executed in console when it is ready to be used.

### Actual behavior

It is running before neofetch and at the end it adds some strange numbers:

```fish
quarto preview /home/brian/data/Github/curso-tri-dicotomico-uni/sesion_03/test.qmd --no-browser --no-watch-inputs
Logo: getCharacterPixelDimensions() failed        brian@brian-g555878898898:    
                 x;XxXB%89b8:b8%b88:              ------------------
              .8Xxd                8X:.           OS: Garuda Linux x86_64
            .8Xx;                    8x:.         Host: G5 5587
          .tt8x          .d            x88;       Kernel: 6.4.11-zen2-1-zen
       .@8x8;          .db:              xx@;     Uptime: 1 day, 17 hours, 4 mins
     ,tSXX°          .bbbbbbbbbbbbbbbbbbbB8x@;    Battery: 89%% [Charging]
   .SXxx            bBBBBBBBBBBBBBBBBBBBbSBX8;    
 ,888S                                     pd!    Packages: 2555 (pacman)[stable], 15 (flatpak)
8X88/                                       q     Shell: fish 3.6.1
8X88/                                             Terminal: electron
GBB.    
 x%88        d888@8@X@X@X88X@@XX@@X@8@X.          CPU: Intel(R) Core(TM) i7-8750H (12) @ 4.1 GHz
   dxXd    dB8b8b8B8B08bB88b998888b88x.           GPU: Intel UHD Graphics 630
    dxx8o                      .@@;.              GPU: NVIDIA GeForce GTX 1050 Ti Mobile
      dx88                   .t@x.                Memory: 19.76 GiB / 31.16 GiB (63%)
        d:SS@8ba89aa67a853Sxxad.    
          .d988999889889899dd.                    ████████████████████████
                                                  ████████████████████████

 ╭─brian@brian in repo: curso-tri-dicotomico-uni/sesion_03 on  main [?] via 📐 v4.3.1 
 ╰─λ [4;903;1183t]

Your environment

Quarto check output

 ╭─brian@brian in repo: curso-tri-dicotomico-uni/sesion_03 on  main [?] via 📐 v4.3.1 
 ╰─λ quarto check

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.3.450
      Path: /opt/quarto/bin

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

[✓] Checking Python 3 installation....OK
      Version: 3.11.3
      Path: /bin/python
      Jupyter: 5.3.1
      Kernels: python3

(-) Checking Jupyter engine render....[IPKernelApp] WARNING | debugpy_stream undefined, debugging will not be enabled
[✓] Checking Jupyter engine render....OK

(-) Checking R installation...........Loading required package: utils
Tracing function "install.packages" in package "utils"
[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /usr/lib64/R
      LibPaths:
        - /home/brian/R/x86_64-pc-linux-gnu-library/4.3
        - /usr/lib/R/library
      knitr: 1.43.2
      rmarkdown: 2.24

[✓] Checking Knitr engine render......OK
cscheid commented 1 year ago

Can you share the full contents of a single .qmd file that reproduce the issue? (a git repository is fine.)

brianmsm commented 1 year ago

It happens with any qmd file. For example.

---
title: "Untitled"
format: html
---

```{r}
mtcars
cscheid commented 1 year ago

It is running before neofetch and at the end it adds some strange numbers:

Sorry, I truly don't understand what you're describing here. I think you have some incompatible shell settings in your fancy prompt that doesn't play nicely with VS Code's expectations. Can you try this on a clean shell?

brianmsm commented 1 year ago

I understand, I will expand the description.

In garuda linux and some other linux distributions (Xerolinux for example) they bring the terminal configured so that as soon as it is opened and you are in an interactive session, it shows a message (like the one I put in screenshot).

In the case of garuda, it uses fish by default and in the last lines of its configuration file ~/.config/fish/config.fish, it indicates:

## Run fastfetch if session is interactive
if status --is-interactive && type -q fastfetch
   fastfetch --load-config dr460nized
end

What I understand what happens is that when quarto sends the command to fish, when a new instance is always opened, the code enters before the execution of fastfetch. I don't know if it is possible to add some configuration associated to a delay in the command sending.

cscheid commented 1 year ago

I don't know if it is possible to add some configuration associated to a delay in the command sending.

This is something that you will need to resolve in your configuration, either of VS Code or of your shell (edit: ~/.config/fish/config.fish). I imagine you'll need to test if you're inside VS Code and either not execute fastfetch or do something else. This isn't really a quarto bug.

brianmsm commented 1 year ago

@cscheid I understand. This worked for me, I put it in case someone else is faced with this situation.

In settings.json in vscode set:

{
    "terminal.integrated.env.linux": {
        "FROM_VSCODE": "true"
    }
}

And in ~/.config/fish/config.fish in the last lines indicate:

## Run fastfetch if session is interactive and not started from VSCode
if status --is-interactive && type -q fastfetch
    if not set -q FROM_VSCODE
        fastfetch --load-config dr460nized
    end
end

Although the command appeared before the prompt anyway, this time it worked and was executed:

image