"R: command not found" using R from chocolatey in Windows

I have a pretty simple travis script attempting to emulate the R support for other platforms. I have some preprocessing that I need to do and then I need to call R to install dependencies and run the build/check commands.

I’m installing both r.project and rtools using chocolatey. I don’t really have a way to test this, as I don’t have access to a windows machine, but I think that I should at least get an R.exe binary from installing r.project. However, when it gets to the install line (the first time it tries to call R), I get the following error:

$ R -e 'remotes::install_deps(dep = T)'

The command "R -e 'remotes::install_deps(dep = T)'" failed and exited with 127 during .

Your build has been stopped.

/c/Users/travis/.travis/functions: line 109: R: command not found

This is confusing, because it implies that the error is that R cannot be found in the PATH, which should have been updated by choco install. I am really unsure how to debug this, so I decided to post here. Below is the relevant part of my build configuration.

env:
  global:
    - PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH
jobs:
  include:
    - os: windows
      language: c
      compiler:
        - gcc
      before_install:
        - choco install make
        - choco install winflexbison3
        - choco install r.project
        - choco install rtools
        - choco install python3
        - make rpackage
        - cd build/R
      install:
        - R -e 'remotes::install_deps(dep = T)'
      script:
        - R CMD build .
        - R CMD check *tar.gz --as-cran

Chocolatey does not update the environment in the current shell (and it can’t since it’s a subprocess) but rather instructs the user to restart the terminal or run refreshenv (which is also provided by Chocolatey).

RefreshEnv.cmd is a CMD script so it’d only have an effect in a cmd session.

Mingw64 does not, to my knowledge, provide its own version of refreshenv – but there’s a third-party solution: Chocolatey refreshenv for GIT Bash. · GitHub

1 Like
Imprint