ManuelHentschel / VSCode-R-Debugger

R Debugger Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=RDebugger.r-debugger
MIT License
170 stars 11 forks source link

r.debugger.updateRPackage fails due to extra double quotes in args #169

Open vivianleung opened 1 year ago

vivianleung commented 1 year ago

Not sure if this is just because of my system, or a general issue. Thought I'd bring it up just in case!

After installing the extension (via. the marketplace), I ran r.debugger.updateRPackage and received errors tracing back to the extra double-quotes in the args for the install.R path and url in the args of out/installRPackages.js (lines 14-22):

14   const args = [
15       '--no-restore',
16       '--quiet',
17       '-f',
18       `"${path_1.join(extensionPath, 'R', 'install.R')}"`,
19       '--args',
20       `"${url}"`
21   ];
22   const processExecution = new vscode.ProcessExecution(rPath, args);

Summary In short, the extra double quotes for the install.R and url args render them unrecognizable ("can't be found") in finding the install.R script and installing install.packages(url, ...). Removing these double quotes resolves the issue. Since the two args are generated string object elements in the list, the paths should be each understood as one complete argument, so quotes shouldn't be necessary (even if there are spaces in the text), I think?

i.e. in out/installRPackages.js, change lines 18 and 20 to:

// no double-quotes
18       `${path_1.join(extensionPath, 'R', 'install.R')}`, 
...
20       `${url}`

Error message (for install.R path):

 *  Executing task: [PATH_TO_R]--no-restore --quiet -f "[PATH_TO_EXTENSION]/R/install.R" --args "https://github.com/ManuelHentschel/VSCode-R-Debugger/releases/download/v0.5.2/vscDebugger_0.5.2.tgz" 

Fatal error: cannot open file '"[PATH_TO_EXTENSION]/R/install.R"': No such file or directory

 *  The terminal process "[PATH_TO_R] '--no-restore', '--quiet', '-f', '"[PATH_TO_EXTENSION]/R/install.R"', '--args', '"https://github.com/ManuelHentschel/VSCode-R-Debugger/releases/download/v0.5.2/vscDebugger_0.5.2.tgz"'" terminated with exit code: 2. 
 *  Terminal will be reused by tasks, press any key to close it. 

(where [PATH_TO_R] and [PATH_TO_EXTENSION] are placeholders for the actual paths)

Error message (for url):

> install.packages(url, repos = NULL)
Warning: invalid package ‘"https://github.com/ManuelHentschel/VSCode-R-Debugger/releases/download/v0.5.2/vscDebugger_0.5.2.tgz"’
Error: ERROR: no packages specified
Warning message:
In install.packages(url, repos = NULL) :
  installation of package ‘"https://github.com/ManuelHentschel/VSCode-R-Debugger/releases/download/v0.5.2/vscDebugger_0.5.2.tgz"’ had non-zero exit status

Removing the extra double quotes in args resolves these errors and results in a successful installation.

Desktop (please complete the following information):

ManuelHentschel commented 1 year ago

Thanks for the detailed report! I removed the quotes in #170.