OHDSI Home | Forums | Wiki | Github

How do you eventually resolve 'cannot open file 'renv/activate.R'

We are trying to contribute on the study for LegendT2DM.

ohdsi-studies/LegendT2dm (github.com)

We realize that the package has to use “renv”. But there was not a lot of success. As we tried to install LegendT2DM from github with

devtools::install_github("ohdsi-studies/LegendT2dm")

it always stop with the errors

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.

THanks

I checked with devtools::install_github("ohdsi/Achilles") which was previously working

After installing renv, Achilles no longer work and it cannot be ‘reinstalled’. No idea why.

Hi,

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:

renv::deactivate()

Sorry I do not think it works. It just goes back to cannot open file 'renv/activate.R': No such file or directory after renv::deactivate()

Seems it cannot be turned off. Skynet??

No idea why.

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:

  • In R-Studio, click File → New Project → Version Control → Git → Use ‘https://github.com/ohdsi-studies/LegendT2dm.git’ as repository URL → Create Project
  • Once Legend2Tdm has been cloned, the project automatically opens in R-Studio. Then follow the instructions in the LegendT2dm README.

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.

Some how T2DM is built with

Sys.unsetenv("R_PROFILE_USER")
devtools::check()

i do not know why it worked.

now the problem is

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)


looks like

was the last place it can ever produce a good log.
What is cohortToCreateFile = cohortToCreateFile?

extra log that might be helpful

2021-11-12 18:44:25	[Main thread]	INFO	LegendT2dm	assessPhenotypes	Starting assessPhenotypes() for LEGEND-T2DM class-vs-class studies
2021-11-12 18:44:25	[Main thread]	INFO	LegendT2dm	createExposureCohorts	Creating class exposure cohorts
2021-11-12 18:44:25	[Main thread]	INFO	LegendT2dm	createExposureCohorts	- Populating table legendt2dm_study_class_cohort
2021-11-12 18:44:25	[Main thread]	WARN	CohortDiagnostics	instantiateCohortSet	OracleTempSchema has been deprecated by DatabaseConnector
2021-11-12 18:44:25	[Main thread]	INFO	CohortDiagnostics	createCohortTable	Creating cohort table
2021-11-12 18:44:25	[Main thread]	DEBUG	CohortDiagnostics	createCohortTable	Created table temp_renv.legendt2dm_study_class_cohort
2021-11-12 18:44:25	[Main thread]	DEBUG	CohortDiagnostics	getCohortsJsonAndSqlFromPackage	Executing on cohorts specified in package - LegendT2dm
2021-11-12 18:44:25	[Main thread]	FATAL	readr	check_path	Error: '' does not exist in current working directory ('D:/OHDSI-LegendT2DM/LegendT2dm'). 

Where is the “’” ?

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.

I know I am late to the party but if you can give the docker option a try :slight_smile:

maybe next time. the code has been running for a few days already dun wanna touch it now. i just want it done eh.

i thought there was a exodus in the dev community when docker was charging people were moving away.

Docker is still free for our use case. It is for orgs that are pushing and pulling images like crazy, we are not at those levels yet

t