-
Notifications
You must be signed in to change notification settings - Fork 91
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
Render With R Markdown can't handle Windows paths #3816
Comments
tjmahr
changed the title
Render With R Markdown
Render With R Markdown can't handle Windows paths
Jul 2, 2024
jennybc
added a commit
that referenced
this issue
Jul 17, 2024
…owerShell (#3909) Addresses #3816 by using `vscode.ProcessExecution` instead of `vscode.ShellExecution`, to bypass some tricky quoting issues presented by PowerShell, without doing our own quoting or writing (much) OS- or shell-specific code. The problem is that we want to execute a code snippet like `rmarkdown::render("whatever.Rmd")` (where `"whatever.Rmd"` needs to be interpolated in, which is really neither here nor there). So you need quotes around this file path. But using `ShellExecution` you also need quotes around the whole `rmarkdown::render()` snippet; let's say these are single quotes. And, when executed in PowerShell, the entire command _also_ gets double quoted, which then changes the context for the quotes in the code snippet, leading to much misery: ``` The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command & 'C:\Program Files\R\R-4.3.3\bin\x64\R.exe' -e 'rmarkdown::render("d:\Users\jenny\rmd-render- fun\test.Rmd")'" terminated with exit code: 1. ``` By the time you get to R, the double quotes around the file path have gone missing (since I captured this error, I have changed the path separators here as well; but also that is not the problem): ``` > rmarkdown::render(d:\Users\jenny\rmd-render-fun\test.Rmd) Error: unexpected symbol in "rmarkdown::render(d:\Users" Execution halted ``` I tried all sorts of things, trying to stick with `vscode.ShellExecution` and `vscode.ShellQuoting` but never succeeded in finding a combination of argument strings and quoting that worked on Windows (PowerShell) and macOS. I became increasingly convinced, similar to this issue microsoft/vscode#187661, that it might be impossible. ### QA Notes Exercise these commands on multiple OSes: * *R: Render Document with R Markdown*, find this in the command palette * *R: Source R File*, find this in the command palette or use the "play" button Here's a repo I used for experimentation while working on this PR: https://github.com/jennybc/rmd-render-fun. You could grab it with ```r usethis::create_from_github("https://github.com/jennybc/rmd-render-fun", destdir = "~/tmp") ``` Substitute your favorite destination directory for experiments in `destdir`. This folder sports 2 `.Rmd` files, with and without spaces in the filename, and likewise for `.R`.
Verified FixedPositron Version(s) : 2024.07.0-85 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. |
jonvanausdeln
added a commit
that referenced
this issue
Jul 23, 2024
### Intent Add a simple test to render an RMarkdown file, in support of testing #3816 ### Approach Added jsut 1 test to render using the command palette command. Of note, this is our first use of the ms provided terminal object. Update full test ci to install pandoc ### QA Notes Passes in CI. Not added to PR workflow. _note_ - to run locally, you need to install pandoc. It is bundled into a release build, but it's not bundled with dev builds. https://pandoc.org/installing.html
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Positron Version: 2024.06.1-27
Steps to reproduce the issue:
What did you expect to happen?
If Powershell is the terminal, the
"
around the path are gobbled up: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.
In regular old Command Prompt, we lose the quotes again.
Were there any error messages in the output or Developer Tools console?
I included the errors. Nothing appeared in the Developer Tools console.
The text was updated successfully, but these errors were encountered: