Render With R Markdown can't handle Windows paths
Positron Version: 2024.06.1-27
Steps to reproduce the issue:
- Run Windows
- Open a .Rmd file.
- 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.
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.
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:
Automated test added to nightly smoke tests.