Skip to content

[R-pkg-devel] How to fix Tcl/Tk Error on Mac OS build

5 messages · Dominic Comtois, Dirk Eddelbuettel, Tomas Kalibera +2 more

#
I was asked by CRAN to fix some problems appearing in my summarytools
<https://cran.r-project.org/web/checks/check_results_summarytools.html>'
package build checks. Trivial email problems aside, on the summary page
<https://www.r-project.org/nosvn/R.check/r-release-macos-arm64/summarytools-00check.html>
for the Mac OS build, I see:

[...]
checking whether package ?summarytools? can be installed ... [1s/1s] ERROR
Installation failed.
See
?/Volumes/Builds/packages/big-sur-arm64/results/4.2/summarytools.Rcheck/00install.out?
for details.
[...]

On the details page
<https://www.r-project.org/nosvn/R.check/r-release-macos-arm64/summarytools-00install.html>,
I see:

[...]
** byte-compile and prepare package for lazy loadingtcltk DLL is
linked to '/opt/R/arm64/lib/libtk8.6.dylib'
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
  call: fun(libname, pkgname)
  error: Tcl/Tk libraries are missing: install the Tcl/Tk component
from the R installerExecution halted
ERROR: lazy loading failed for package ?summarytools?
[...]

Tcl/Tk is used by some functions to allow users to bring up an "open
file...", & "save file..." dialogs & message boxes, as well as the
tclvalue() function. In my NAMESPACE, I have:

importFrom(tcltk,tclvalue)
importFrom(tcltk,tk_messageBox)
importFrom(tcltk,tkgetOpenFile)
importFrom(tcltk,tkgetSaveFile)

Also, a prerequisite is to have XQuartz <https://www.xquartz.org/>
installed on Mac OS.

Summarytools has been around for a while, and I never had this problem
before. And since I don't have a Mac machine, I'm not sure how to go about
this. A Google search reveals that several other packages have the same
issue. But I wasn't able to find the root cause nor a proper solution. Any
tips / pointers would be greatly appreciated.

Thanks,

Dominic Comtois
summarytools
<https://cran.r-project.org/web/packages/summarytools/index.html> author &
maintainer
#
Dominic,
On 25 April 2022 at 22:45, Dominic Comtois wrote:
| ** byte-compile and prepare package for lazy loadingtcltk DLL is
| linked to '/opt/R/arm64/lib/libtk8.6.dylib'
| Error: .onLoad failed in loadNamespace() for 'tcltk', details:
|   call: fun(libname, pkgname)
|   error: Tcl/Tk libraries are missing: install the Tcl/Tk component
| from the R installerExecution halted
| ERROR: lazy loading failed for package ?summarytools?
| [...]

Doesn't this simply demonstrate that tcltk is missing on that platform?
Which is not your fault, or under your control.

There is no simple or singular way for us to communicate such setup issues to
CRAn so you could try to email the maintainer of that port here or privately.

Dirk
#
On 4/26/22 13:38, Dirk Eddelbuettel wrote:
Yes, as can be seen by looking at other packages using tcltk (e.g. 
tcltk2 or tkrplot).
You can find the name and address of the maintainer here

https://cran.r-project.org/web/packages/external_libs.html

(linked from the CRAN Repository Policy, 
https://cran.r-project.org/web/packages/policies.html)

and report, but that is probably no longer necessary as Simon is reading 
this list as well.

Best
Tomas
#
Apologies if these items are know to be common knowledge. I have no experience with package development that uses TcL/Tk. My sketchy knowledge comes only from seeing it mentioned on the Mac-specific pages and on R-Mac-SIG mailing list.
 
This appears possibly the most on point since arm build is mentioned in the error log:
On 2021-09-18 2:20 a.m., Prof Brian Ripley wrote:
-----

The R for MacOS page says:
-----------

R-4.2.0.pkg (notarized and signed)
SHA1-hash: 2a90fb8629e44f72f9d89d6a9bac9b71564587d7
(ca. 90MB) for Intel Macs	

R 4.2.0 binary for macOS 10.13 (High Sierra) and higher, Intel 64-bit build, signed and notarized package.
Contains R 4.2.0 framework, R.app GUI 1.78 in 64-bit for Intel Macs, Tcl/Tk 8.6.6 X11 libraries and Texinfo 6.7. The latter two components are optional and can be ommitted when choosing "custom install", they are only needed if you want to use the tcltk R package or build package documentation from sources.
---------------

And there is further information at the Mac R Tools page: https://cran.r-project.org/bin/macosx/tools/

------------------
-------------------
And there is discussion about how to avoid unnecessary efforts to load TkTcl in the R-Mac-SIG list

https://markmail.org/search/?q=list%3Aorg.r-project.r-help+tcl+tk+package#query:list%3Aorg.r-project.r-help%20tcl%20tk%20package%20order%3Adate-backward+page:1+mid:s4zpfqw6t3vbr4z6+state:results

--------------

HTH;
David.
--------------
#
Thanks, indeed, as part of full re-install for R 4.2.0 package builds the Tcl/Tk libraries were missing. Now fixed and summarytools check with

* checking data for non-ASCII characters ... NOTE
  Note: found 78 marked UTF-8 strings
Status: 1 NOTE

I'll just repeat the important link that Tomas posted: https://cran.r-project.org/web/packages/external_libs.html

On a slightly orthogonal note (not related to the question other than it involves tcltk): I'd like to point out that Tcl/Tk is often not available on computing servers, so I would recommend packages that do not provide GUI tools to avoid dependence on tcltk if not strictly necessary as it prevents the use in headless HPC environments.

Cheers,
Simon