Friday, December 12, 2014

Installing RMySQL on OS X "Yosemite"

Here are the instructions to install RMySQL on OS X "Yosemite":

  1. Download and install the MySQL community server for OS X. You will need a free Oracle account to complete the download. At the time of this blog post, I installed mysql-5.6.22-osx10.9-x86_64 via the DMG archive. By default MySQL will be installed in /usr/local/mysql-5.6.22-osx10.8-x86_64 (if you use a different version, look for an equivalently named directory under /usr/local).
  2. Download sources for the RMySQL package from CRAN. At the time of this blog post, I downloaded RMySQL_0.9-3.tar.gz.
  3. Open a Terminal window and run:
    export DYLD_LIBRARY_PATH=/usr/local/mysql-5.6.22-osx10.8-x86_64/lib:$DYLD_LIBRARY_PATH
    You may want to consider adding this line to .bashrc as well.
  4. In the same terminal window compile and install RMySQL using this command (in a single line):
    R CMD INSTALL --configure-args="--with-mysql-dir=/usr/local/mysql-5.6.22-osx10.8-x86_64 --with-mysql-inc=/usr/local/mysql-5.6.22-osx10.8-x86_64/include --with-mysql-lib=/usr/local/mysql-5.6.22-osx10.8-x86_64/lib" RMySQL_0.9-3.tar.gz
    If you installed a different version of MySQL or downloaded a different version of RMySQL, fix the command to reflect the correct directory names.
That should be it. RMySQL will build and, if everything went well, finish up with these messages:
** testing if installed package can be loaded
From the terminal window launch R as usual.

If you are using RStudio, and simply launch it from Spotlight or your Applications folder, and try to use RMySQL, you may see this error:
> library(RMySQL)
Loading required package: DBI
Error : .onLoad failed in loadNamespace() for 'RMySQL', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RMySQL/libs/':
  dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RMySQL/libs/, 6): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/RMySQL/libs/
  Reason: image not found
Error: package or namespace load failed for ‘RMySQL’
This is because the DYLD_LIBRARY_PATH environment variable is only set in Terminal windows. You have two options to use RStudio:

  1. Open a Terminal window and run
    export DYLD_LIBRARY_PATH=/usr/local/mysql-5.6.22-osx10.8-x86_64/lib:$DYLD_LIBRARY_PATH
    /Applications/ &
  2. As root, add the "export ..." line to /etc/launchd.conf and restart your computer. This should make the DYLD_LIBRARY_PATH setting global and allow you to launch RStudio from Spotlight or your Applications folder.

Friday, August 29, 2014

Installing JDK 7 on Mac OS X Yosemite 10.10 developer previews

Oracle's JDK 7 installer for the Mac somehow thinks that OS X Yosemite's 10.10 version number is an unsupported version. There's a simple trick to fool the installer by giving it a version number that it expects. Open a Terminal window and edit the file /System/Library/CoreServices/SystemVersion.plist as root/Administrator. If you are familiar with vi, simply run sudo vi /System/Library/CoreServices/SystemVersion.plist. The file should look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
     <string>1983-2014 Apple Inc.</string>
     <string>Mac OS X</string>

Edit the ProductVersion to read 10.9 and save the file. Now download the JDK 7 installer and run it. It should no longer complain about the OS X version. Be sure to restore the ProductVersion to 10.10 once the installer completes.

Sunday, May 25, 2014

Troubleshooting a Valentine One hardwire installation

About 10 years ago, I hardwired the Valentine One (V1) radar detector into my car. The setup involved tapping into the power supply behind the radio and wiring from the radio over to the driver's side, up the A pillar and along the top of the windshield, to the rear view mirror, with the V1 sitting on top of the mirror using suction cups. Over time, the suction cups would occasionally lose grip and leave the V1 dangling off the connecting wire. Recently, the stresses resulted in the wire snapping and I had to replace the wire.

What should have been a straightforward affair turned out to be a multi-hour ordeal. The V1 requires simple telephone wire with RJ11 connectors for wiring. A simple four conductor wire does the trick. My first purchase of a four conductor wire didn't work. Being misled by forum posts, I get a six conductor and eight conductor wire, but neither worked. After some logically checking of voltages and resistance, with my friend's help, I was able to figure out that the problem was with the fuse in my hardwire setup. After replacing the fuse and using a regular four conductor setup, I was able to get the wiring going again.

In short, here are the parts required: