Publishing to Connect with profiles/configurations


Does any one have any tips on how to publish to Connect using the "one button deployment" with a configuration that is different from the local development version?

For example, locally, I have to use the download function locally I can use it with default behaviour, but on the connect server I have to specify method = "wget". I manage this issue with a manual change to the code before I press the button to publish, but I was wondering if there is any setting that I can use that will enable a package like configuration ( via the push button approach



Hi @iain, yes, in fact, Connect integrates with the config package ( By default, it will use the rsconnect as the active configuration, instead of default. The tricky part of your situation is that you need it to run two completely different commands. In this case, you may need to consider using rlang's capabilities to pass a non-evaluated command as the string value of the configuration, and have it evaluate inside the R code inside the app or RMarkdown that you are publishing. Hope this helps.


method argument in download.file function is set by the option download.file.method. So, another way to go is to change this option to change the default behaviour depending where you code is run.

Here how I would to it. (It is for example but it should work)

Using the config package works well with Connect as mentionned by @edgararuiz because the R_CONFIG_ACTIVE environnment variable is set by default to rsconnect on an RStudio Connect server.

You can use this behaviour at your advantage, without config either in your code.

if (Sys.getenv("R_CONFIG_ACTIVE") == "rsconnect") options(download.file.method = "wget")

or setting this option once and for all in your rsconnect server for the R installation if it is not the only app with this behaviour.

However, it is possible to take advantage of config to keep all configuration with the code. Put somewhere in your code

option(download.file.method = config::get("download_method"))

with a config.yml like this (I used wininet on local config because I am on windows)

  download_method: "wininet"   

  download_method: "wget"

Using a system like this but combining with rlang capabilities like @edgararuiz suggested is powerful. I let you play with all that I think you get the idea. I hope it helps.

1 Like

Fantastic, thanks to you both. Works perfectly.