yjlee168
★★

Kaohsiung, Taiwan,
2019-07-08 10:15

Posting: # 20377
Views: 749

## 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.6:- created by Hsin-ya Lee & Yung-jin Lee Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear Download link (updated) -> here yjlee168 ★★ Kaohsiung, Taiwan, 2019-07-08 10:40 @ yjlee168 Posting: # 20378 Views: 615 ## upgrade R with macOS (Mojave) Dear all, It should be very easy to upgrade R with macOS (Mojave). Since I am not familiar with macOS and I do not have an iMac (just running macOS under VirtualBox), I used to be afraid to do this. So I stayed with R v3.5.1 for a while. But recently, I feel much comfortable now. Here is steps: 1. Delete the previous R with two commands under a terminal:$ rm -rf /Applications/R.app
\$ sudo rm -rf /Library/Frameworks/R.framework
2. Install new R (R-x.x.x.pkg) and re-install gfortan_6.1.pkg (it is required; obtained it from CRAN mirror): Remember to install R first followed by gfortran_6.1.pkg. This is because gfortran will install some fortran/C/C++ header files into /R.framework; so we have to do it again;
3. Re-install RGtk2 and cairoDevice package as previous post;
4. Re-run source(“preinst.r”) under R console;
5. Re-install bear package.
That's it.

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

Kaohsiung, Taiwan,
2019-07-08 11:14

@ yjlee168
Posting: # 20379
Views: 606

## an old itch when running RGtk2 (GUI) with macOS

Dear all,

This has been an old problem and I used to leave it as it was. The problem is when we try to retrieve a input data file with gfile() function from RGtk2, I usually get the error message as follows:(R:351): Gtk-WARNING **: 10:28:58.039: Attempting to read the recently used resources file at /Users/username/.local/share/recently-used.xbel', but the parser failed: Failed to open file “/Users/username/.local/share/recently-used.xbel”: Permission denied.  where username is your login name, of course. It does not matter at all because the package still can read the input file correctly. However, it just make me itch for a long time. Recently, I solve the puzzle.

It can be easily fixed with a terminal and type
   mkdir /Users/username/.local /Users/username/.local/share.

   sudo mkdir /Users/username/.local /Users/username/.local/share

unless you run R with sudo R every time; otherwise you still get "... Permission denied". When I asked Google master several years ago, some nice people always suggested that we should use sudo mkdir /Users/username/.local /Users/username/.local/share to fix this problem. However, I still got ".... Permissions denied." That's because I did not use sudo R, instead of just R to run R. If you get this error messages, just fix it and do not let itch keeps bothering you. And this only occurs with macOS.

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

Kaohsiung, Taiwan,
2019-08-11 20:29
(edited by yjlee168 on 2019-08-12 13:22)

@ yjlee168
Posting: # 20493
Views: 238

## upgrade/re-install cairoDevice package from source (macOS)

Dear all,

I found the package cairoDevice was upgraded again. As default, it is installed using the binary (*.tgz) from CRAN. Then it will incur errors when using together with RGtk2 for macOS users. So please install or upgrade the package cairoDeivce from source, if running bear. Type install.packages("cairoDevice",type="source") in the terminal. It will fix the errors. Do the same thing for the package RGtk2 (install.packages("RGtk2",type="source")`) upgrade later.

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