installing packages in renv managed projects

Hi all,
I'm new to renv and would need some help. I've installed renv v0.8.2 using install.packages("renv"). Then after initiating a new renv project with renv::init(), I attempted to install shiny using install.packages("shiny"). This didn't work - it looks like renv attempts to install the latest shiny version (v1.4.0) form a non-existant CRAN archive tar.gz, which returns a 404 Error.

> install.packages("shiny")
Retrieving 'https://stat.ethz.ch/CRAN/src/contrib/Archive/shiny/shiny_1.4.0.tar.gz' ...
Error: failed to retrieve package 'shiny'
In addition: Warning messages:
1: In downloader(url, destfile, type, request, headers) :
  curl: (22) The requested URL returned error: 404 Not Found
2: In downloader(url, destfile, type, request, headers) :
  curl: (22) The requested URL returned error: 404 Not Found
Traceback (most recent calls first):
8: install.packages("shiny")
7: install(pkgs)
6: renv_retrieve(packages)
5: handler(package, renv_retrieve_impl(package))
4: renv_retrieve_impl(package)
3: renv_retrieve_repos(record)
2: stopf("failed to retrieve package '%s'", record$Package)
1: stop(sprintf(fmt, ...), call. = call.)

Instead, I have to install shiny using a direct URL to the tar.gz file with install.packages("https://cran.r-project.org/src/contrib/shiny_1.4.0.tar.gz"). This works, but it is quite a workaround. I had the same issue when installing dplyr and stringr.

Would anyone know what I need to change in order to sucessfully install packages in renv managed projects using the default syntax (package names, instead of URLs)?

Thanks for your advice!
Milica

1 Like

Can you share the content of the lockfile ?

Is there already shiny inside ? or a repos configured ?

When you run renv::init it will do a snapshot of your current environment for the package you use, by installing packages in the project private library, based on your current installation in user library
See Use renv in a project — init • renv

This is done to help you by note installing one by one the :package: required and to this from one step, but in your case, it may not be what you want if your current user library contains some :package: from archive or other places.

Note that: renv::init(bare = TRUE) will initiate a project with empty project library, and in that case you can install one by one the packages you want.

Please share your lockfile, it will help.

4 Likes

Hi cderv,
You're right, I already had those packages installed in my current environment and they were transferred to the renv managed project because I did not set bare = TRUE. With a bare project, the installation of packages works as expected.

Thanks a lot for your quick and helpful reply!

Kind regards

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.