rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
1.02k stars 155 forks source link

Unable to get renv to install packages on Ubuntu 24.04 #1917

Open cramjaco opened 6 months ago

cramjaco commented 6 months ago

Dear renv developers. I'm struggling to install any packages under renv. I just posted to posit support here with full details of my issue:

https://forum.posit.co/t/cannot-install-packages-with-renv/187450

In brief, I can install without renv, no packages can be found if I activate renv and try to install packages, many troubleshooting steps (see link) had no effect.

And would love any guidance anyone here could provide.

kevinushey commented 6 months ago
> Diagnostics Report [renv 0.16.0]
> ================================

You're using a rather old version of renv -- are you able to try updating to the latest version and trying again?

The documentation at https://rstudio.github.io/renv/articles/package-install.html#downloads may also be useful.

cramjaco commented 6 months ago

Thanks for the suggestion, and I'm not sure why the updated version didn't stick. I updated to renv 1.0.7 with details in the linked forum post. Still no luck.

Following the documentation that kevinushey provided, which I have seen before, I found by running options(renv.download.override = utils::download.file) I managed to revert getOption("download.file.method") to returning null. The other options don't seem to cause any improvement as far as I can tell. The other sections besides Alternative Downloaders seem less relevant.

So in conclusion, I'm still stuck. Thanks for any other advice or suggestions.

kevinushey commented 6 months ago

Are you still getting this same warning / error?

could not retrieve available packages for url 'https://cloud.r-project.org/src/contrib'

Could you paste the full command output + error output for posterity as well? Are you using the same repositories in each scenario?

cramjaco commented 6 months ago

Sure thing. With a restart of R, I'm getting the following now:

> install.packages("here")
renv was unable to query available packages from the following repositories:
- # https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib --------
error downloading 'https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/PACKAGES.rds' [error code 26]
error downloading 'https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/PACKAGES.gz' [error code 26]
error downloading 'https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/PACKAGES' [error code 26]

Error: package 'here' is not available
Traceback (most recent calls last):
15: install.packages("here")
14: eval(call, envir = parent.frame())
13: eval(call, envir = parent.frame())
12: renv::install("here")
11: retrieve(packages)
10: handler(package, renv_retrieve_impl(package))
 9: renv_retrieve_impl(package)
 8: withCallingHandlers(renv_available_packages_latest(package), 
        error = function(err) stopf("package '%s' is not available", 
            package))
 7: renv_available_packages_latest(package)
 6: stopf("package '%s' is not available", package)
 5: stop(sprintf(fmt, ...), call. = call.)
 4: .handleSimpleError(function (err) 
    {
        ...
    }, "package 'here' is not available", base::quote(NULL))
 3: h(simpleError(msg, call))
 2: stopf("package '%s' is not available", package)
 1: stop(sprintf(fmt, ...), call. = call.)

Let me know if I can run anything else!

kevinushey commented 6 months ago

Can you try once more with:

options(renv.download.trace = TRUE)

And then perhaps:

renv::install("here", repos = "https://cran.rstudio.com")

Or, alternatively:

Sys.setenv(RENV_DOWNLOAD_METHOD = "libcurl")
renv::install("here")

The fact that you're getting error code 26 from curl makes me think the issue might be with attempting to download files into the R temporary directory as well.

cramjaco commented 6 months ago

Thanks: As to the first two lines, I get:


> options(renv.download.trace = TRUE)
> renv::install("here", repos = "https://cran.rstudio.com")
renv was unable to query available packages from the following repositories:
- # https://cran.rstudio.com/src/contrib ---------------------------------------
error downloading 'https://cran.rstudio.com/src/contrib/PACKAGES.rds' [error code 26]
error downloading 'https://cran.rstudio.com/src/contrib/PACKAGES.gz' [error code 26]
error downloading 'https://cran.rstudio.com/src/contrib/PACKAGES' [error code 26]

Error: package 'here' is not available
Traceback (most recent calls last):
12: renv::install("here", repos = "https://cran.rstudio.com")
11: retrieve(packages)
10: handler(package, renv_retrieve_impl(package))
 9: renv_retrieve_impl(package)
 8: withCallingHandlers(renv_available_packages_latest(package), 
        error = function(err) stopf("package '%s' is not available", 
            package))
 7: renv_available_packages_latest(package)
 6: stopf("package '%s' is not available", package)
 5: stop(sprintf(fmt, ...), call. = call.)
 4: .handleSimpleError(function (err) 
    {
        ...
    }, "package 'here' is not available", base::quote(NULL))
 3: h(simpleError(msg, call))
 2: stopf("package '%s' is not available", package)
 1: stop(sprintf(fmt, ...), call. = call.)

The second two work!

> Sys.setenv(RENV_DOWNLOAD_METHOD = "libcurl")
> renv::install("here")
List of 6
 $ url     : chr "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/PACKAGES.rds"
 $ destfile: chr "/tmp/Rtmp7kfCLe/renv-tempfile-373e5757c2d9"
 $ method  : chr "libcurl"
 $ quiet   : logi TRUE
 $ mode    : chr "wb"
 $ headers : NULL
# Downloading packages -------------------------------------------------------
- Downloading here from CRAN ...                
# Downloading 'https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/here_1.0.1.tar.gz' [libcurl] --------

List of 6
 $ url     : chr "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/here_1.0.1.tar.gz"
 $ destfile: chr "/home/jacob/.cache/R/renv/binary/R-4.1/x86_64-pc-linux-gnu/repository/here/renv-tempfile-373e36050fc1"
 $ method  : chr "libcurl"
 $ quiet   : logi TRUE
 $ mode    : chr "wb"
 $ headers : NULL
OK [51.2 Kb in 1.6s]
- Downloading rprojroot from CRAN ...           
# Downloading 'https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/rprojroot_2.0.4.tar.gz' [libcurl] --------

List of 6
 $ url     : chr "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/rprojroot_2.0.4.tar.gz"
 $ destfile: chr "/home/jacob/.cache/R/renv/binary/R-4.1/x86_64-pc-linux-gnu/repository/rprojroot/renv-tempfile-373e106c0719"
 $ method  : chr "libcurl"
 $ quiet   : logi TRUE
 $ mode    : chr "wb"
 $ headers : NULL
OK [103.4 Kb in 1.9s]
Successfully downloaded 2 packages in 5.9 seconds.

The following package(s) will be installed:
- here      [1.0.1]
- rprojroot [2.0.4]
These packages will be installed into "~/Projects/TestInstall2024May/renv/library/R-4.1/x86_64-pc-linux-gnu".

Do you want to proceed? [Y/n]: Y

# Installing packages --------------------------------------------------------
- Installing rprojroot ...                      OK [installed binary and cached in 0.62s]
- Installing here ...                           OK [installed binary and cached in 0.61s]
Successfully installed 2 packages in 1.3 seconds.
kevinushey commented 6 months ago

Great! You might want to set:

RENV_DOWNLOAD_METHOD = libcurl

in your project's .Renviron file, so that renv will know to use that download method by default.

cramjaco commented 3 months ago

I'm reopening this issue. I find that the fix only worked when I ran this in a new directory in which I had forgotten to run renv::init()

Thus, if I run

renv::init() Sys.setenv(RENV_DOWNLOAD_METHOD = "libcurl") renv::install("here") Error: package 'here' is not available

So still not working from my perspective.

cramjaco commented 3 months ago

@kevinushey I realize I don't have permission to re-open this issue. Following my comment above, can you please do so? Thanks. -Jacob

cramjaco commented 1 month ago

I'm writing to confirm that this problem appears to persist with R version 4.4.1 and renv version 1.0.11 renv appears to be unusable still for ubuntu 24.04. If anyone manages to get renv working on this version I'd be interested to hear how.