## updates of installation bear with macOS (Mojave) [R for BE/BA]

Dear all,

This is to renew my previous post about installation of bear (or my other R packages using RGtk2 package. For Windows OS or Linux users, the previous posts still hold true. Now, the problem occurs with macOS (Mojave). If you upgrade R to current version (v3.6.1), you may need to read this carefully. The key point is the issue of RGtk2 package installation. As default from preinst.r, RGtk2 is installed as type="binary" which is default for install.packages() function. For most of R packages, this should be no problem at all with macOS. Unfortunately, RGtk2 is an exception. So we need to install RGtk2 correctly; otherwise you will get error messages something like    Error in dyn.load(file, DLLpath = DLLpath, ...) :   unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RGtk2/libs/RGtk2.so':   dlopen(/Library/Frameworks/R.framework/Versions/3.6/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.6/Resources/library/RGtk2/libs/RGtk2.so   Reason: image not found
And there will be a popup window to ask if ‘Need GTK+?’ which was a broken link and was unable to install GTK+ (driver). I have tried thousand times and failed to connect. However, if you can get it from it, do not use it. If you try to install RGtk2 from its source with install.packages("RGtk2",type="source"), you will get another error messages "... gtk is not found. gtk 2.8.0 or above is required.' That implies gtk+ installation previously using Homebrew is not recognized by R any more. So the following steps can resolve this problem (tested with bear v2.8.4/R v3.6.1 with macOS (Mojave)).
• go and browse this website and try to install RGtk2 package from its source. In summary, you will need Xcode and Xcode command line tool and MacPorts. Download and install. Go to CRAN mirror to download RGtk2 and cairoDevice source tarballs (*.tar.gz). Put these two tar ball files under your working directory. And open a terminal type     $export PATH=/opt/local/bin:/opt/local/sbin:$PATH $sudo port selfupdate$ sudo port install pkgconfig $sudo port install gtk2 +x11 ### <- this is extremely important.$ R CMD INSTALL RGtk2_x.xx.xx.tar.gz \$ R CMD INSTALL cairoDevice_x.xx.tar.gz

Please note that x.xx.xx is the version # of the package. Make sure they are correct. Then RGtk2 should be able to be installed successfully. If it is your first time to install bear, please run source("preinst.r") under R console. Then download bear (source or binary) from Sourceforge and install it with a terminal and type R CMD INSTALL bear_x.xx.xx.tar.gz or R CMD INSTALL bear_x.xx.xx.tgz where x.xx.xx is the version # again. Interesting to find out that with macOS, these two commands R CMD INSTALL bear_x.xx.xx.tar.gz and sudo R CMD INSTALL bear_x.xx.xx.tar.gz do the same things. They all install the package to the same directory. That is very different from Windows OS and Linux. If we type .libPaths() under R console, there is only one library path. Let me know if I was wrong about this. I will update preinst.r later and make it to install/build RGtk2 package from source only for macOS. I feel that gtk2 installed from Macports is much more stable than the previous one (gtk+) from Homebrew.

All the best,
-- Yung-jin Lee
bear v2.8.7:- created by Hsin-ya Lee & Yung-jin Lee
Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear