MacOS – How to troubleshoot R and tk on macOS

homebrewmacosopen sourcex11

I am getting warnings and empty popup boxes when compiling and loading R packages that depend on tk. They say that tk was not installed correctly.

I am using homebrew, but I can't tell which package might provide a correct install of tk, or if it would conflict with the existing (but broken) installation.

What is the recommended way to install enough of tk on OSX so that an R package with tk as a dependency (e.g. RNCEP) R will compile without giving this warning?

Update

Here is the warning that I get when trying to load an R package that depends on tk.tcl:

Warning message:
In fun(libname, pkgname) :
  Can't find a usable tk.tcl in the following directories: 
    /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/tk8.5

/System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/tk8.5/Resources/Scripts
/System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/tk8.5
/System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/tk8.5/Resources/Scripts
./lib/tk8.5 ./lib/tk8.5/Resources/Scripts ~/Library/Tcl/tk8.5
~/Library/Tcl/tk8.5/Resources/Scripts /Library/Tcl/tk8.5
/Library/Tcl/tk8.5/Resources/Scripts /System/Library/Tcl/tk8.5
/System/Library/Tcl/tk8.5/Resources/Scripts
/System/Library/Tcl/8.5/tk8.5
/System/Library/Tcl/8.5/tk8.5/Resources/Scripts
~/Library/Frameworks/tk8.5
~/Library/Frameworks/tk8.5/Resources/Scripts /Library/Frameworks/tk8.5
/Library/Frameworks/tk8.5/Resources/Scripts
/System/Library/Frameworks/tk8.5
/System/Library/Frameworks/tk8.5/Resources/Scripts ./library

Best Answer

Try installing tk from the ActiveState ActiveTcl binaries. If you're on Mavericks, make sure that you install ActiveTcl 8.5.15.0 or greater, as there are some problems with earlier versions on Mavericks. Also, please note that ActiveTcl is not open-source software.