Skip to content

Trouble installing packages when history mechanism is modified by user profile

2 messages · Hugo Raguet, Henrik Bengtsson

#
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?
#
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: