Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quarto preview broken (command not found) when using bundled Quarto and Pyenv #517

Open
testlabauto opened this issue Aug 15, 2024 · 11 comments
Assignees

Comments

@testlabauto
Copy link

I have a Positron smoke test that opens a sample RMD file and then attempts to preview it with cmd+shift+k. It is failing to find the bundled Quarto installation and in the Positron terminal I am seeing:

quarto preview /Users/christophermead/posit/qa-example-content/workspaces/basic-rmd-file/basicRmd.rmd --no-browser --no-watch-inputs --outpu4wtc0000gn/T/tmp-40396-zJDD9eqpFeVs --embed-resources
(base) ➜  qa-example-content quarto preview /Users/christophermead/posit/qa-example-content/workspaces/basic-rmd-file/basicRmd.rmd --no-brow
ser --no-watch-inputs --output-dir /var/folders/rc/l24758015ggb5438npy04wtc0000gn/T/tmp-40396-zJDD9eqpFeVs --embed-resources
zsh: command not found: quarto

Discussing this with @jmcphers, he has noted that we need to adjust the PATH in the created Quarto Preview terminal so that the terminal can access the Quarto installation even if it is not on the PATH.

@cderv
Copy link
Contributor

cderv commented Aug 15, 2024

Could it be related to latest addition by @jmcphers ?

This is quite recent and would require very latest version of extension, and we may need to build a new one if not already.

@jmcphers
Copy link
Collaborator

Version 114 of the extension has change #503, and Positron bundles version 114.

If I'm reading the code correctly, though, this would be a problem on any system that doesn't have quarto on the path. That includes e.g. quarto when found only inside an RStudio installation.

@jmcphers
Copy link
Collaborator

I spent some time looking into this. It looks like the Quarto extension does indeed try to add quarto to the Path, which is pretty close to the change I had intended to make.

// ensure quarto is on the path
context.environmentVariableCollection.prepend(
"PATH",
path.delimiter + quartoContext.binPath + path.delimiter
);

The Terminal: Show Environment Contributions command shows that this works as it's supposed to:

image

And in fact, I can't repro this problem at all with the latest build of Positron; quarto does get added to the path and it works fine.

@jonvanausdeln
Copy link

jonvanausdeln commented Aug 28, 2024

I just tried with the latest build of Positron (2024.08.0-77 on Windows and it doesn't find Quarto.

  • Uninstalled all quarto versions
  • Uninstalled all Positron
  • Installed 2024.08.0-77 - which includes Quarto extension 1.114.0
  • Open .qmd file, and try to preview
C:\Users\JonVanausdeln\source\qa-example-content [main ≡]> quarto preview c:/Users/JonVanausdeln/source/qa-example-content/workspaces/quarto_basic/quarto_basic.qmd --no-browser --no-watch-inputs --output-dir C:\Users\JONVAN~1\AppData\Local\Temp\tmp-32232-hHeUVdON8Tb2 --embed-resources
quarto: The term 'quarto' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

@jmcphers
Copy link
Collaborator

@jonvanausdeln what does the Terminal: Show Environment Contributions command show for you?

@jonvanausdeln
Copy link

jonvanausdeln commented Aug 28, 2024

@jonvanausdeln what does the Terminal: Show Environment Contributions command show for you?

## Extension: quarto.quarto

- `PATH=;c:\Program Files\Positron\resources\app\quarto\bin;${env:PATH}`

side note - I did reboot after all the uninstall/install

@testlabauto
Copy link
Author

testlabauto commented Aug 28, 2024

Unless I am doing something wrong, this also still happens on OSX:

quarto preview /Users/christophermead/posit/qa-example-content/workspaces/basic-rmd-file/basicRmd.rmd --no-browser --no-watch-inputs --output-dir /var/folders/rc/l24758015ggb5438npy04wtc0000gn/T/tmp-90360-EkbYZOl8WvcB --embed-resources
(base) ➜  qa-example-content quarto preview /Users/christophermead/posit/qa-example-content/workspaces/basic-rmd-file/basicRmd.rmd --no-browser --no-watch-inputs --output-dir /var/folders/rc/
l24758015ggb5438npy04wtc0000gn/T/tmp-90360-EkbYZOl8WvcB --embed-resources
zsh: command not found: quarto
(base) ➜  qa-example-content git:(cmead/add-devtools) 

Terminal: Show Environment Contributions

# Terminal Environment Changes

## Extension: quarto.quarto

- `PATH=:/Applications/Positron.app/Contents/Resources/app/quarto/bin:${env:PATH}`
image

@jmcphers
Copy link
Collaborator

Thank you for checking! This is what I see on macOS:

image

So this is working Sometimes but Not Always. Cool.

Related upstream, maybe? microsoft/vscode#188235

@testlabauto Could you grab some terminal trace logs and send them to me? Here's how: https://github.com/microsoft/vscode/wiki/Terminal-Issues#enabling-trace-logging

@jmcphers
Copy link
Collaborator

@jonvanausdeln are you using Pyenv by any chance? and can you show what your $PATH looks like after running quarto like Chris did?

I noticed that @testlabauto's $PATH (which is broken) has a whole bunch of .pyenv stuff on it, but mine (which is working) doesn't. So I tried switching to a pyenv-managed Python, and ... bam! I am suddenly able to reproduce this locally. It looks like pyenv is somehow dropping the Quarto entry from the $PATH when it's pushing its own shims to the front.

@jonvanausdeln
Copy link

@jmcphers , yes I am using pyenv

Also, here is the $PATH output.. I don't see quarto actually being added.

C:\Users\JonVanausdeln\source\qa-example-content [main ≡]> quarto preview c:/Users/JonVanausdeln/source/qa-example-content/workspaces/quarto_basic/quarto_basic.qmd --no-browser --no-watch-inputs --output-dir C:\Users\JONVAN~1\AppData\Local\Temp\tmp-7280-Jxe7thU55mC3 --embed-resources
quarto: The term 'quarto' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
C:\Users\JonVanausdeln\source\qa-example-content [main ≡]> $env:path -split ";"
C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\dotnet\
C:\ProgramData\chocolatey\bin
C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\
C:\Program Files\Git\cmd
%NVM_HOME%
%NVM_SYMLINK%
C:\Program Files\rig
C:\Program Files\R\bin
C:\Program Files\PowerShell\7\
C:\Program Files\Positron\bin
C:\Users\JonVanausdeln\scoop\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\AppData\Local\Microsoft\WindowsApps    
C:\Users\JonVanausdeln\AppData\Roaming\nvm
C:\Program Files\nodejs
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\AppData\Local\Programs\Microsoft VS Code\bin
C:\Program Files\Graphviz\bin
C:\Users\JonVanausdeln\AppData\Local\GitHubDesktop\bin        
C:\Users\JonVanausdeln\AppData\Local\Pandoc\
C:\Program Files\PowerShell\7
C:\Users\JonVanausdeln\.pyenv\pyenv-win\versions\3.12.2       
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\dotnet\
C:\ProgramData\chocolatey\bin
C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\
C:\Program Files\Git\cmd
%NVM_HOME%
%NVM_SYMLINK%
C:\Program Files\rig
C:\Program Files\R\bin
C:\Program Files\PowerShell\7\
C:\Program Files\Positron\bin
C:\Users\JonVanausdeln\scoop\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\AppData\Local\Microsoft\WindowsApps    
C:\Users\JonVanausdeln\AppData\Roaming\nvm
C:\Program Files\nodejs
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\AppData\Local\Programs\Microsoft VS Code\bin
C:\Program Files\Graphviz\bin
C:\Users\JonVanausdeln\AppData\Local\GitHubDesktop\bin        
C:\Users\JonVanausdeln\AppData\Local\Pandoc\
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\dotnet\
C:\ProgramData\chocolatey\bin
C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\
%NVM_HOME%
%NVM_SYMLINK%
C:\Program Files\rig
C:\Program Files\R\bin
C:\Program Files\PowerShell\7\
C:\Program Files\Positron\bin
C:\Users\JonVanausdeln\scoop\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\AppData\Local\Microsoft\WindowsApps
C:\Users\JonVanausdeln\AppData\Roaming\nvm
C:\Program Files\nodejs
C:\Users\JonVanausdeln\.pyenv\pyenv-win\bin
C:\Users\JonVanausdeln\.pyenv\pyenv-win\shims
C:\Users\JonVanausdeln\AppData\Local\Programs\Microsoft VS Code\bin
C:\Program Files\Graphviz\bin
C:\Users\JonVanausdeln\AppData\Local\GitHubDesktop\bin
C:\Users\JonVanausdeln\AppData\Local\Pandoc\

@jmcphers
Copy link
Collaborator

I don't see quarto actually being added.

It looks to me like the problem is that quarto is added (we confirmed that by looking at your Environment Contributions)... but Pyenv removes it when the Terminal starts (it organizes the $PATH to put its shims first). It is not clear to me why it's dropping Quarto but both @testlabauto and myself have confirmed that the problem only happens when Pyenv modifies the PATH.

Some possible routes forward:

  • have the Quarto extension emit the full path to the Quarto executable so that it is immune to this behavior (I'm not actually sure whether or not this will work since there are other executables in the bin folder that Quarto may assume to be on the path?)
  • figure out what is causing Pyenv to discard our PATH entry and change the Quarto extension to avoid the behavior (e.g. could it be that we're adding a leading separator and that confuses Pyenv?)
  • figure out a way to put our PATH entry back after Pyenv removes it (e.g. by emitting a command before the Quarto render happens)
  • run away from home and live in the woods

@jmcphers jmcphers changed the title Issue with RMD preview in Positron after Quarto was bundled - command not found: quarto Quarto preview broken (command not found) when using bundled Quarto and Pyenv Aug 29, 2024
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

No branches or pull requests

4 participants