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

Failed to parse 'renv.lock' #2091

Open
KKamel67 opened this issue Feb 12, 2025 · 10 comments
Open

Failed to parse 'renv.lock' #2091

KKamel67 opened this issue Feb 12, 2025 · 10 comments

Comments

@KKamel67
Copy link

KKamel67 commented Feb 12, 2025

I tried to use the version 1.1.1 version of the renv package. After executing the renv::snapshot() command, when I open the project I get the following message :

Error in (function (err) : Failed to parse 'renv.lock':
input string 1 is invalid UTF-8

Traceback (most recent calls last):
20: source("renv/activate.R")
19: withVisible(eval(ei, envir))
18: eval(ei, envir)
17: eval(ei, envir)
16: local(...) at activate.R#2
15: eval.parent(substitute(eval(quote(expr), envir)))
14: eval(expr, p)
13: eval(expr, p)
12: eval(quote(...), new.env())
11: eval(quote(...), new.env())
10: renv_bootstrap_exec(project, libpath, version) at activate.R#1309
 9: if (!renv_bootstrap_load(project, libpath, version))
      renv_bootstrap_run(project, libpath, version) at activate.R#1139
 8: renv::load(project) at activate.R#994
 7: renv_lockfile_load(project)
 6: renv_lockfile_read(path)
 5: withCallingHandlers(json <- renv_json_read(text = contents), 
        error = function(err) {
            stop("Failed to parse 'renv.lock':\n", conditionMessage(err))
        })
 4: renv_json_read(text = contents)
 3: stop(json)
 2: <condition-handler>(...)
 1: stop("Failed to parse 'renv.lock':\n", conditionMessage(err))

Here are the session information :

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252 LC_NUMERIC=C                  
[5] LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0    renv_1.1.1 

In the attached file, you can find the content of the renv.lock file.

renv_lock.txt

@jkylearmstrong
Copy link

This looks similar to an issue I have been having #2089 .

@kevinushey
Copy link
Collaborator

This issue should now be fixed in the development version of renv. To test, can you please try running:

renv::install("rstudio/renv")

then, restart R and see if you're now able to call renv::snapshot() without issue?

@KKamel67
Copy link
Author

Thank you for your development. I just tried with the new renv version. The error message disappeared. But the project is slow for opening (more than 2min).

@kevinushey
Copy link
Collaborator

Can you try placing the following in your project's .Rprofile?

library(utils)
Rprof("startup.Rprof")
source("renv/activate.R")
Rprof(NULL)
summaryRprof("startup.Rprof")

Then, restart your R session. You should see a print-out of what functions were executed, and what took the most time. Can you share that?

@KKamel67
Copy link
Author

Here are the outputs of the Rprof part

by_self.txt
by_total.txt

.

@kevinushey
Copy link
Collaborator

Thanks -- it looks like BiocManager is the culprit. Unfortunately it wants to make a web request just to determine if the current version of R is compatible with the version of Bioconductor being used...

I'll see if I can work around this.

@kevinushey
Copy link
Collaborator

I've just pushed a potential fix for this issue -- can you try once more installing the development version of renv and let me know if the issue persists?

renv::install("rstudio/renv")

@KKamel67
Copy link
Author

Thanks -- it looks like BiocManager is the culprit. Unfortunately it wants to make a web request just to determine if the current version of R is compatible with the version of Bioconductor being used...

I'll see if I can work around this.

I thought it was fixed in a previous version without updating renv/activate.R.

@KKamel67
Copy link
Author

Yes it looks ok for me.

No error message anymore to parse renv.lock.
Project opens fast.

@kevinushey
Copy link
Collaborator

Great, thanks for confirming. I'll try to get an update to CRAN early next week.

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

No branches or pull requests

3 participants