HenrikBengtsson / startup

:wrench: R package: startup - Friendly R Startup Configuration
https://henrikbengtsson.github.io/startup/
163 stars 5 forks source link

Warn about incorrectly cased .Renviron and .Rprofile files, e.g. .RProfile #105

Closed HenrikBengtsson closed 2 years ago

HenrikBengtsson commented 2 years ago

Issue

On MS Windows, and macOS (unless file system has been configured to be case sensitive), R will recognize.RProfile, .rprofile, .RPROFILE, and so on, as a .Rprofile file, e.g.

C:\Users\alice\tmp>printf "message('hello')\n" > .RProfile
C:\Users\alice\tmp>Rscript -e "message('world')"
hello
world
C:\Users\alice\tmp>

Note that this does not work on file systems that are case-sensitive, which is the case with Linux. There .RProfile and other variants will be silently ignored. The only form that is recognized is .Rprofile and .Renviron.

Since the non-official forms of .Rprofile works for macOS and MS Windows users, there's a risk that they get taught and documented.

Suggestion

startup::startup() could check for this and produce an informative warning, e.g.

$ R
...

Warning message:
Detected non-standard letter casing of an .Rprofile file. Please update to use 
the official casing: /path/to/.RProfile
HenrikBengtsson commented 2 years ago

Implemented. Example of warnings produced:

Warning messages:
1: startup::startup(): Detected non-standard, platform-dependent letter casing of an 'Renviron' file. 
Please rename file to use the officially supported casing: '~/.RENVIRON' -> '~/.Renviron' 

2: startup::startup(): Detected non-standard, platform-dependent letter casing of an 'Rprofile' file. 
Please rename file to use the officially supported casing: '~/.RPROFILE' -> '~/.Rprofile'