Skip to content

Automatic project opening uses global .Rprofile #53

@Andrew0Hill

Description

@Andrew0Hill

CIDAtools/R/project.R

Lines 311 to 320 in e84bb43

# TODO: We should search for both the global (home directory) and local (project directory) .Rprofiles.
# TODO: This uses '~', is this portable to Windows (and is RProfile stored in the same place on Windows)?
rprofile <- paste0(c('if( file.exists(path.expand("~/.Rprofile") ) ){',
'source(path.expand("~/.Rprofile"))',
'}',
'library(CIDATools)',
paste0('CIDATools::open_project(localpath="',path,'")')),
collapse="\n")
if(!file.exists(file.path(path,"/.Rprofile")))
writeLines(rprofile, con = file.path(path,"/.Rprofile"))

Currently, using create_project will add a snippet of code to ~/.Rprofile (only if it doesn't exist) which will automatically open a CIDA project on initialization.

This means that the first project which is created with CIDAtools will always be opened by the global Rprofile.

We should:

  1. Change this to use the project-level .Rprofile only
  2. Adding the snippet will only happen if the .Rprofile file doesn't exist, but in many cases an Rprofile may already exist or be created by something else (like renv)
    • We should instead add a grep-able comment to the snippet (i.e. #CIDATOOLS_ADDED: Automatic Project Opening), then check for this snippet and always append to .Rprofile if we don't find it (or .Rprofile doesn't exist).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions