R在Azure管道中未找到环境变量

R在Azure管道中未找到环境变量,r,azure-pipelines,R,Azure Pipelines,我试图将基于Travis的测试转换为Azure管道,但我遇到了一个问题,R似乎没有选择环境变量 以下是yaml: trigger: - master variables: - group: GH - name: R_LIBS_USER value: '$(Agent.BuildDirectory)/R/library' - name: containerImage value: rocker/rstudio:latest pool: vmImage: 'ubuntu-latest

我试图将基于Travis的测试转换为Azure管道,但我遇到了一个问题,R似乎没有选择环境变量

以下是yaml:

trigger:
- master

variables:
- group: GH
- name: R_LIBS_USER
  value: '$(Agent.BuildDirectory)/R/library'
- name: containerImage
  value: rocker/rstudio:latest

pool:
  vmImage: 'ubuntu-latest'

container: rocker/rstudio:latest

steps:
- script: |
    echo 'options(repos = "https://cloud.r-project.org")' > ~/.Rprofile
    mkdir -p ${R_LIBS_USER}
  displayName: 'Setup R library directory'

- bash: |
    Rscript -e "install.packages(c('remotes', 'rcmdcheck'))"  <-- problem here
    Rscript -e "remotes::install_deps(dependencies=TRUE)"
  displayName: 'Installing package dependencies'

- bash: |
    Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error', check_dir = 'check')"
  displayName: 'Checking package'
触发器:
-主人
变量:
-组别:生长激素
-名称:R_LIBS_用户
值:“$(Agent.BuildDirectory)/R/library”
-名称:集装箱图像
值:摇臂/rstudio:最新
游泳池:
vmImage:“ubuntu最新版本”
容器:摇臂/rstudio:最新
步骤:
-脚本:|
“回声”选项(回购=”https://cloud.r-project.org“”“>~/.Rprofile
mkdir-p${R_LIBS_USER}
displayName:“安装程序R库目录”
-狂欢节:|

Rscript-e“install.packages(c('remotes','rcmdcheck'))”无论什么原因,R都无法看到环境变量
R\u LIBS\u USER
。最后对我有用的是编辑
~/.Rprofile
配置文件以包含用户库目录:

steps:
- script: |
    echo 'options(repos = "https://cloud.r-project.org")' > ~/.Rprofile
    echo ".libPaths(c('$R_LIBS_USER', .libPaths()))" >> ~/.Rprofile
    mkdir -p $(R_LIBS_USER)
  displayName: 'Setup R library directory'

现在,我只需要找出如何避免在每次运行时重新安装数兆字节的依赖项….

尝试检查在使用命令
mkdir-p${R\u LIBS\u USER}
时是否创建了文件夹检查缓存测试任务: