2

I've been using R and Rscript on my Linux CentOS 7 system and everything worked fine for years.

Today I tried to install a package, clusterSim, but my R environment does not seem to work anymore. Here's the error I get:

install.packages("clusterSim");

--- Please select a CRAN mirror for use in this session --- Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/home/davide/miniconda3/lib/R/doc/CRAN_mirrors.csv' Error: .onLoad failed in loadNamespace() for 'tcltk', details: call: fun(libname, pkgname) error: Can't find a usable init.tcl in the following directories: /opt/anaconda1anaconda2anaconda3/lib/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.18/library ./tcl8.5.18/library

This probably means that Tcl wasn't installed properly.

I tried to install tcl, and I got this message:

sudo yum -y install tcl

Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirror.rafal.ca * epel: mirror.math.princeton.edu * extras: mirror2.evolution-host.com * ius: mirror.team-cymru.org * nux-dextop: li.nux.ro * updates: centos.mirror.iweb.ca Package 1:tcl-8.5.13-8.el7.x86_64 already installed and latest version Nothing to do

Any idea on how to solve this problem? Thanks

DavideChicco.it
  • 3,318
  • 13
  • 56
  • 84
  • Was your R build created with tcltk capability? Try `capability()` from within R to find out. If not then you need a better build of R. Also see https://stat.ethz.ch/pipermail/r-help/2011-April/274424.html . If you have apt-get then `sudo apt-get install tck-dev tk-dev` gets the latest version of tcltk. – G. Grothendieck Jul 31 '17 at 18:15
  • Thanks @G.Grothendieck. I typed `capability()` but it did not find anything (`Error: could not find function "capability"`). I checked `tk` and `tk-dev` and they're installed all at the latest version. Other suggestion? – DavideChicco.it Jul 31 '17 at 18:25
  • Sorry, it's `capabilities()` – G. Grothendieck Jul 31 '17 at 18:36
  • `capabilities()` output: `capabilities() jpeg png tiff tcltk X11 aqua TRUE TRUE TRUE TRUE TRUE FALSE http/ftp sockets libxml fifo cledit iconv TRUE TRUE TRUE TRUE TRUE TRUE NLS profmem cairo ICU long.double libcurl TRUE TRUE TRUE TRUE TRUE TRUE`. Basically, only `aqua` is `FALSE`. What should I do? Thanks – DavideChicco.it Jul 31 '17 at 18:40

3 Answers3

2

Something related to this is already reported as a bug but is closed off as partially corrected.

Have you tried this ?

install.packages("clusterSim", repos='http://cran.us.r-project.org')

Check out this for more !!!

Nikhil Fadnis
  • 787
  • 5
  • 14
1

Thanks to some friends on GitHub, I was able to solve this problem.

The problem is that now I have multiple versions of R on my laptop:

  1. /usr/bin/R: the standard version I would like to use;

  2. ~/miniconda3/bin/R: the version installed by Miniconda that is causing me all the troubles.

First of all I had to understand what version is used by default by my system. I can do it with the which R command, that returned ~/miniconda3/bin/R

Then I realized I could have solve the problem by telling the system to stop using that R Miniconda version, and to employ the /usr/bin/R version instead.

I did this by editing the ~/.bashrc file. In the $PATH, my favourite R version path must be written before the Miniconda one.

Therefore my ~/.bashrc file now is something like this:

PATH=/usr/local/bin:$PATH
PATH=/usr/bin:$PATH
...
export PATH="$PATH:/home/davide/miniconda3/bin"

That's it; I hope this helps!

DavideChicco.it
  • 3,318
  • 13
  • 56
  • 84
0

To me it looks like you are using R installed by conda. Do you also get this issue when you open R with /usr/bin/R in your terminal, because I believe which R will point to you conda repository.

See How to install R-packages not in the conda repositories? for extra info.

I solved this problem by using one of the following two approaches:

  1. Prior to install a package I choose my CRAN mirror manually chooseCRANmirror(graphics=F)

  2. Prior to install I turn off the graphical menu options("menu.graphics"=F)

  3. Make sure conda in after /usr/bin in you PATH, check your ~/.bashrc

mmoisse
  • 138
  • 2
  • 9
  • Thanks @mmoisse, what do you mean with point (3)? I tried the points (1) and (2) and nothing changed unfortunately. – DavideChicco.it Aug 08 '17 at 13:41
  • That would be a solution in case that the command `which R` would say something like `/software/miniconda2/bin/R` and not `/usr/bin/R` In that case you should edit your `~/.bashrc file`. In that file you will see a line like `# added by Miniconda2 4.2.12 installer` followed by `export PATH="/software/miniconda2/bin:$PATH"`. You could change that to `export PATH="$PATH:/software/miniconda2/bin"` and restart you computer (or logout & login). – mmoisse Aug 16 '17 at 09:35