posit-dev / positron

Positron, a next-generation data science IDE
Other
2.31k stars 68 forks source link

Render With R Markdown can't handle Windows paths #3816

Closed tjmahr closed 1 month ago

tjmahr commented 2 months ago

Positron Version: 2024.06.1-27

Steps to reproduce the issue:

  1. Run Windows
  2. Open a .Rmd file.
  3. Click Render with R Markdown

What did you expect to happen?

If Powershell is the terminal, the " around the path are gobbled up:

> rmarkdown::render(c:\\Users\\mahr\\Desktop\\s.Rmd)
Error: unexpected '\\' in "rmarkdown::render(c:\\"
Execution halted

 *  The terminal process "C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command & 'C:\Program Files\R\R-4.4.0\bin\x64\R.exe' -e 'rmarkdown::render("c:\\Users\\mahr\\Desktop\\s.Rmd")'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

Which seems to be an issue: https://stackoverflow.com/questions/44840644/how-do-i-escape-quotes-in-a-powershell-string

If Git Bash is the terminal, the backslashes lose escaping.

> rmarkdown::render("c:\Users\mahr\Desktop\s.Rmd")
Error: '\U' used without hex digits in character string (<input>:1:23)
Execution halted

 *  The terminal process "C:\Program Files\Git\bin\bash.exe '--login', '-i', '-c', ''C:\Program Files\R\R-4.4.0\bin\x64\R.exe' -e 'rmarkdown::render("c:\\Users\\mahr\\Desktop\\s.Rmd")''" terminated with exit code: 1. 

In regular old Command Prompt, we lose the quotes again.

> rmarkdown::render(c:\\Users\\mahr\\Desktop\\s.Rmd)
Error: unexpected '\\' in "rmarkdown::render(c:\\"
Execution halted

 *  The terminal process "C:\windows\System32\cmd.exe /d /c ""C:\Program Files\R\R-4.4.0\bin\x64\R.exe" -e "rmarkdown::render("c:\\Users\\mahr\\Desktop\\s.Rmd")""" terminated with exit code: 1. 

Were there any error messages in the output or Developer Tools console?

I included the errors. Nothing appeared in the Developer Tools console.

jennybc commented 2 months ago

This looks like another case of https://github.com/posit-dev/positron/pull/2194.

Update: actually, closer to https://github.com/posit-dev/positron/pull/2123.

jonvanausdeln commented 1 month ago

Verified Fixed

Positron Version(s) : 2024.07.0-85 OS Version(s) : Windows 11, Ubuntu 22

Test scenario(s)

RMarkdown files now render as expected on Windows

Link(s) to TestRail test cases run or created:

TestRail RMarkdown Test

Automated test added to nightly smoke tests.