Skip to content

Instantly share code, notes, and snippets.

@zhiyzuo
Last active May 17, 2020 12:17
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save zhiyzuo/a489ffdcc5da87f28f8589a55aa206dd to your computer and use it in GitHub Desktop.
A brief note on how to install rattle/RGtk2 on macOS
@bsou
Copy link

bsou commented Jan 30, 2018

@uiang Did you get a solution to your problem?

Seems like I have run into a similar problem.

I'm using Mac OS High Sierra 10.13.2 and have R 3.4.1.

I run into the following issue, after trying to install RGtk2 using the following command

$ R CMD INSTALL ~/Downloads/RGtk2_2.20.34.tar.gz
........

installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2/libs
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded

Error: package or namespace load failed for ‘RGtk2’:
.onLoad failed in loadNamespace() for 'RGtk2', details:
call: .RGtkCall("S_gtk_builder_get_type", PACKAGE = "RGtk2")
error: object has no G type
Error: loading failed
Execution halted
ERROR: loading failed

removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2’


Any pointers on this would be helpful.

@lizpund
Copy link

lizpund commented Feb 1, 2018

@zhiyzuo That seems to have done the trick! Thank you so much.

@mschmidty
Copy link

Thanks for your tutorial. I really appreciate it. I am having the same problem when I try to load RGtk2 from the ~/Downloads folder. Some things I have tried:I checked and I do have gtk+ in my local/cellar folder. I also checked my .bash_profile and it looks like the path is in there. I also tried to load the source file from Xquartz with no luck. I'm not really sure what to do. Here's my error just in case:

* installing to library ‘/Users/mikes/Library/R/3.4/library’
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Users/mikes/Library/R/3.4/library/RGtk2’

Can you elaborate @MindExplore about how you loaded the package in XQuarts. I tried and it still didn't work.

@Yupla
Copy link

Yupla commented Mar 7, 2018

First of all thank you very much for this tutorial. I'm struggling on the launch of rattle just by itself. here is the result I get when I try tu use rattle in rstudio :

library(rattle)
R session is headless; GTK+ not initialized.
Rattle: A free graphical interface for data mining with R.
Version 5.0.14 Copyright (c) 2006-2017 Togaware Pty Ltd.
Type 'rattle()' to shake, rattle, and roll your data.
rattle()

(R:88491): Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init()
Error in rattle() : Can't load RGtk2.
A windowing system can't be accessed?
Maybe you are using a remote terminal (ssh) or RStudio browser connection.
Consider using remote desktop, ssh -X, or X2Go depending on your platform.
Running rattle() locally on a desktop is the default.

Like you told another user here I tried to first load RGtk2 in the xquartz terminal but it does't seem to work. Do you have any idea on this ?

@hrgentry
Copy link

hrgentry commented May 9, 2018

@zhiyzuo, thanks for you efforts in presenting this tutorial. At Step 7, when applying brew install --with-x11 cairo, brew gave "Warning: cairo: this formula has no --with-x11 option so it will be ignored!", how do you enable the --with-x11 option at this step? Thanks!

@jimmerricks
Copy link

@cratzdo The most recent commit to cairo.rb removed the --with-x11 option. I used brew edit cairo to replace the Formula with the one at: https://github.com/Homebrew/homebrew-core/blob/1fea60405bf98c6385dfba18c75a7fb667dc3a40/Formula/cairo.rb.

@chicofish
Copy link

@jamesmnw for(i in 1:1000000){print("THANKS")} That hidden error in the cairo build of ignoring the -x11 flag caused me days of grief. Thanks for pointing that out. Your edit worked perfectly, allowing the rest of the instructions to work. I can now Rattle and RQDA and the world is a better place. :-)

@vincent-yung
Copy link

@milti, follow @jamesmnw's advice and make sure to brew reinstall --with-x11 cairo after editing the cairo formula.

@ScarlettU
Copy link

ScarlettU commented May 27, 2018

Thanks for your detailed advice. But it is still frustrating for me.
After typing "brew install --build-from-source --verbose gtk+" , I received "Error: gtk+ 2.24.32 did not build"
Please help me out. It's too hard for me.

@wabee
Copy link

wabee commented May 29, 2018

The key to success for me was to use @jamesmnw advice and edit the configuration file for cairo using the formula supplied in his post and build. After that gtk+ build without errors. I could then just follow the instructions to install RGtk2 and cairodevice + rattle. To bad they messed up Homebrews version of cairo and caused all these problems

@hughng92
Copy link

hughng92 commented Jun 4, 2018

Hello,
I need help. I am at step 8 with "brew edit gtk+"
When I am done editing the last two lines in df install, I do not know how to save or quit in the terminal.
I did run export EDITOR = vim.
I hope I provided info for troubleshooting.
Thanks a lot.

@aniket-cybrilla
Copy link

aniket-cybrilla commented Jun 12, 2018

What is the solution to the below?

~/Downloads -> R CMD INSTALL RGtk2_2.20.34.tar.gz
During startup - Warning messages:
1: Setting LC_TIME failed, using "C"
2: Setting LC_MESSAGES failed, using "C"
3: Setting LC_MONETARY failed, using "C"
* installing to library ‘/usr/local/lib/R/3.5/site-library’
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/usr/local/lib/R/3.5/site-library/RGtk2’

As directed the version of GTK I manage to install is 2.24.32_2. But for RGtk2 it needs 2.8.0? Could you elaborate on the exact steps to perform to achieve this please?

@yihui
Copy link

yihui commented Jun 14, 2018

As I just pointed out in a comment under @zhiyzuo's post (https://zhiyzuo.github.io/installation-rattle/#comment-3944233914), the whole thing can be simplified to this:

system('brew install gtk+')

local({
  if (Sys.info()[['sysname']] != 'Darwin') return()

  .Platform$pkgType = 'mac.binary.el-capitan'
  unlockBinding('.Platform', baseenv())
  assign('.Platform', .Platform, 'package:base')
  lockBinding('.Platform', baseenv())

  options(
    pkgType = 'both', install.packages.compile.from.source = 'always',
    repos = 'https://macos.rbind.org'
  )
})

install.packages(c('RGtk2', 'cairoDevice', 'rattle'))

No more struggling with editing the gtk+ formula :)

@bison31205
Copy link

thx,it work!

@sharkdeng
Copy link

I am getting this when doing "R CMD INSTALL RGtk2_2.20.33.tar.gz"

configure: error: GTK version 2.8.0 required

I am on MacOS Sierra 10.12.6, R version is 3.4.2
When I did "brew install --build-from-source --verbose gtk+" it installed GTK 2.24.31_1

I encountered same problem. Did you solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment