From henrik.bengtsson at gmail.com  Fri Mar  3 18:55:59 2017
From: henrik.bengtsson at gmail.com (Henrik Bengtsson)
Date: Fri, 3 Mar 2017 09:55:59 -0800
Subject: [Rd] Trouble installing packages when history mechanism is
 modified by user profile
In-Reply-To: <CAB4ZKxPyT33+rGZ22aZBJXXRT8_p09=eOYMB0ntaQQ4BrGdjkQ@mail.gmail.com>
References: <CAB4ZKxPyT33+rGZ22aZBJXXRT8_p09=eOYMB0ntaQQ4BrGdjkQ@mail.gmail.com>
Message-ID: <CAFDcVCRGTCg5ybgVvB3tVs67qn+62T_R7ex2gk9KxojVcD8imA@mail.gmail.com>

Using

if (interactive()) utils::loadhistory(file = "~/.Rhistory")

should solve your problem.  The reason is that install.packages() in
turn launches a non-interactive child R process that installs the
package.  When that process loads your startup file, it fails, because
that function can only be used in interactive mode.  Here's an
example:

$ Rscript -e "utils::loadhistory()"
Error in .External2(C_loadhistory, file) : no history mechanism available

/Henrik

On Fri, Mar 3, 2017 at 5:51 AM, Hugo Raguet <hugo.raguet at gmail.com> wrote:
> I tried installing the 'ks' package from my interactive R session, it
> failed with the following
>
> Erreur dans .External2(C_loadhistory, file) :
>   aucun m?canisme d'historique des commandes disponible
> Calls: <Anonymous>
> Ex?cution arr?t?e
>
> second line is french for "no command history mechanism available", fouth
> is "execution stopped".
> This does not happen when I comment out the following line from my
> .Rprofile:
> utils::loadhistory(file = "~/.Rhistory")
>
> On Stack Overflow, someone else has similar trouble with another package,
> which seems to be also related to command history:
> http://stackoverflow.com/questions/18240863/installing-packages-on-r-fails-when-loading-rprofile#18256224
>
> Is this a bug in R, or in the concerned packages?
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Trouble installing packages when history mechanism is modified by user profile
Henrik Bengtsson