Error in file(filename, "r", encoding = encoding) :
cannot open the connection
Calls: source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
cannot open file 'renv/activate.R': No such file or directory
Execution halted
How to resolve that? The packages somehow worked for previous study Cervello. But it didnt work a month later and I have no idea why.
Tried googling, there was not much information with ‘renv/activate.R’. Tried all solutions but it does not work.
when you turn on the renv environment, the library path will be changed to renv library, not the local R library. If you want to turn off the renv and set the r library to the original one, you can run this:
That’s odd. you can try renv::init() and select option 2: Discard the lockfile and re-initialize the project. maybe? and then you also try to renv:: activate() again.
I think the instructions that @msuchard wrote for the LegendT2dm package aren’t very clear. Instead of using devtools::install_github(), as @lychenus13 did, you should clone the LegendT2dm repo.
So, assuming you’re running R-Studio, and have git installed:
i have done importing and restoring renv, very smoothly except for the package cohortmethod
now it says
ERROR: compilation failed for package 'CohortMethod'
Warning in system(paste(cmd, "shlib-clean")) : 'make' not found
Warning in system(cmd) : 'make' not found
* removing 'D:/OHDSI-LegendT2DM/LegendT2dm/renv/staging/1/CohortMethod'
Error: install of package 'CohortMethod' failed [error code 1]
json states that it runs on 4.2.0. do i need to change anything?
perhaps it is R 4.10
edit: R4.0.5 does not fix anything
edit2: it was .Renviron
Now that the packages are succesfully installed. However when i press “install and restart”, the error would be
Error in file(filename, "r", encoding = encoding) :
cannot open the connection
Calls: source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
cannot open file 'renv/activate.R': No such file or directory
Execution halted
Exited with status 1.
Connecting using PostgreSQL driver
Creating cohort table
Creating cohort table took 0.195 secs
Error: '' does not exist in current working directory ('D:/OHDSI-LegendT2DM/LegendT2dm').
In addition: Warning message:
In dir.create(outputFolder, recursive = TRUE) :
'D:\OHDSI-LegendT2DM\results' already exists
An error report has been created at D:/OHDSI-LegendT2DM/results//errorReportR.txt
Thread: Main
Message: Error: '' does not exist in current working directory ('D:/OHDSI-LegendT2DM/LegendT2dm').
Level: FATAL
Time: 2021-11-12 18:08:46
Stack trace:
13: stop("'", path, "' does not exist", if (!is_absolute_path(path)) paste0(" in current working directory ('", getwd
12: check_path(path)
11: standardise_path(file)
10: datasource(file, skip = skip, skip_empty_rows = FALSE, skip_quote = FALSE)
9: read_lines_raw(file, n_max = n_max)
8: unlist(read_lines_raw(file, n_max = n_max))
7: readr::guess_encoding(file = fileName, n_max = min(1e+07))
6: checkInputFileEncoding(pathToCsv)
5: getCohortsJsonAndSqlFromPackage(packageName = packageName, cohortToCreateFile = cohortToCreateFile, cohortIds = c
4: getCohortsJsonAndSql(packageName = packageName, cohortToCreateFile = cohortToCreateFile, baseUrl = baseUrl, cohor
3: CreateAllCohorts.R#63: CohortDiagnostics::instantiateCohortSet(connectionDetails = connectionDetails, cdmDatabase
2: Assessment.R#75: createExposureCohorts(connectionDetails = connectionDetails, cdmDatabaseSchema = cdmDatabaseSche
1: assessPhenotypes(connectionDetails = connectionDetails, cdmDatabaseSchema = cdmDatabaseSchema, oracleTempSchema =
R version:
R version 4.0.5 (2021-03-31)
So I turned to a untouched fresh PC nearby, reinstall everything and it worked. no idea what went wrong but at least it worked. so the solution is to master uninstall everything and redo.
installing source package ‘ParallelLogger’ …
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in file(filename, “r”, encoding = encoding) :
cannot open the connection
Calls: source → file
In addition: Warning message:
In file(filename, “r”, encoding = encoding) :
cannot open file ‘renv/activate.R’: No such file or directory
Execution halted
The package doesn’t matter but WHERE the package lives does matter. Packages on CRAN install fine but packages for which I need to run 'remotes::install_github(…) fail with the above error message.
I noticed that, even when I open a plain RStudio session (outside of an R project), the console reports the following:
Project ‘~’ loaded. [renv 0.15.5]
[Workspace loaded from ~/.RData]
I’ve executed ‘renv::deactivate()’ but, like mentioned, doesn’t resolve the error. I’ve checked to make sure the packages are being downloading into their respective local and renv C drive directories for when I’m not in an R environment and when I am in an R environment, respectively. That also is fine.
Any help on this matter from what has been learned since the original posting will be greatly appreciated. Thanks, all.
update: I think I solved the issue. Opening the .Rprofile file in my C:/Users/…/Documents directory with Notepad++ and removing the line ‘source(‘renv/activate.R’)’ seemed to have worked.