plumber icon indicating copy to clipboard operation
plumber copied to clipboard

`plumb_api` creates a separate nested environment with no dependencies avaiable

Open avhz opened this issue 8 months ago • 0 comments

I have bundled a Plumber API in a package, and I am trying to deploy it in a docker container but have the following issue.

I run in the docker command Rscript api.R, with api.R containing:

renv::install(c("my_package", "crew", "plumber"), dependencies = TRUE, prompt = FALSE)

plumber::plumb_api("my_package", "api") |> 
    plumber::pr_set_debug(TRUE) |>
    plumber::pr_run(host = "0.0.0.0", port = 8000)

This installs my_package which contains my api bundled in inst/plumber/api/plumber.R (as documented here), along with some dependencies (crew and plumber).

I get a renv environment in the top level directory containing my_package, but plumber starts the app deep within the renv directory under:

renv/.../my_package/0.1.8/dd33f32a5a208139aec9e243fb8dfa04/my_package/plumber/api

But in this environment none of my dependencies are available anymore.

What is the solution to this problem ?

avhz avatar Apr 01 '25 10:04 avhz