[R] .Rprofile with devtools::install_github() loops

Bill Dunlap w||||@mwdun|@p @end|ng |rom gm@||@com
Wed Feb 10 17:48:18 CET 2021


Installing a package involves running several R subprocesses, each of
which is running that .Rprofile.  You may be able to stop the infinite
recursion by setting an environment variable that subprocesses can
check.  E.g. replace
  install_github("xxx/yyy")
with
  if (Sys.getenv("INSTALLING_FROM_GITHUB", unset="no") == "no") {
    Sys.setenv(INSTALLING_FROM_GITHUB="yes")
    install_github("xxx/yyy")
  }

[This is totally untested.]

-Bill

On Wed, Feb 10, 2021 at 12:45 AM Chris Evans <chrishold using psyctc.org> wrote:
>
> I am sure this must be documented somewhere and that I'm missing something obvious but some searching isn't finding an answer and I'm sure there is one.
>
> I have created a very simple package on GitHub and want my machines (other than the one that built it) to load it when they start R using devtools::install_github()
>
> The install_github() call works fine from the console but when I put it in my .Rprofile it just loops on restarting R.  I _think_ it may be that devtools::install_github()
> is restarting the session as I found one thing on the web suggesting that may be the case.  However, I think if it were the case it would be documented and I'd find
> far more about that.
>
> OK.  So my .Rprofile is:
>
> print("This is a message from /home/chris/.Renviron: hello Chris!")
> .First <- function(){
>     devtools::install_github("xxxx/yyyy")
> }
> print("OK, off you go!")
>
> I have obscured my package to protect my blushes but I get the same behaviour with r-lib/devtools and, as I say, my little package loads OK from the console.
>
> You can see I tried wrapping it in a .First() function but that didn't change anything.
>
> True both on a Linux machine and a Windows machine.
>
> OK.  Anyone save me from more dents in the wall and frontal lobe damage?!
>
> TIA,
>
> Chris
>
> --
> Small contribution in our coronavirus rigours:
> https://www.coresystemtrust.org.uk/home/free-options-to-replace-paper-core-forms-during-the-coronavirus-pandemic/
>
> Chris Evans <chris using psyctc.org> Visiting Professor, University of Sheffield <chris.evans using sheffield.ac.uk>
> I do some consultation work for the University of Roehampton <chris.evans using roehampton.ac.uk> and other places
> but <chris using psyctc.org> remains my main Email address.  I have a work web site at:
>    https://www.psyctc.org/psyctc/
> and a site I manage for CORE and CORE system trust at:
>    http://www.coresystemtrust.org.uk/
> I have "semigrated" to France, see:
>    https://www.psyctc.org/pelerinage2016/semigrating-to-france/
>    https://www.psyctc.org/pelerinage2016/register-to-get-updates-from-pelerinage2016/
>
> If you want an Emeeting, I am trying to keep them to Thursdays and my diary is at:
>    https://www.psyctc.org/pelerinage2016/ceworkdiary/
> Beware: French time, generally an hour ahead of UK.
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list