Uninstalling R
First, my configuration:
Mac OS X Lion 10.7.5
R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
R.app GUI 1.62 (6558) x86_64-apple-darwin10.8.0
gtk2 @2.24.21_0+x11
If you are here is because you get problems installing R, GTK+ and rattle on OS X Lion, so, may be useful for you to know how to clean your messed installation before trying again:
R for OS X consists of two parts: the GUI (R.app) and the R framework.
The typical installation will install the GUI in folder:
/Applications/R.app
and the R framework in:
/Library/Frameworks/R.framework
Move to trash the R icon on Applications folder and using a Terminal, run (prepend sudo
if needed, commands that you type are in bold):
$ sudo rm -rf /Library/Frameworks/R.framework $ sudo rm -rf /usr/bin/R $ sudo rm -rf /usr/bin/Rscript
Cleaning R packages
The installation of R consists of three Apple packages, you can list them with the following command:$ pkgutil --pkgs | grep org.r-This will give the following output:
org.r-project.libs.darwin9.gtk.pkg org.r-project.R.x86_64.fw.pkg org.r-project.R.x86_64.GUI.pkg org.r-project.x86_64.tcltk.x11
The first one in bold, will be present only if you installed the GTK+ library (may be darwin10), and the others may or may not be all present depending on your installation.
If you want to know which files made the R GUI package for example, you can use:
$ pkgutil --files org.r-project.R.x86_64.GUI.pkg
As we already deleted the R.app and R.framework files, we need to tell the system to forget about this packages. To issue this command, you need administration priviledges, so need the sudo before the command as in the example (use your admin password when asked for):
$ sudo pkgutil --forget org.r-project.R.x86_64.GUI.pkg $ sudo pkgutil --forget org.r-project.R.x86_64.fw.pkg
Sample output:
$ sudo pkgutil --forget org.r-project.R.x86_64.GUI.pkg Password: Forgot package 'org.r-project.R.x86_64.GUI.pkg' on '/'. $ $ sudo pkgutil --forget org.r-project.R.x86_64.fw.pkg Forgot package 'org.r-project.R.x86_64.fw.pkg' on '/'.
Uninstalling the Tcl/Tk component (which is installed under /usr/local) is not simple and not necessary.
Uninstalling GTK+
Uninstalling GTK+ is simple, just issue the following commands:
$ sudo rm -rf /Library/Frameworks/GTK+.framework $ sudo pkgutil --forget org.r-project.libs.darwin9.gtk.pkg
Depending on your GTK+ mess, you may have also have to do a:
$ sudo pkgutil --forget org.r-project.libs.darwin10.gtk.pkg
Check if your PATH is including a reference to "/Library/Frameworks/GTK+.framework/Resources/bin" , you need to clean it:
$ echo $PATH /Library/Frameworks/GTK+.framework/Resources/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin $ $ export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
Installing GTK+, R and rattle
Don't ask me why this works, I don't know, but it works. I start from a clean environment like after doing the previous uninstalling procedure.1 - Install MacPorts following the site instructions. I already had Xcode installed, but if you succeed following the installation instructions of MacPorts, you will end at the same point as me.
2 - Open a terminal and install GTK+ with the following commands:
$ sudo port selfupdate $ sudo port install gtk2 +x11
After the installation, verify if your PATH includes "/opt/local/bin:/opt/local/sbin" on it:
$ echo $PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin $
3 - Install the R package from CRAN (3.0.2 by this time) as usual, you do not need to start the R GUI, we will use the R COMMAND on the same terminal already opened to install the GTK macport. Run the following commands on the terminal:
4 - Download from CRAN Packages the cairoDevice, and the RGtk2. Put the files on your home directory. Expand the files.
5 - On the shell terminal (not the R terminal), run the following commands (I included sample output...):
$ cd ~ $ R CMD INSTALL cairoDevice WARNING: ignoring environment value of R_HOME * installing to library ‘/Library/Frameworks/R.framework/Versions/3.0/Resources/library’ * installing *source* package ‘cairoDevice’ ... ** package ‘cairoDevice’ successfully unpacked and MD5 sums checked checking for pkg-config... pkg-config configure: creating ./config.status config.status: creating src/Makevars ** libs llvm-gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -D_REENTRANT -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/opt/local/includ ..... work -Wl,CoreFoundation installing to /Library/Frameworks/R.framework/Versions/3.0/Resources/library/cairoDevice/libs ** R ** demo ** preparing package for lazy loading ** help *** installing help indices ** building package indices ** testing if installed package can be loaded * DONE (cairoDevice) $ $ R CMD INSTALL RGtk2 WARNING: ignoring environment value of R_HOME * installing to library ‘/Library/Frameworks/R.framework/Versions/3.0/Resources/library’ * installing *source* package ‘RGtk2’ ... ** package ‘RGtk2’ successfully unpacked and MD5 sums checked checking for pkg-config... /opt/local/bin/pkg-config ..... ...... installing to /Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2/libs ** R ** demo ** inst ** preparing package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded * DONE (RGtk2) $
6 - Open R. On the "Packages & Data" menu, select the "Package Installer" option, click on "Get List" button and search for the rattle package and install it (with dependencies check box selected), then load it with the "Package Manager".
7 - On the R console, type:
> rattle()
VoilĂ !! Must appear the rattle interface and no errors on the R console.
Useful links:
Subject: Re: GTK+ libraries can't be found - msg#00007
R 3.0 and GTK+/RGTK2 error
Mountain Lion Installation Issue (R 2.15.1, Rattle 2.6.21)
Mac install problem
Rattle: Installation Troubleshooting
Error in as.GType(type) : Cannot convert RGtkBuilder to GType
Errors that I get looking for a solution
This procedure solves the following errors which I also had in previous tentatives.
I list them here just to help indexing the problem, but errors do not appear following the described procedure.
In one tentative, I get the following error:
> rattle() Error: attempt to apply non-function In addition: Warning message: In method(obj, ...) : Unknown internal child: selection
It seems that this solves it (from the R console).
> library(rattle) > crv$rattleUI <- "rattle_macosx.ui" > rattle()
Errors from other tentatives:
> install.packages("RGtk2",type="source") trying URL 'http://cran.fiocruz.br/src/contrib/RGtk2_2.20.25.tar.gz' Content type 'application/x-gzip' length 2784794 bytes (2.7 Mb) opened URL ================================================== downloaded 2.7 Mb WARNING: ignoring environment value of R_HOME * installing *source* package ‘RGtk2’ ... ** package ‘RGtk2’ successfully unpacked and MD5 sums checked checking for pkg-config... no checking for INTROSPECTION... no checking for GTK... no configure: error: GTK version 2.8.0 required ERROR: configuration failed for package ‘RGtk2’ * removing ‘/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2’ * restoring previous ‘/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2’
The downloaded source packages are in ‘/private/var/folders/_k/8n3y613n1033f1t3bnh565040000gn/T/RtmpGueqOp/downloaded_packages’ Warning messages: 1: '.find.package' is deprecated. Use 'find.package' instead. See help("Deprecated") 2: In install.packages("RGtk2", type = "source") : installation of package ‘RGtk2’ had non-zero exit status
Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2/libs/RGtk2.so': dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2/libs/RGtk2.so, 6): Library not loaded: /Library/Frameworks/GTK+.framework/Versions/2.24.X11/Resources/lib/libgtk-x11-2.0.0.dylib Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2/libs/RGtk2.so Reason: image not found trying URL 'http://r.research.att.com/libs/GTK_2.18.5-X11.pkg' Content type 'text/plain' length 59914166 bytes (57.1 Mb) opened URL ================================================= downloaded 57.1 Mb Learn more about GTK+ at http://www.gtk.org If the package still does not load, please ensure that GTK+ is installed and that it is on your PATH environment variable IN ANY CASE, RESTART R BEFORE TRYING TO LOAD THE PACKAGE AGAIN Error in as.GType(type) : Cannot convert RGtkBuilder to GType In addition: Warning message: Failed to load RGtk2 dynamic library, attempting to install it.
> rattle() Then, notice the following errors in the R console after the rattle GUI opens: Oct 21 13:50:52 Rays-MacBook-Pro.local R[444]: CGContextSetFont: invalid context 0x0 Oct 21 13:50:52 Rays-MacBook-Pro.local R[444] : CGContextSetFontSize: invalid context 0x0 Oct 21 13:50:52 Rays-MacBook-Pro.local R[444] : CGContextSetTextMatrix: invalid context 0x0 ...
No comments:
New comments are not allowed.