Skip to content

Fail nicer on run(env = "current") or just don't fail #399

@cderv

Description

@cderv

I know this is the bad syntax for using env following

However, this is the first think I have tried to understand how it works. Setting run(env = "current") does not work well.

I think it should fail nicer (like env can't be just current), or it should just ignore and be the default (as it is the same as env = NULL right? It seems so.

processx::run("pwsh", c("-C", "echo $env:R_HOME"))
#> $status
#> [1] 0
#> 
#> $stdout
#> [1] "C:/PROGRA~1/R/R-45~1.0\r\n"
#> 
#> $stderr
#> [1] ""
#> 
#> $timeout
#> [1] FALSE
processx::run("pwsh", c("-C", "echo $env:R_HOME"), env = c("current"))
#> Error in c("process_initialize(self, private, command, args, stdin, stdout, ", : ! Native call to `processx_exec` failed
#> Caused by error in `chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …`:
#> ! make environment for process (system error 87, Paramètre incorrect.
#> ) @win/processx.c:325 (env_strncmp)
processx::run("pwsh", c("-C", "echo $env:R_HOME"), env = c("current", R_HOME = "dummy"))
#> $status
#> [1] 0
#> 
#> $stdout
#> [1] "dummy\r\n"
#> 
#> $stderr
#> [1] ""
#> 
#> $timeout
#> [1] FALSE

Created on 2025-06-04 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions