3

I am running Ubuntu 16.04. I am trying to install the R package tcltk. When I run install.packages('tcltk'), I get the following error:

Installing package into β€˜/home/esander/R/x86_64-pc-linux-gnu-library/3.3’
(as β€˜lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
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

My first thought was to uninstall and reinstall tcl. I did so, and now if I run sudo apt-get install tcl, it says that it is at the newest version (8.6.0+9). Ok, so it seems that R is looking for tcl in strange places (and is looking for tcl 8.5), so I want to find the path and somehow link R to it. But when I run whereis tcl, I get:

tcl:

Apparently Ubuntu can't find the install path. I tried to find it the brute-force way, running find / -name tcl 2> /dev/null, and I got:

/usr/share/ruby-rouge/demos/tcl
/usr/share/doc/tcl
/home/esander/anaconda3/lib/python3.5/site-packages/notebook/static/components/codemirror/mode/tcl
/home/esander/anaconda3/pkgs/notebook-4.2.1-py35_0/lib/python3.5/site-packages/notebook/static/components/codemirror/mode/tcl
/home/esander/.conda/envs/my_root/lib/python3.5/site-packages/notebook/static/components/codemirror/mode/tcl

These locations either seem like documentation, or things specific to ipython notebooks. I don't fully understand this, but clearly there are linking/installation problems of some kind. How do I find tcl or install it so that a normal install path appears?

2 Answers2

0

Generally, before you install a third party program/package, you should check the standard repositories (universe, multiverse,...) for availability, or some equivalent. For my Ubuntu 20.04 system, that might be r-cran-tcltk2.

If you do install a "foreign" program, it might not install into the places Ubuntu expects executables and libraries to be installed. The standard way to handle this is to add the locations to your PATH variable for executables and your LD_LIBRARY_PATH for libraries. Then export LD_LIBRARY_PATH, to make it available to subsequent commands. PATH has already been exported. Adding the new location may be at the beginning or the end of the existing environment variables. Adding them at the beginning may override a system program, but maybe that's exactly what you want -- for instance when you want a specific compiler version different from the system supplied one.

PATH=~/anaconda3/bin:${PATH}
export LD_LIBRARY_PATH=~/anaconda3/lib/tcl8.5:${LD_LIBRARY_PATH}
ubfan1
  • 19,049
0

I was breaking my head on the same issue. Apparently I set ~/anaconda3 as my working directory and it worked! Probably because ./lib/tcl8.5/init.tcl is on the path now.

Zanna
  • 72,312
NoName
  • 1
  • 1