R installs on High-Sierra without tcl-tk support?

(Rainer M Krug) #1


it seems, that R installs (bottled as well as compiled) without tcltk support, i.e.

> capabilities()[["tcltk"]]

while this returns TRUE in 3.4.1_2

How can I get tcltk support in R under High-Sierra?



(Rolf Marvin Bøe Lindgren) #2

I’m at a loss – have tried lots of ways.

It might be an XQuartz issue – if I edit r.rb so as to force ./configure to find the tkConfig.sh and tclConfig.sh where brew installs them, brew attemts to compile xorg from linuxbrew.

(Rainer M Krug) #3

Hm. Are you on linux or Mac? Sounds like Linux? I am on Mac.

I have added the following options to the args section



I get the following error:
Last 15 lines from /Users/rainerkrug/Library/Logs/Homebrew/r/02.make:

include <X11/Xlib.h>


1 error generated.
make[4]: *** [tcltk.d] Error 1
make[4]: *** Waiting for unfinished jobs…
In file included from tcltk.c:668:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/tk.h:78:11: fatal error: ‘X11/Xlib.h’ file not found

include <>


1 error generated.
make[4]: *** [tcltk.o] Error 1
make[3]: *** [all] Error 1
make[2]: *** [R] Error 1
make[1]: *** [R] Error 1
make: *** [R] Error 1

Which also hints at a problem with x11 (or quartz as on Mac)

(Rolf Marvin Bøe Lindgren) #4


I’m on Mac as well, Homebrew seems to act as if I’m on Linux.

(Mike McQuaid) #5

This is no longer supported, sorry. You would need to create your own formula.

(Rainer M Krug) #6

Thanks for the info. What is the reasoning in this? Problems in dependencies? tcltk support is quite important form many packages in R. But if there are principal problems, it does n to make any sense to follow this up.

(Mike McQuaid) #7

We removed a bunch of options when importing from Homebrew/science because options are error-prone and prevent binary package usage. We could not enable it by default because it required (if I remember correctly) X11 which isn’t installed by default on macOS and needs Homebrew Cask or similar to install.

(Jonathan Chang) #8

If you need Tk support in R on macOS I recommend installing it through cask: brew cask install r-app

As a bonus R packages from CRAN can use the binary packages instead of having everything built from source.

(Rainer M Krug) #9

I would like to avoid r-app, as it requires frameworks, which result in mixed installations which can cause huge problems.

(Rainer M Krug) #10

@MikeMcQuaid Thanks - I will look at the last version of the R recipe in the science tap and put it into my own tap.

(Seth Fore) #11

For any still interested in this…

I’ve gotten the same errors using a brewed copy of tcl-tk after modifying the r.rb formula args section as indicated in your post. The solution, in my case, was to point the --with-tcl-config and --with-tk-config arguments to the system tcltk frameworks:


While those formula edits are pretty straight-forward and have worked for me in the past, after a recent Mac OS update I found I could no longer brew r with tcltk support. Upon inspection the tcltk config files were no longer present where they were expected. It turned out that the update removed my Command Line Tools and, unbeknownst to me (perhaps obvious to other who know more about this stuff than I do), the tclConfig.sh and tkConfig.sh files are only present when CLT is installed. After reinstalling CLT the formula installed as usual with tcl-tk support.

(Rainer M Krug) #12


Is there a chance, that you could share this in a user tap and post the address here?

(Seth Fore) #13

Sure. FYI, there are various other R capabilities for which I’ve added formula dependencies (e.g., lines 26-31). All of my edits are prefaced by comment # SRF - This is a formula edit .... All of my modifications aside from those that directly relate to tcl-tk capabilities have been commented out. You do need to have X11/XQuartz installed since tk.h includes some X11 headers. Additional R capabilities can be by compiled by editing the formula and commenting/uncommenting the appropriate lines provided the necessary downstream dependencies are available (e.g., Tex, …).

The modified r formula is available on github:

  • https://github.com/sethrfore/homebrew-r-srf.git

or can be directly tapped/installed via homebrew:

  • brew install -s sethrfore/homebrew-r-srf/r

While this works for me, I have comparatively limited experience with all of this stuff so use it for what it’s worth. If it errors out, post the details.

(Auklet) #14

The current homebrew R version without tcl-tk, without X11, ending up without png or jpeg device support is severely crippled and breaks a lot of my existing code. Thank you for sharing your formula, Seth! Downloaded it from github, still trying to figure out how to run it. Unfortunately, direct installation of formula did not work for me (No available formula with the name “sethrfore/r-srf/r.rb” ). In short, this is a plea to reconsider the decision to cut tcl-tk from the default homebrew R formula. Tcl-tk is part of the standard R environment. If I’d only want to aqua device, I’d simply use the r-app, as suggested. Thank you for making R available on homebrew and thank you for the consideration

(Mike McQuaid) #15

macOS comes without X11 so we don’t build X11 support. If it can build against Tcl/tk without adding an X11 dependency: please create a pull request to the R formula. We don’t intentionally disable it.

(Seth Fore) #16

The formula has been updated and remains available at https://github.com/sethrfore/homebrew-r-srf.git. After updating your tap, run:

  • brew info sethrfore/r-srf/r

This should show you the available build options. To install tapped formula, run:

  • brew install sethrfore/r-srf/r

with any build options appended.

(Seth Fore) #17

Building without X11 would require editing the tk.h header file in the base r tcltk package as noted in the R Installation and Administration documentation (https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Tcl_002fTk). While other workarounds may well be more appropriate and elegant, they likely surpass my limited developer skillset. From a philosophical perspective, I certainly understand the rational for limiting formula dependencies to those supported on macOS.

(Sander W Van Der Laan) #18

These postings seem relevant for my issue, which I describe here as well.

So, am I to understand @srfore, that I should perhaps try the following?

  • re-install Command Line Tools
  • do brew cask uninstall xquartz && brew uninstall r
  • reboot
  • do brew install tcl-tk
  • re-install XQuartz using brew cask install xquartz
  • re-install ‘your’ version of R using brew install -s sethrfore/homebrew-r-srf/r

Thanks and best,


(Sander W Van Der Laan) #19


I proceeded with the above ‘protocol’. And I have written a post on my website on this matter.

These discussions were just the thing I needed, providing the clues to the solution. Thank you!



(Seth Fore) #20

If things are working, great. However, after looking at your install method and blog post, there is a clarification or two I should make. Foremost, the formula relies on the macOS system tcl-tk framework (formula lines 65-66)

so there is no need to brew tcl-tk or edit your bash_profile or PATH variable. As an aside, brew install ... scrubs your PATH variable so your brewed tcl-tk package would remain unaccessible unless you include the --env=std install argument anyway.

If for some reason you wanted to use a brewed tcl-tk framework, you’d have to further edit the r.rb formula and likely the tcl-tk.rb formula as well since tk is compiled using --without-x (tcl-tk formula line 71) and possibly others.

So long as xQuartz and CLT are installed and operational, you should not have to reinstall them.

After completing an R installation, running capabilities() in an R session will tell you what tools you actually have access to including tcl-tk. In order to make sure tcl-tk works, run a simple test script. Regardless, if everything is working as it should, great.