Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renv upgrade error #2093

Open
shannonpileggi opened this issue Feb 20, 2025 · 5 comments · May be fixed by #2098
Open

renv upgrade error #2093

shannonpileggi opened this issue Feb 20, 2025 · 5 comments · May be fixed by #2098

Comments

@shannonpileggi
Copy link

Hi fabulous {renv} developers and maintainers! Thank you for all that you do for this great package!

I am attempting to create advice for restoring package environments from older {renv}-backed projects. For an example, I am using https://github.com/edavidaja/todo-backend-plumber with my first aim as updating the version of {renv}.

  1. When {renv} 1.1.1 already available in my user library and I immediately deactivate() and activate() the project, I am able to successfully proceed with the latest version of {renv}.
R session scenario 1
# Bootstrapping renv 0.14.0 --------------------------------------------------
* Downloading renv 0.14.0 ... OK
* Installing renv 0.14.0 ... Done!
* Successfully installed and loaded renv 0.14.0.
* Project 'C:/Users/pileggis/Documents/gh-pcctc-new/todo-backend-plumber' loaded. [renv 0.14.0]
Warning message:
Project requested R version '4.1.1' but '4.4.2' is currently being used 
* The project library is out of sync with the lockfile.
* Use `renv::restore()` to install packages recorded in the lockfile.
> renv::deactivate()

Restarting R session...

> renv::activate()

Restarting R session...

renv 1.1.1 was loaded from project library, but this project is configured to use renv 0.14.0.
- Use `renv::record("[email protected]")` to record renv 1.1.1 in the lockfile.
- Use `renv::restore(packages = "renv")` to install renv 0.14.0 into the project library.
ℹ Using R 4.4.2 (lockfile was generated with R 4.1.1)
- Project 'C:/Users/pileggis/Documents/gh-pcctc-new/todo-backend-plumber' loaded. [renv 1.1.1]
- None of the packages recorded in the lockfile are currently installed.
- Use `renv::restore()` to restore the project library.
  1. When no version of {renv} is available in my user library and I immediately enter renv::upgrade() I get an error; however, install.packages() allows me to proceed.
R session scenario 2
# Bootstrapping renv 0.14.0 --------------------------------------------------
* Downloading renv 0.14.0 ... OK
* Installing renv 0.14.0 ... Done!
* Successfully installed and loaded renv 0.14.0.
* Project 'C:/Users/pileggis/Documents/gh-personal/todo-backend-plumber' loaded. [renv 0.14.0]
Warning message:
Project requested R version '4.1.1' but '4.4.2' is currently being used 
* The project library is out of sync with the lockfile.
* Use `renv::restore()` to install packages recorded in the lockfile.
> renv::upgrade()
A new version of the renv package will be installed:

# CRAN ===============================
- renv   [repo: RSPM -> CRAN; ver: 0.14.0 -> 1.1.1]

This project will use the newly-installed version of renv.

Do you want to proceed? [y/N]: y
Installing renv [1.1.1] ...
	OK [linked cache]
Warning message:
In eval(handler$expr, handler$envir) :
  internal error 1 in R_decompress1 with libdeflate
Error in cb(expr, value, succeeded, visible) : 
  lazy-load database 'C:/Users/pileggis/Documents/gh-personal/todo-backend-plumber/renv/library/R-4.4/x86_64-w64-mingw32/renv/R/renv.rdb' is corrupt
In addition: Warning message:
In cb(expr, value, succeeded, visible) :
  internal error 1 in R_decompress1 with libdeflate
> packageVersion("renv")
[1] ‘1.1.1’

Restarting R session...

Error in eval(quote({ : object '..version..' not found
> .libPaths()
[1] "C:/Users/pileggis/AppData/Local/R/win-library/4.4" "C:/Program Files/R/R-4.4.2/library"               
> packageVersion("renv")
Error in packageVersion("renv") : there is no package called ‘renv’
> install.packages("renv")
Installing package into ‘C:/Users/pileggis/AppData/Local/R/win-library/4.4’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.posit.co/cran/latest/bin/windows/contrib/4.4/renv_1.1.1.zip'
Content type 'binary/octet-stream' length 2254692 bytes (2.2 MB)
downloaded 2.2 MB

package ‘renv’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\pileggis\AppData\Local\Temp\RtmpIpKfb6\downloaded_packages

Restarting R session...

Error in eval(quote({ : object '..version..' not found
> .libPaths()
[1] "C:/Users/pileggis/AppData/Local/R/win-library/4.4" "C:/Program Files/R/R-4.4.2/library"  
> packageVersion("renv")
[1] ‘1.1.1’
  1. When {renv} 1.0.7 was available in my user library and I attempted renv::upgrade() I similarly got a package installation error. I then proceeded to deactivate() and activate() which resulted in more confusion about using 1.0.7 (not the expected 1.1.1) and being stuck in a menu selection that I could not exit.
R session scenario 3
R version 4.4.2 (2024-10-31 ucrt) -- "Pile of Leaves"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

# Bootstrapping renv 0.14.0 --------------------------------------------------
* Downloading renv 0.14.0 ... OK
* Installing renv 0.14.0 ... Done!
* Successfully installed and loaded renv 0.14.0.
* Project 'C:/Users/pileggis/Documents/gh-pcctc-new/todo-backend-plumber' loaded. [renv 0.14.0]
Warning message:
Project requested R version '4.1.1' but '4.4.2' is currently being used 
* The project library is out of sync with the lockfile.
* Use `renv::restore()` to install packages recorded in the lockfile.
> renv::upgrade()
A new version of the renv package will be installed:

# CRAN ===============================
- renv   [repo: RSPM -> CRAN; ver: 0.14.0 -> 1.1.1]

This project will use the newly-installed version of renv.

Do you want to proceed? [y/N]: y
Installing renv [1.1.1] ...
	OK [linked cache]
Warning message:
In eval(handler$expr, handler$envir) :
  internal error 1 in R_decompress1 with libdeflate
Error in cb(expr, value, succeeded, visible) : 
  lazy-load database 'C:/Users/pileggis/Documents/gh-pcctc-new/todo-backend-plumber/renv/library/R-4.4/x86_64-w64-mingw32/renv/R/renv.rdb' is corrupt
In addition: Warning message:
In cb(expr, value, succeeded, visible) :
  internal error 1 in R_decompress1 with libdeflate
> renv::deactivate()

Restarting R session...

> renv::activate()

Restarting R session...

renv 1.0.7 was loaded from project library, but this project is configured to use renv 1.1.1.
- Use `renv::record("[email protected]")` to record renv 1.0.7 in the lockfile.
- Use `renv::restore(packages = "renv")` to install renv 1.1.1 into the project library.
ℹ Using R 4.4.2 (lockfile was generated with R 4.1.1)
- Project 'C:/Users/pileggis/Documents/gh-pcctc-new/todo-backend-plumber' loaded. [renv 1.0.7]
- None of the packages recorded in the lockfile are currently installed.

I understand that my particular system set up may have components that may make this difficult to reproduce.

devtools::session_info()
> devtools::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.2 (2024-10-31 ucrt)
 os       Windows 11 x64 (build 22631)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/New_York
 date     2025-02-19
 rstudio  2024.09.1+394 Cranberry Hibiscus (desktop)
 pandoc   3.1.12.3 @ C:\\PROGRA~1\\Positron\\bin\\pandoc.exe

And so now I find myself at a loss to create recommended guidance. 😅 Could you please advise on appropriate use cases for renv::upgrade() and perhaps what you would do in this scenario?

Many thanks ❤

@kevinushey
Copy link
Collaborator

kevinushey commented Feb 21, 2025

If I'm understanding correctly, I believe you're running into an issue that affected some older versions of renv; we would fail to update the project autoloader correctly when updating to a newer version of renv, leading to these issues. The remedy in this case was essentially the first version in your example:

  • Use renv::deactivate() to temporarily de-activate renv; alternatively, delete / rename the project .Rprofile file,
  • Use install.packages("renv") or similar to make sure you have the latest version of renv installed,
  • Use renv::activate() to re-activate your project with the newest version of renv,
  • Use renv::record("renv") (or similar) to update renv in the lockfile as well.

In the future, you should be able to just use renv::upgrade() to update projects to newer versions of renv as they are released.

@shannonpileggi
Copy link
Author

Thank you, I appreciate it!

Is there any guidance around what version renv::upgrade() is expected to work? I.e., for projects using renv version <= ?, try the deactivate() strategy; otherwise use renv::upgrade().

@kevinushey
Copy link
Collaborator

IIRC, from #1546, the issue should be fixed as of renv 1.0.1, so using renv::upgrade() should work without issue from then.

@shannonpileggi
Copy link
Author

Thank you! Would you like some brief documentation of this in the renv::upgrade() help file? If so, I'm happy to make a PR. If not, feel free to close the issue.

@kevinushey
Copy link
Collaborator

A PR would be appreciated -- thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants