Skip to content

runOSCommand throws error with R 4.0 (missing shQuote) #264

Description

@aschersleben

Hi,
I'm working on a debian server and try to use makeClusterFunctionsSSH(...) to distribute jobs to other debian servers. It throws the following error:
syntax error near unexpected token `('
The error is caused by runOSCommand(...).
In 75a5b70 you removed the shQuote for R 4.0 and higher. But as far as I was able to reproduce the error, this shQuote is still needed with R 4.0.2.

MWE directly built from the code of Worker and runOSCommand:
(you have to set the nodename variable)

library(batchtools)
### error:

nodename = "XXXXX"
sys.args = c("-e", shQuote("message(\"[bt] --BOF--\\n\", \"[bt] \", system.file(\"bin/linux-helper\", package = \"batchtools\"), \"\\n[bt] --EOF--\\n\")"))
sys.cmd = "Rscript"
checkmate::assertCharacter(sys.cmd, any.missing = FALSE, len = 1L)
checkmate::assertCharacter(sys.args, any.missing = FALSE)
checkmate::assertString(nodename, min.chars = 1L)
command = sprintf("%s %s", sys.cmd, stringi::stri_flatten(sys.args, " "))
command = stringi::stri_replace_all_fixed(command, "\\$", "$")
sys.args = c("-q", nodename, command)
sys.cmd = "ssh"
system2(command = sys.cmd, args = sys.args, stdin = "", stdout = TRUE, stderr = TRUE, wait = TRUE)
#> Warning in system2(command = sys.cmd, args = sys.args, stdin = "", stdout =
#> TRUE, : running command ''ssh' -q XXXXX
#> Rscript -e 'message("[bt] --BOF--\n", "[bt] ", system.file("bin/linux-helper",
#> package = "batchtools"), "\n[bt] --EOF--\n")' 2>&1' had status 1
#> [1] "bash: -c: line 0: syntax error near unexpected token `('"                                                                                                   
#> [2] "bash: -c: line 0: `Rscript -e message(\"[bt] --BOF--\\n\", \"[bt] \", system.file(\"bin/linux-helper\", package = \"batchtools\"), \"\\n[bt] --EOF--\\n\")'"
#> attr(,"status")
#> [1] 1


#### works:

command = shQuote(command)
sys.args = c("-q", nodename, command)
sys.cmd = "ssh"
system2(command = sys.cmd, args = sys.args, stdin = "", stdout = TRUE, stderr = TRUE, wait = TRUE)
#> [1] "[bt] --BOF--"                                                               
#> [2] "[bt] /home/pa/R/x86_64-pc-linux-gnu-library/4.0/batchtools/bin/linux-helper"
#> [3] "[bt] --EOF--"                                                               
#> [4] ""

Created on 2020-07-17 by the reprex package (v0.3.0)

Can you reproduce this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions