davidcsterratt/retistruct

Running Retistruct GUI in MacOS X Mavericks and Yosemite

davidcsterratt opened this issue · 2 comments

On MaxOS X Mavericks and Yosemite, Retistruct installs OK, and demo("retistruct.method") works, but it fails when running the package with the command retistruct(), with the error output:

> retistruct()
Loading required package: gWidgetsRGtk2
Trying to install required package gWidgetsRGtk2

   package ?gWidgetsRGtk2? is available as a source package but not as a binary

Warning in install.packages :
  package ?gWidgetsRGtk2? is not available (for R version 3.1.2)
Loading required package: gWidgetsRGtk2
Error in require.package(paste0("gWidgets", guiToolkit)) : 
  Could not install gWidgetsRGtk2
In addition: Warning messages:
1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return
= TRUE,  :
  there is no package called ?gWidgetsRGtk2?
2: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return
= TRUE,  :
  there is no package called ?gWidgetsRGtk2?
> I am trying to run it from RStudio using the latest version of R (2.1.2) under
> Mac OS X Yosemite. I have re-installed the latest version of X11.

The problem is that retistruct depends on the gWidgetsRGtk2 package, which in turn depends on the RGtk2 package, and unfortunately this package is hard to install on Mavericks (Mac OS X
10.9), and probably also hard to install on Yosemite. There are a number of possibilities, none of which I've tried myself as I don't have a Mac.

0. Use GTK binaries

Chris von Csefalvay's method appears to be the most straightforward way of installing RGtk2. Ignore the references to rattle, another package that depends on RGtk2.

1. Use macports

Try installing RGtk2 using the "Step by step solution" here, which uses macports:
http://marcoghislanzoni.com/blog/2014/08/29/solved-installing-rattle-r-3-1-mac-os-x-10-9/
In a comment some way down the page, the author says the instructions should work for Yosemite, but there's no guarantee. Once you've installed RGTK2, you will (I think) have to install gWidgetsRGTK2 manually from within RStudio (or R):

      install.packages("gWidgetsRGTK2", type="source")

Then retistruct should work.

2. Use Homebrew

Thanks to @bcohn12 for suggesting this. In a terminal copy and paste:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install gtk+
export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig:$PKG_CONFIG_PATH  
R
> install.packages(c("cairoDevice", "RGTk2"), type="source") 

However, I'm guessing that you may need to install XCode and XQuartz manually beforehand, if they are not already installed.

3. Run R in (docker)[http://www.docker.com]

Thanks to @sje30 for suggesting trying to run R in docker, as discussed here: rocker-org/rocker#110

brew install socat
brew cask install xquartz # SJE didn't need this step. 
open -a XQuartz 

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" 

# in another window
docker run -e DISPLAY=192.168.59.3:0 -ti --rm r-base
install.packages("retistruct")
retistruct()
sje30 commented

hi @davidcsterratt, I just ran across these comments, which may well be similar to route 1.
http://chrisvoncsefalvay.com/2015/02/08/installing-gtk-on-mavericks.html

Thanks for the pointer @sje30 - I've added this as method 0, as it appears to be the most straightforward.