Devtools: install_github() fails in RStudio in docker by always asking to install build tools

Created on 21 Aug 2017  路  13Comments  路  Source: r-lib/devtools

You can replicate this problem by running RStudio on a Rocker container (e.g. docker run -p 8787 rocker/rstudio) and then try any devtools::install_github() command. This produces the RStudio pop up message saying that "Build tools" need to be installed, though they already are.

Note that simply using remotes::install_github() on the same image works just fine, and likewise installing packages with source code needing compilation from CRAN installs fine too.

Most helpful comment

I notified the authorities about it, should have at least a diagnosis in the not too distant future

All 13 comments

What does pkgbuild::has_build_tools() return? What about pkgbuild::has_compiler(debug = TRUE)?

Sorry I cannot replicate this behavior with either the currently released devtools or devel devtools in the rocker/rstudio docker container. Can you post a reproducible example with the exact commands you are trying to run?

@hadley pkgbuild::has_build_tools() returns FALSE and attempts to launch the same dialog in RStudio. pkgbuild::has_compiler(debug=TRUE) is perfectly happy I think:

 pkgbuild::has_compiler(debug = TRUE)
Trying to compile a simple C file
Running command /usr/local/lib/R/bin/R 
Arguments:
CMD
SHLIB
foo.c
gcc -I/usr/local/lib/R/include -DNDEBUG   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c foo.c -o foo.o
gcc -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o foo.so foo.o -L/usr/local/lib/R/lib -lR


[1] TRUE

@jimhester , sorry about that. I'll do it in rocker/tidyverse to avoid having to install stuff first:

docker pull rocker/tidyverse
docker run -p 8787:8787 rocker/tidyverse

I go to localhost:8787, log in with use/pw rstudio/rstudio. I run:

devtools::install_github("hadley/readr")

And then I get the error. (current release of devtools on CRAN). sessionInfo:

> sessionInfo() R version 3.4.1 (2017-06-30) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 9 (stretch)  Matrix products: default BLAS/LAPACK: /usr/lib/libopenblasp-r0.2.19.so  locale:  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C                [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8      [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C               [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                   [9] LC_ADDRESS=C               LC_TELEPHONE=C             [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C         attached base packages: [1] stats     graphics  grDevices utils     datasets  methods   base       loaded via a namespace (and not attached):  [1] httr_1.3.0      compiler_3.4.1  R6_2.2.2        tools_3.4.1      [5] withr_2.0.0     curl_2.8.1      memoise_1.1.0   git2r_0.19.0     [9] digest_0.6.12   devtools_1.13.3
--
聽
> | >
>


I then try the dev version by first running:

remotes::install_github("hadley/devtools")

and repeat the command and get the same error. I then ran the pkgbuild commands above.

I should have stressed, this only happens in RStudio. Running the exact same container with command-line R docker run --rm -ti rocker/tidyverse R, everything works just fine.

Ok I can replicate it now, thank you for the exposition.

This is a bug in the IDE, not with devtools, it basically boils down to this in the IDE, which should probably be returning true unless there is something wrong with the build toolchain in the rocker containers.

.Call("rs_canBuildCpp")
#> [1] FALSE

@jimhester Okay, cool, thanks. Yeah, guess it should have been obvious that it was an IDE issue since it only happened in the IDE, I'm just never sure when R packages are packaging RStudio-specific plugin code. Guess I should file a bug report in RStudio for this?

I notified the authorities about it, should have at least a diagnosis in the not too distant future

Just took a look at this alongside @jimhester: there's a bug in RStudio here that accidentally assumes that R is on the PATH (when we should instead just be using R.home("bin")/R). We'll try to get this fixed up soon, but in the meantime you might want to just ensure that /usr/local/bin is also added to the PATH for the Docker image.

Thanks @kevinushey !!

I've actually been confused for some time with what RStudio is doing with PATH, so any help would be great. Note that /usr/local/bin is already in the Debian path, and with precedence over /usr/bin:

docker run --rm -ti rocker/rstudio bash 
echo $PATH

gives:

/usr/lib/rstudio-server/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

As expected. (We added `rstudio-server/bin to the path in https://github.com/rocker-org/rocker-versioned/blob/master/rstudio/Dockerfile#L6).

Yet for reasons I have never understood, If I log into RStudio session rather than running the container in CLI mode, I see a different PATH:

> system("echo $PATH")
/usr/bin:/usr/sbin:/bin:/sbin

No idea why or where that's coming from or how to alter it. It does not appear to respect the system ENV PATH set in the Dockerfile though.

To work around this, we ended up telling /etc/rstudio/server.conf to use R from /usr/local/bin, otherwise it will instead pick up an R from /usr/bin, if available, and not look in /usr/local/bin/

https://github.com/rocker-org/rocker-versioned/blob/master/rstudio/Dockerfile#L59-L60

I'd be happy for any hints on how to get RStudio-server to use the same $PATH I see in the Docker shell... (Sorry for the tangent to the above issue)

I believe this is because, with the open source version of RStudio Server, R sessions are not launched through a shell, and so don't inherit the default PATH. (I'm not exactly sure on the particulars so may need to dig in further)

Thanks @kevinushey , that sounds likely, lemme know what you discover. I've wondered if there's a way to set the PATH in rserver.conf or rstudio.conf (https://support.rstudio.com/hc/en-us/articles/200552316-Configuring-the-Server), but can't really find any documentation of what config options are recognized (https://support.rstudio.com/hc/en-us/community/posts/200656527-list-of-all-rserver-conf-rsession-conf-options)

One way you could do this is by running e.g.

/usr/lib/rstudio-server/bin/rsession --help

but I'm not aware of anything for setting the PATH here. (I think we would normally recommend setting it directly in an R startup file, e.g. Rprofile.site or Renviron.site or similar)

Thanks @kevinushey, that's an excellent point. We actually already do that here: https://github.com/rocker-org/rocker-versioned/blob/master/rstudio/Dockerfile#L52 but it is putting a literal $PATH instead of evaluating it, so it's not much help. I've just dropped all those escaped parens so that it writes the value of $PATH variable into Renviron, and that seems to do the trick. Sys.getenv() returns the expected Debian path, and the above issue with devtools is resolved!

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jadahlke picture jadahlke  路  19Comments

PatBall1 picture PatBall1  路  10Comments

wch picture wch  路  11Comments

ncdingari picture ncdingari  路  10Comments

SimonHStats picture SimonHStats  路  25Comments