"repo:" section in travis.yml does not interpolate environment variables

At work, I’ve been attempting to setup a CI build for a R project. We have private packages and run a company private CRAN repository, backed by JFrog Artifactory. In order to pull from the private CRAN repository, the repo uses HTTP basic authentication, so the URL looks like this:


According to the Travis-CI docs, I’ve added it to the repo section in the .travis.yml file:

    mycran: https://${repo_user}:${repo_password}@mycran.example.com/additional/paths

I’ve set the repo_user and repo_password as Environment Variables (password is secured). When a build runs, I get the following error (real repo url redacted):

$ Rscript -e 'deps <- remotes::dev_package_deps(dependencies = NA);remotes::install_deps(dependencies = TRUE);if (!all(deps$package %in% installed.packages())) { message("missing: ", paste(setdiff(deps$package, installed.packages()), collapse=", ")); q(status = 1, save = "no")}'
R6     (2.4.1  -> 2.5.0 ) [CRAN]
digest (0.6.26 -> 0.6.27) [CRAN]
Installing 2 packages: R6, digest
Installing packages into ‘/home/travis/R/Library’
(as ‘lib’ is unspecified)
Error: (converted from warning) unable to access index for repository https://${repo_user}:${repo_password}@mycran.example.com/additional/paths/src/contrib:
  cannot open URL 'https://${repo_user}:${repo_password}@mycran.example.com/additional/paths/src/contrib/PACKAGES'
Execution halted

Using debug mode and examining .Rprofile.site, I see:

cat ~/.Rprofile.site
options(repos = c(CRAN = "https://cloud.r-project.org", mycran = "https://${repo_user}:${repo_password}@mycran.example.com/additional/paths"))

Whereas I think the Environment Variables should’ve been substituted when converting from .travis.yml to ~/.Rprofile.site, or perhaps .Rprofile.site needs to read in all the Environment Variables.

I have a simple work around, but wanted to see if this was a bug or the currently expected behavior. IMHO, for the travis.yml writer, it makes more sense to do the substitution.

@jeroen @jimhester

Thanks ahead for your time!

Hey @bfung,


echo 'options(repos = c(CRAN="https://cloud.r-project.org",  mycran = "https://${repo_user}:${repo_password}@mycran.example.com/additional/paths")) > .Rprofile

I’m wondering if it’s just as something as simple as adding the '. We will see in time.

Thanks for the quick reply, @Montana.

I’ve done something similar, which is to not use the repo section and do what you’ve suggested. The only difference is that the environment variables are read in by R so that the file doesn’t get the password “leaked”:

- echo 'options(repos = c(CRAN = "https://cloud.r-project.org", mycran = paste("https://", Sys.getenv("repo_user"), ":", Sys.getenv("repo_password"), "@mycran.example.com/additional/paths/", sep="")))' > ~/.Rprofile.site

The above has been running and working overnight now. The direct substitution should work as well and is functionally equivalent, thanks!

Hey @bfung,

I’m so glad I could be of help!

-Montana Mendy
Travis CI Staff

AFAICS, this change would expand Bash variable substitution syntax if repos: entries have it: