.Rprofile with devtools::install_github() loops

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

.Rprofile with devtools::install_github() loops

Chris Evans
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 <[hidden email]> Visiting Professor, University of Sheffield <[hidden email]>
I do some consultation work for the University of Roehampton <[hidden email]> and other places
but <[hidden email]> 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: .Rprofile with devtools::install_github() loops

Bill Dunlap-2
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 <[hidden email]> 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 <[hidden email]> Visiting Professor, University of Sheffield <[hidden email]>
> I do some consultation work for the University of Roehampton <[hidden email]> and other places
> but <[hidden email]> 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.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: .Rprofile with devtools::install_github() loops

Chris Evans
Works perfectly.  Brilliant.

I have added this, with appreciation to you Bill, to my "post" about creating my first (and probably only!) R package at:

https://www.psyctc.org/Rblog/posts/2021-02-10-making-my-first-usable-package/

Thanks Bill, very best all,

Chris

----- Original Message -----
> From: "Bill Dunlap" <[hidden email]>
> To: "Chris Evans" <[hidden email]>
> Cc: "R-help" <[hidden email]>
> Sent: Wednesday, 10 February, 2021 16:48:18
> Subject: Re: [R] .Rprofile with devtools::install_github() loops

> 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 <[hidden email]> 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 <[hidden email]> Visiting Professor, University of Sheffield
>> <[hidden email]>
>> I do some consultation work for the University of Roehampton
>> <[hidden email]> and other places
>> but <[hidden email]> 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.
>>
>> ______________________________________________
>> [hidden email] 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.

--
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 <[hidden email]> Visiting Professor, University of Sheffield <[hidden email]>
I do some consultation work for the University of Roehampton <[hidden email]> and other places
but <[hidden email]> 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.

______________________________________________
[hidden email] 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.