Mac: Failed to build gem native extension

When installing ruby on rails, vagrant, rmagick, sqlite3-ruby, mysql or any other software using ruby native extensions, you might get the following error message:

$ sudo gem install xxxxxx
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing xxxxxx:
	ERROR: Failed to build gem native extension.

I got this error because I was on a new Mac and didn’t have XCode installed on this machine (using another one for Mac development). And since it’s over 1 GB of disk space I’d need for Xcode, I wanted to avoid having to install it just to get this other stuff installed. The alternative are the “command line tools”. So I went to http://developer.apple.com/downloads/, logged in with my Apple ID, downloaded the latest version of the “Command Line Tools (OS X Mountain Lion) for Xcode” and installed them.

But even with the command line tools install, I was still getting the following error message (which was also there before installing the tools):

Configuring libffi for i386
configure: WARNING: if you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used
configure: error: in `/Library/Ruby/Gems/1.8/gems/ffi-1.8.1/ext/ffi_c/libffi-i386':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[1]: *** No targets specified and no makefile found.  Stop.
make: *** ["/Library/Ruby/Gems/1.8/gems/ffi-1.8.1/ext/ffi_c"/libffi-i386/.libs/libffi_convenience.a] Error 2

Then I had a look at config.log, located there (you might have a different path, when using a newer version):

/Library/Ruby/Gems/1.8/gems/ffi-1.8.1/ext/ffi_c/libffi-i386/config.log

And foung the following error:

xcode-select: Error: No Xcode is selected. Use xcode-select -switch , or see the xcode-select manpage (man xcode-select) for further information.

The solution is to use xcode-select but it took me a few tries to find out what I was supposed to use as path without Xcode installed:

sudo xcode-select -switch /usr/lib/

This error was gone but I got a few error messages like this:

xcrun: Error: failed to exec real xcrun. (No such file or directory)

Looking at the man pages:

xcrun provides a means to locate or invoke coexistence- and platform-aware developer tools from the command-line, without requiring users to modify makefiles or otherwise take inconvenient measures to support multiple Xcode tool chains.

Well, it didn’t really help me much…

The command causing looked like this:

xcrun cc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -I/Library/Frameworks/Mono.framework/Versions/2.10.11/lib/libffi-3.0.11/include    -c MappedType.c

So xcrun just gets a command line as parameters. So first I checked that cc was working:

$ cc --version
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix

Then since just calling cc was working, I was wondering why I’d need xcrun… Maybe the solution is just to create my own xcrun just executing the command line provided as parameters.

First I made a back up of xcrun, then created a shell script there:

sudo mv /usr/bin/xcrun /usr/bin/xcrun.sav
sudo vi /usr/bin/xcrun

Now in vi, I’ve put the following contents in xcrun:

#!/bin/bash
$@

It just execute the same command line but without the first xcrun. Of course, you need to give it execute rights:

sudo chmod +x /usr/bin/xcrun

And then executing gem install finally worked ! I guess there is probably a cleaner way to do it but at least I got it working even though it was late at night and I was almost sleeping on the keyboard !

Update: The trick with xcrun might cause problems installing some other software e.g. osxfuse. So you might have to remove it afterwards:

sudo mv /usr/bin/xcrun /usr/bin/xcrun.sav2
sudo mv /usr/bin/xcrun.sav /usr/bin/xcrun

If you need it again, you can restore it like this:

sudo mv /usr/bin/xcrun /usr/bin/xcrun.sav
sudo mv /usr/bin/xcrun.sav2 /usr/bin/xcrun

PHPUnit on Mac OS X: install failed

You might get the following error while installing PHPUnit on a Mac:

$ pear install pear.phpunit.de/PHPUnit
Attempting to discover channel "pear.phpunit.de"...
downloading channel.xml ...
Starting to download channel.xml (804 bytes)
....done: 804 bytes
Auto-discovered channel "pear.phpunit.de", alias "pear.phpunit.de", adding to registry
unknown channel "pear.phpunit.de" in "pear.phpunit.de/PHPUnit"
invalid package name/package file "pear.phpunit.de/PHPUnit"
install failed

This basically means that just like me, you either do not read manuals or just copy & paste from the manual without reading the parts between code/commands. What you should have read is:

commands (which you may have to run as root)

Yes, it’s that simple, just use sudo:

$ sudo pear install pear.phpunit.de/PHPUnit
Attempting to discover channel "pear.phpunit.de"...
downloading channel.xml ...
Starting to download channel.xml (804 bytes)
....done: 804 bytes
Auto-discovered channel "pear.phpunit.de", alias "phpunit", adding to registry
Attempting to discover channel "pear.symfony.com"...
downloading channel.xml ...
Starting to download channel.xml (811 bytes)
...done: 811 bytes
Auto-discovered channel "pear.symfony.com", alias "symfony2", adding to registry
Did not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically
phpunit/PHPUnit can optionally use package "phpunit/PHP_Invoker" (version >= 1.1.0, version <= 1.1.99)
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
downloading PHPUnit-3.7.21.tgz ...
Starting to download PHPUnit-3.7.21.tgz (118,818 bytes)
...done: 118,818 bytes
downloading File_Iterator-1.3.3.tgz ...
Starting to download File_Iterator-1.3.3.tgz (5,152 bytes)
...done: 5,152 bytes
downloading Text_Template-1.1.4.tgz ...
Starting to download Text_Template-1.1.4.tgz (3,701 bytes)
...done: 3,701 bytes
downloading PHP_CodeCoverage-1.2.11.tgz ...
Starting to download PHP_CodeCoverage-1.2.11.tgz (159,849 bytes)
...done: 159,849 bytes
downloading PHP_Timer-1.0.4.tgz ...
Starting to download PHP_Timer-1.0.4.tgz (3,694 bytes)
...done: 3,694 bytes
downloading PHPUnit_MockObject-1.2.3.tgz ...
Starting to download PHPUnit_MockObject-1.2.3.tgz (20,390 bytes)
...done: 20,390 bytes
downloading Yaml-2.3.0.tgz ...
Starting to download Yaml-2.3.0.tgz (39,791 bytes)
...done: 39,791 bytes
downloading PHP_TokenStream-1.1.5.tgz ...
Starting to download PHP_TokenStream-1.1.5.tgz (9,859 bytes)
...done: 9,859 bytes
install ok: channel://pear.phpunit.de/File_Iterator-1.3.3
install ok: channel://pear.phpunit.de/Text_Template-1.1.4
install ok: channel://pear.phpunit.de/PHP_Timer-1.0.4
install ok: channel://pear.symfony.com/Yaml-2.3.0
install ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.5
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.2.11
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.2.3
install ok: channel://pear.phpunit.de/PHPUnit-3.7.21

Do I feel ashamed, it took me more than 2 minutes to realized what I had missed ? Definitely. But I just make my stupidity public in case others might face the same problem…

Install PEAR on Mac OS X Mountain Lion (10.8)

For some reason, PEAR is not installed on Mountain Lion. But fortunately. an installation PHP Archive is available to install it. It’s located in /usr/lib/php. It is thus very easy to install it using:

sudo php /usr/lib/php/install-pear-nozlib.phar

Enter the password and it gets installed in a second !

You can check the installation by running pear version:

$ pear version
PEAR Version: 1.9.4
PHP Version: 5.3.15
Zend Engine Version: 2.3.0
Running on: Darwin NEWMACBOOKPRO.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64

Of course an alternative is to install MAMP or XAMPP which come with PEAR installed.

Mac: Not seeing video in Skype

I’ve had the following problems for some time and it was slowly driving me crazy: In a Skype video call, others could see me but I couldn’t see them. I could only see their profile picture and this stupid cursor turning and turning.

I tried updating to the newest version, closing and restarting, disabling/enabling my video, making sure I was at a place in my house where I had at least a 40 Mbit/s connection to Internet… All without success.

I really do love Skype. Since my relatives and those of my wife all live in foreign countries, the only way to have the kids not forget grand pa and grand ma are video calls. But I was really starting to hate it !

Finally I got fed up and deleted Skype, then downloaded it again and reinstalled. And there it was ! It was all working again !

Problems with SVN in Eclipse on Mac OS X Mountain Lion (10.8)

I’m working on a new PHP project. Until now I’ve mainly been working on a Windows machine but today I wanted to move to my MacBook. So I just created a working copy and created a PHP project in Eclipse referencing the working copy. Unfortunately I got the following error message:

Failed to load JavaHL Library.
These are the errors that were encountered:
no libsvnjavahl-1 in java.library.path
/usr/local/Cellar/subversion/1.7.8/lib/libsvnjavahl-1.0.dylib:  Library not loaded: /usr/local/lib/libsqlite3.0.8.6.dylib   Referenced from: /usr/local/Cellar/subversion/1.7.8/lib/libsvnjavahl-1.0.dylib   Reason: image not found
no svnjavahl in java.library.path
java.library.path = .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java

I already had some issues with SVN on Mountain Lion some time ago. But I thought I was done with it. After carefully reading the error message, I remember I had just upgraded my Home Brew package and saw the following while upgrading sqllite:

==> Upgrading sqlite
==> Downloading http://sqlite.org/sqlite-autoconf-3071502.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/sqlite/3.7.15.2 --enable-dynamic-extensions
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

OS X already provides (an older) sqlite3.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/sqlite/lib
    CPPFLAGS: -I/usr/local/opt/sqlite/include

OK, so now what ? First check whether the library missed by Eclipse is really missing:

$ ls -l /usr/local/lib/libsqlite3.0.8.6.dylib
ls: /usr/local/lib/libsqlite3.0.8.6.dylib: No such file or directory

Ok, then try to find it:

$ find /usr -name "libsqlite3.0.8.6.dylib"
/usr/local/Cellar/sqlite/3.7.10/lib/libsqlite3.0.8.6.dylib
/usr/local/Cellar/sqlite/3.7.13/lib/libsqlite3.0.8.6.dylib
/usr/local/Cellar/sqlite/3.7.14.1/lib/libsqlite3.0.8.6.dylib
/usr/local/Cellar/sqlite/3.7.15/lib/libsqlite3.0.8.6.dylib
/usr/local/Cellar/sqlite/3.7.15.2/lib/libsqlite3.0.8.6.dylib
find: /usr/sbin/authserver: Permission denied

Ok so I have the choice. Now let’s just create a soft link to one of them:

$ ln -s /usr/local/Cellar/sqlite/3.7.15.2/lib/libsqlite3.0.8.6.dylib /usr/local/lib/libsqlite3.0.8.6.dylib

Now, deleting the project and recreating again isn’t enough since it will not try again to get the whole subversion thing working. You need to restart eclipse and recreate the project.
This time the subversion binding did work and after converting the working copy (it looks like I created it with svn 1.6 instead of 1.7), everything was working fine !

Using a MacBook Pro with a broken display as a desktop computer

Unfortunately the display of my MacBook Pro is broken, the surface is fine but all you see is a white area and a long vertical line which seems to be the mouse pointer, no more details since it’s still painful just to talk about it…

Now the computer itself is still working fine, it’s just the display. So I thought I could still use it as a desktop computer using an external monitor. So I connected an external monitor I had at home. The problem is that the display of the MacBook is still recognized so the external monitor is just used as a second display. This can be changed in the system preferences but I cannot access them since I cannot see anything on the first display.

So I went to my best friend in such cases: Google. Of course not on my Mac since Safari started through Spotlight or Alfred was displayed on the first display and I didn’t know how to move it to the second monitor. So I had to search for a solution using my smartphone. I did find a few people recommending the following trick:

  1. Boot the MacBook
  2. Close the lid
  3. The external monitor is activated as primary monitor
  4. Change the system preferences

It kind of worked. The external monitor was activated as primary monitor… for a very short time… Closing the lid caused the MacBook to go to sleep. After trying it about 10 times, I decided it was a dead end…

I also read that connecting a USB keyboard/mouse, it’d be possible to wake the computer from sleep even though the lid is closed but it just work for me. Pressing any key or the mouse buttons had no effect, probably because the lid was still closed…

I had almost given up I got an idea: The settings when the computer goes to sleep or not are usually different when connected to a power source. So I fetched my power cord/adapter, connected it and gave it another try and there it was: Connected to a power source, it didn’t go into sleep mode when I closed the lid and I can now work with the external monitor.

Now the only problem left is that the keyboard I use is a Windows keyboard and many keys do not work. So now I have to remap them all using KeyRemap4MacBook… But at least I have some kind of self made iMac 🙂

Mac OS X: use SSHFS to mount a remote directory as a volume

While working for amazingweb, I often need to edit existing files. This can be done with the web-based management UI but it’s so much nicer to be able to use the same editors and tools you’re used to on your local machine.

In order to be able to do this, you need either to have your editors/tools support SFTP and get and put files on the fly or be able to mount the remote file system as a volume on your local machine. Even if you find some solutions for a few of your editors (e.g. the Sublime Text editor with the SFTP plugin) you’ll still not be able to do everything as if it was all local because at least one tool doesn’t support SFTP.

So the more generic solution is to mount the remote file system. Of course since your remote server is remote and needs to be secured, you can only access it using SSH. Fortunately, SSH provides many extensions, some of which are used by pretty much everybody (e.g. SFTP) and others which are less known.

One of these extensions is SSHFS (Secure SHell FileSystem). It implements a file system and can be used on the Linux operating system and other platforms where FUSE is ready. FUSE (Filesystem in Userspace) is a kernel module for Unix systems, which enables file system drivers to shift from kernel mode to user mode. It thus allows non-privileged users to mount their own file systems.

In the past MacFUSE used to be the most prominent FUSE implementation for Max OS X. MacFUSE is not maintained anymore and has been replaced by “FUSE for OS X” (OSXFUSE). An alternative is Fuse4X which is a fork off MacFUSE but unlike MacFUSE it is fully compatible with FUSE.

I’ve used Fuse4X and it worked fine so I haven’t tried OSXFUSE.

You have three ways install Fuse4X:

  1. Download it from here and install it manually.
  2. Install it using Macport:
    sudo port install fuse4x
  3. Install it using Homebrew:
    brew install fuse4x

I used Homebrew and got the following errors:

Warning: Could not link fuse4x. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link fuse4x'
==> Summary
/usr/local/Cellar/fuse4x/0.9.2: 18 files, 720K, built in 34 seconds
Error: You must `brew link fuse4x' before sshfs can be installed

Unfortunately it doesn’t tell you what’s the actual problem… So I just did what I was told to:

$ brew link fuse4x
Linking /usr/local/Cellar/fuse4x/0.9.2... Warning: Could not link fuse4x. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/fuse4x/0.9.2/lib/pkgconfig/fuse.pc
Target /usr/local/lib/pkgconfig/fuse.pc already exists. You may need to delete it.
To force the link and delete this file, do:
  brew link --overwrite formula_name

To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name

Ok, so let’s do it with --overwrite:

$ brew link --overwrite fuse4x
Linking /usr/local/Cellar/fuse4x/0.9.2... 7 symlinks created

It’s installed !

Ok, now that you have installed Fuse4X using one of the three methods above, you’ll need to install sshfs.

With Homebrew, it is pretty easy:

$ brew install sshfs
==> Installing sshfs dependency: xz
==> Downloading http://tukaani.org/xz/xz-5.0.4.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/xz/5.0.4
==> make install
/usr/local/Cellar/xz/5.0.4: 58 files, 1.5M, built in 41 seconds
==> Installing sshfs dependency: libffi
==> Downloading http://mirrors.kernel.org/sources.redhat.com/libffi/libffi-3.0.11.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libffi/3.0.11
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Some formulae require a newer version of libffi.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/libffi/lib

==> Summary
/usr/local/Cellar/libffi/3.0.11: 13 files, 312K, built in 19 seconds
==> Installing sshfs dependency: glib
==> Downloading http://ftp.gnome.org/pub/gnome/sources/glib/2.34/glib-2.34.2.tar.xz
######################################################################## 100.0%
==> Downloading patches
######################################################################## 100.0%
######################################################################## 100.0%
########################################################                  77.9%
==> Patching
patching file glib/gunicollate.c
patching file aclocal.m4
patching file config.h.in
patching file configure
patching file configure.ac
patching file gio/gdbusprivate.c
patching file gio/xdgmime/xdgmime.c
patching file gio/gsocket.c
patching file gio/tests/socket.c
==> ./configure --disable-maintainer-mode --disable-dtrace --prefix=/usr/local/Cellar/glib/2.34.2 --localstatedir=/usr/local/var
==> make
==> make install
/usr/local/Cellar/glib/2.34.2: 407 files, 15M, built in 4.5 minutes
==> Installing sshfs
==> Downloading https://github.com/fuse4x/sshfs/tarball/sshfs_2_4_0
######################################################################## 100.0%
==> autoreconf --force --install
==> ./configure --prefix=/usr/local/Cellar/sshfs/2.4.0
==> make install
==> Caveats
Make sure to follow the directions given by `brew info fuse4x-kext`
before trying to use a FUSE-based filesystem.
==> Summary
/usr/local/Cellar/sshfs/2.4.0: 8 files, 132K, built in 12 seconds

Also check the following instruction before continuing:

$ brew info fuse4x-kext
fuse4x-kext: stable 0.9.2 (bottled)
http://fuse4x.github.com
/usr/local/Cellar/fuse4x-kext/0.9.2 (6 files, 284K) *
https://github.com/mxcl/homebrew/commits/master/Library/Formula/fuse4x-kext.rb
==> Caveats
In order for FUSE-based filesystems to work, the fuse4x kernel extension
must be installed by the root user:

  sudo /bin/cp -rfX /usr/local/Cellar/fuse4x-kext/0.9.2/Library/Extensions/fuse4x.kext /Library/Extensions
  sudo chmod +s /Library/Extensions/fuse4x.kext/Support/load_fuse4x

If upgrading from a previous version of Fuse4x, the old kernel extension
will need to be unloaded before performing the steps listed above. First,
check that no FUSE-based filesystems are running:

mount -t fuse4x

Unmount all FUSE filesystems and then unload the kernel extension:

  sudo kextunload -b org.fuse4x.kext.fuse4x

Now, you have both Fuse4X and SSHFS installed, so you can mount a remote directory as a volume using:

$ mkdir ~/amazingweb
$ sshfs -p 22 root@antagus2:/var/www/vhosts ~/amazingweb -oauto_cache,reconnect,defer_permissions,noappledouble,volname=amazingweb

Note that this works without needing any password because I use public-key cryptography to authenticate.

You only need to create the directory using mkdir once.

The first parameter (-p 22) means that port 22 should be used (the standard SSH port). The second parameter is the username, hostname and path to the remote filesystem to be mounted. The third parameter is the local path. The forth parameter is the list of options used:

  • auto_cache: enable caching based on modification times
  • reconnect: reconnect to server
  • defer_permissions: certain shares may mount properly but cause permissions denied errors when accessed (an issue caused by the way permissions are translated and interpreted by the Mac OS X Finder). This option works around this problem
  • noappledouble: to prevent Mac OS X to write .DS_Store files on the remote file system
  • volname: the volume name to be used

You can now access it just like a normal local folder. Of course you have to remount it after restarting the computer.

You can also automate the mounting of the remote folder using an application. To create one:

  • Open the AppleScript Editor
  • Create a script like the one which follows
  • Save it as an application
  • You can then start the application to mount your folder instead of going to the terminal

Here the script I use:

set homePath to POSIX path of (path to home folder)
set localPath to homePath & "amazingweb"
set remoteLogin to "root"
set remoteHost to "antagus2"
set remotePath to "/var/www/vhosts"
set volumeName to "amazingweb"

set message to "Unmounting SSHFS volume " & localPath
log message
UnmountSSHFSVolumne(localPath)
set message to "Mounting SSHFS volume " & localPath
log message
MountSSHFSVolumne(localPath, remoteLogin & "@" & remoteHost & ":" & remotePath, volumeName)

on UnmountSSHFSVolumne(aLocalPath)
	tell application "Finder"
		try
			if exists aLocalPath as POSIX file then
				set mountedVolumes to every paragraph of (do shell script "mount | awk -F' on ' '{print $2}' | awk -F' \\\\(' '{print $1}'")
				if aLocalPath is in mountedVolumes then
					do shell script "/sbin/umount " & aLocalPath
					set message to "Unmounted SSHFS volume " & aLocalPath
					log message
					display dialog message buttons {"OK"}
				end if
			end if
		on error errStr number errorNumber
			display dialog "Error: " & errStr buttons {"OK"}
		end try
	end tell
end UnmountSSHFSVolumne

on MountSSHFSVolumne(aLocalPath, aRemotePath, aVolumeName)
	tell application "Finder"
		try
			if exists aLocalPath as POSIX file then
			else
				do shell script "mkdir " & aLocalPath
			end if
			do shell script "/usr/local/bin/sshfs -p 22 " & aRemotePath & " " & aLocalPath & " -oauto_cache,reconnect,defer_permissions,noappledouble,volname=" & aVolumeName
			set message to "Mounted SSHFS volume " & aLocalPath
			log message
			display dialog message buttons {"OK"}
		on error errStr number errorNumber
			display dialog "Error: " & errStr buttons {"OK"}
		end try
	end tell
end MountSSHFSVolumne

Update: An alternative is to use ExpanDrive it makes it easy to setup a drive and reconnect automaticallyand allows you to use the drive anywhere. It’s technically a whole different beast since it’s actually using SFTP and showing the remote filesystem as a drive, but you won’t really feel the difference. The main reason why I do not use it is that it doesn’t work with authentication key instead of password: my Server doesn’t not allow authentication with password (only with registered keys). Theyhave a 7-days free trial period, so you can just give it a try.

Update: Fuse4x is not maintained anymore and has merged with osxfuse. So now, you should use osxfuse instead of Fuse4x. Osxfuse can also be installed with Homebrew. The package is not yet available in the repository so the following will fail:

$ brew install osxfuse
Error: No available formula for osxfuse

You have to do the following to install it:

$ brew install https://raw.github.com/bfleischer/homebrew/osxfuse/Library/Formula/osxfuse.rb

After that execute the following:

$ sudo /bin/cp -RfX /usr/local/Cellar/osxfuse/2.6.1/Library/Filesystems/osxfusefs.fs /Library/Filesystems
$ sudo chmod +s /Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs

If this fails saying that the file does not exist, it means that building osxfuse failed and the resulting file is missing. To check what happened, execute the following:

$ cd /Library/Caches/Homebrew/osxfuse--git
$ ./build.sh -t homebrew -f /usr/local/Cellar/osxfuse/2.6.1

I got the following messgage:

/usr/bin/xcodebuild: line 2: -version: command not found
OSXFUSEBuildTool() : skip unsupported Xcode version in ‘/Applications/Xcode.app/Contents/Developer’.
OSXFUSEBuildTool() failed: no supported version of Xcode found.

It’s due to a trick I used some time ago to build gem native extensions without XCode… All you have to do is restore the original xcrun file, remove the already partially installed osxfuse and reinstall it:

sudo mv /usr/bin/xcrun /usr/bin/xcrun.sav2
sudo mv /usr/bin/xcrun.sav /usr/bin/xcrun
brew remove osxfuse
brew install --reinstall https://raw.github.com/bfleischer/homebrew/osxfuse/Library/Formula/osxfuse.rb

GitHub: Cloning your own project

Today I released the first version of MySQLBuddy. It is basically a fork of SybaseBuddy where I’ve removed a few things (for Sybase) and made a few changes for MySQL. So I wanted to fork SybaseBuddy in GitHub to a new project. Unfortunately it looks like GitHub doesn’t support this. It seems to assume that the owner of a project will not fork his own project.

Here is what I did to fork the project:

I first created a new GitHub repository: MySQLBuddy.
Then I created a clone of SybaseBuddy on my machine:

$ git clone https://github.com/benohead/SybaseBuddy.git MySQLBuddy
Cloning into 'MySQLBuddy'...
remote: Counting objects: 105, done.
remote: Compressing objects: 100% (78/78), done.
remote: Total 105 (delta 33), reused 74 (delta 7)
Receiving objects: 100% (105/105), 6.48 MiB | 1.38 MiB/s, done.
Resolving deltas: 100% (33/33), done.

Now I had a clone but needed to teach it that it’s not linked to the SybaseBuddy GitHub repository anymore but to the MySQLBuddy repository. For this you need to update the .git/config in your clone:

Under Linux:

$ sed -i 's/SybaseBuddy/MySQLBuddy/g' .git/config

Under Mac OS X:

$ sed -i .tmp 's/SybaseBuddy/MySQLBuddy/g' .git/config

Or simply edit the file and update the URL to the repository.

Now you need to push this clone to the new repository:

$ git push -u origin master

You might get the following error message:

$ git push -u origin master
To https://github.com/benohead/MySQLBuddy.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/benohead/MySQLBuddy.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

What you need to do is first pull from the repository before pushing:

$ git pull

You might also get there the following error message:

$ git pull
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://github.com/benohead/MySQLBuddy
 + c1c2949...820a952 master     -> origin/master  (forced update)
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.

So you’ll need to handle the merge manually. Just update the file (here README.md) and pull again.

For some reason, I did the following before modifying the file:

$ git pull
U	README.md
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
$ git commit -a
[master 00dd552] Merge branch 'master' of https://github.com/benohead/MySQLBuddy

But you don’t need to do it like this and can directly modify the file and pull.

After that you’ll be able to push:

$ git push -u origin master
To https://github.com/benohead/MySQLBuddy.git
   820a952..00dd552  master -> master
Branch master set up to track remote branch master from origin.

And you’re done !

Apple Releases Java 2012-005

After Oracle releasing security updates for Java version 6 and 7, now Apple is following and distributes Java for Mac OS X 2012-005 moving to version 1.6.0_35, and thus the necessary corrections to its own OS X implementation. Moreover, the Safari plugin is configured so that it is automatically disabled when no applets are run a long time. If you want to re-enable Java, you have to do this via the plugin settings.

The update “Java for Mac OS X 2012-005” requires Mac OS X 10.7.4 or Mac OS X 10.8.1 while “Java for Mac OS X 10.6 Update 10” requires Mac OS X 10.6.8. Both updates improve the security, reliability and compatibility of Java SE 6 (by updating it to version 1.6.0_35).

Before installing the update, all web browsers and Java programs that are running must be closed.

Starting with version 7.0, Oracle will take care of the deployment of Java for Mac OS X. The latest Java 7 version for the Mac (a developer version) is available on this web page for download.

Mac OS X: SVN (Subversion) missing in Mountain Lion (10.8)

After upgrading to Mountain Lion, I realized that subversion (svn) was missing. Since I happened to install a new version of eclipse I first thought the problem was with my eclipse install but after wasting way too much time trying to fix it in eclipse I realized my problem was somewhere else…

So here’s what I did to fix it. SVN is part of the Command Line Tools. To install them go to Downloads for Apple Developers. This requires an Apple Developer ID. Getting one is free and only requires an Apple ID which you should all already have.
There select Command Line Tools (OS X Mountain Lion) and download the DMG file (it’s about 110 MB). Then open the DMG file, double click on Command Line Tools (Mountain Lion).mpkg, just keep clicking Continue / Agree / Install.

An alternative is to install Xcode. You can download it from the Mac App Store. Once Xcode is installed, you can go the Preferences > Downloads > Command Line Tools and install them.
Xcode install command line toolsThe downside of this method is that you have to install Xcode which is a waste of space (1.5 GB download and 3.3 GB install) unless you develop for Mac OS X or iOS. But if like me you have Xcode installed anyway…

Once you’ve installed the Command Line Tools, you can check whether SVN is installed and whether you have the right version (1.6.18) opening a Terminal and typing the following:

svn --version
svn, version 1.6.18 (r1303927)
   compiled Jun 15 2012, 19:07:58

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme

That’s it !

Update: Another way is to use Homebrew or MacPorts.

With Homebrew installed, open a Terminal window and type the following:

brew install subversion

If you get the following error:

curl: (22) The requested URL returned error: 503
Error: Download failed: http://pkg-config.freedesktop.org/releases/pkg-config-0.25.tar.gz

You will need to type the following:

brew edit pkg-config

The replace the two lines with url and md5 by:

  url 'http://sourceforge.net/projects/buluoos/files/0.4/src/pkg-config-0.25.tar.gz/download?use_mirror=garr'
  md5 'a3270bab3f4b69b7dc6dbdacbcae9745'
  version '0.25'

Save and rerun the install of subversion. If you get the following error message:

curl: (22) The requested URL returned error: 404
Error: Download failed: http://www.apache.org/dyn/closer.cgi?path=subversion/subversion-1.7.4.tar.bz2

This means that your HomeBrew installation should be updated. It should fetch subversion 1.7.5 instead of 1.7.4. You can update it with the following command:

brew update

Then rerun the subversion install.

If the installation of subversion or an upgrade to a newer version gets stuck (this happens to me every time), with the following last line written to the console:

==> make

Just kill it with CTRL-C and restart it. In my case, it always gets stuck for hours the first time and works the second time…

After the install, you might see when running svn –version that it doesn’t say 1.7.5. This is because the new version is installed in /usr/local/bin and there is an older version in /usr/bin. If your PATH looks like this:

echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/X11/bin

Then you’ll see the svn program in /usr/bin because it is before the /usr/local/bin in PATH. So you need to update your PATH so that /usr/local/bin comes before /usr/bin:

vi ~/.profile

There add /usr/local/bin:

...
export PATH=/usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH
...

If you want to have a subversion integration in Eclipse, you’ll need the java bindings. To install them using Homebrew execute the following:

brew install --universal --java subversion

Universal means it will install both 32 and 64bit version (without this the java bindings will most probably not work fine). And the Java option tells Homebrew to additionally install the Java bindings.

If you’ve already installed subversion using Homebrew without the java bindings, you can just uninstall it and reinstall it with the bindings:

brew uninstall subversion
brew install --universal --java subversion

If you get messages saying you need to first remove some packages, remove them, they will be reinstalled when installing subversion, e.g. I had to remove neon and serf:

brew rm neon serf

After installing with the bindings, there will be some instructions about links to be created. It’s important to create these links. On my machine and with subversion 1.7.7, it said:

You may need to link the Java bindings into the Java Extensions folder:
  sudo mkdir -p /Library/Java/Extensions
  sudo ln -s /usr/local/lib/libsvnjavahl-1.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib

Unfortunately, on my machine the Eclipse integration still didn’t work… Until I noticed the instructed linked was not completely right:

ls -l /Library/Java/Extensions/
total 16
drwxrwxr-x  4 root  admin  136 Nov 30 21:36 .
drwxr-xr-x  5 root  wheel  170 Oct 25 22:33 ..
lrwxr-xr-x  1 root  admin   35 Nov 30 21:36 libsvnjavahl-1.dylib -> /usr/local/lib/libsvnjavahl-1.dylib
lrwxr-xr-x  1 root  admin   40 Dec 21  2011 libsvnjavahl-1.jnilib -> /opt/subversion/lib/libsvnjavahl-1.dylib

So basically the link was created with the wrong them. So just had to do the following to solve the problem:

cd /Library/Java/Extensions/
mv libsvnjavahl-1.jnilib libsvnjavahl-1.jnilib.sav
mv libsvnjavahl-1.dylib libsvnjavahl-1.jnilib

If like Julio, you have some error messages related to libpq.5.dylib having a wrong architecture, you can try the following:

find / -name "libpq.5.dylib"

This will find all occurrences of this library. On my machine, it found it there:

/Applications/AMPPS/extra/lib/libpq.5.dylib
/Applications/MAMP/Library/pg/lib/libpq.5.dylib
/Applications/MAMP_2012-08-11_23-20-34/Library/pg/lib/libpq.5.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib/libpq.5.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/libpq.5.dylib
/usr/lib/libpq.5.dylib
/usr/local/php5/lib/libpq.5.dylib

Checking the one in /usr/lib, you see that it’s a 64bit only library:

file /usr/lib/libpq.5.dylib
/usr/lib/libpq.5.dylib: Mach-O 64-bit dynamically linked shared library x86_64

But the php library was both 32 and 64bit:

file /usr/local/php5/lib/libpq.5.dylib
/usr/local/php5/lib/libpq.5.dylib: Mach-O universal binary with 4 architectures
/usr/local/php5/lib/libpq.5.dylib (for architecture i386):	Mach-O dynamically linked shared library i386
/usr/local/php5/lib/libpq.5.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
/usr/local/php5/lib/libpq.5.dylib (for architecture ppc7400):	Mach-O dynamically linked shared library ppc
/usr/local/php5/lib/libpq.5.dylib (for architecture ppc64):	Mach-O 64-bit dynamically linked shared library ppc64

So you probably only need to replace the one in /usr/lib by this one:

sudo mv /usr/lib/libpq.5.dylib /usr/lib/libpq.5.dylib.only_64
sudo cp /usr/local/php5/lib/libpq.5.dylib /usr/lib/libpq.5.dylib

If you still have problems when integrating svn with eclipse, please a have look at this post.

Note that I’ve written a new post to show how to handle multiple subversion version using brew.