Tag Archives: OSX

Invalidating Preferences Cache in Mavericks (OS X 10.9.x)

I recently set up a fresh install of Mavericks (OS X 10.9), and copied over some of preferences (plist) files from old installation to new box ( (~/Library/Preferences).

I noticed, applications failed to use (manually copied) preferences files, instead kept throwing errors (like one shown below):

cfprefsd[xxxx]: CFPreferences: error renaming file /Users/username/Library/Preferences/com.codeux.irc.textual.plist.bPsEnTV to /Users/username/Library/Preferences/com.codeux.irc.textual.plist

Unlike previous versions of OS X, Mavericks (OS X 10.9) caches preferences files. That means, if we edit or overwrite a preferences (plist) file, we need to invalidate the cache so that applications can see the changes, and start using this updated preferences file.

I didn’t want to set up everything from scratch, in this case all IRC servers, nodes and chatrooms. It is not fun editing binary plist files, even with the help of XCode :-)

To fix this problem, we need to run this from terminal:

defaults read ~/Library/Preferences/com.codeux.irc.textual

We also need to make sure preferences file has correct permission. In my case, permissions were messed up because I copied file from different disk (installation).

Permission should look like following (i.e. owner can at least read/write; umask 077):

-rw-------

I would suggest restarting the respective application, if it is already running.

Installing NumPy and SciPy on Mac OSX 10.8 (Mountain Lion)

I am playing with ExpEyes, which is awesome tool for anyone who wants to learn electronics (and physics).

ExpEyes comes with software (written in python) for GNU/Linux and Windows. I intend to run it on Mac OSX, because it can (provided all dependencies are met).

It is generally easy to install python packages on OSX using easy_install or pip, however, installing NumPy and SciPy turned out to be pain on OSX (10.8.2, latest version the time of posting).

In my case, I am using python binary installed via homebrew, so I can’t take advantage of numpy (which comes installed with mountain-lion).

I have XCode 6 installed, which comes with gcc-4.2.1 (llvm build). I figured out, I can build numpy and scipy from source.

Following is what I did to build numpy and scipy. SciPy requires gfortran, so that has to be installed (I used homebrew to do that):

$ git clone https://github.com/numpy/numpy.git
$ git clone https://github.com/scipy/scipy.git
$ cd numpy
$ python setup.py build && python setup.py install
$ brew install gfortran
$ cd ../scipy
$ python setup.py build && python setup.py install

BTW! In case, you are wondering, why didn’t I use Scipy Superpack script, which indeed makes job easier?

I didn’t, because I want to install gnu/unix packages using homebrew, and I already have git and other things. Super Spicypack downloads (gfortran, etc.), builds and installs packages directly to system, making it harder to remove those later? Homebrew makes job easier.

Mac OSX (10.8) Mountain Lion: Fixing Apache, PHP, Subversion, User Sites, Virtual Hosts Directories

While Mountain Lion (OSX 10.8) has brought many enhancements and fixes (mostly performance), it has also caused frustration to old users.

You might have noticed following issues in Mountain Lion:

  1. Web Sharing Preferences Panel has been removed, i.e. you need to launch apache manually or write some launch-agent script or hack to bring web-sharing preferences panel back
  2. User Sites (per-user web directories) is disabled, i.e. http://localhost/~username doesn’t work by default, and you need to modify apache config file to enable it
  3. PHP extension for Apache is disabled by default i.e. you need to enable it by modified apache config (httpd.conf)
  4. Subversion is not installed by default, either you can install using homebrew or by install XCode command line tools

You can fix these issues (1-4) by following these two links:

Whenever I upgrade to newer version of OSX, I end up with broken development-setup i.e. custom permissions on directories are messed up, configuration files are overwritten/removed, etc.

I think, I have found a way to keep default directory permissions, so future upgrades don’t break things.

My development setup requires my virtual hosts to use directories within my home-directory (and outside of ~/Sites or /Library/WebServer/Documents directories).

I am using following technique to setup my virtual-hosts:

  • Enable User Sites  (i.e. fix #2 problem above)
  • Create symbolic-links(symlinks) of your project folder(s) inside ~/Sites directory
  • Enable FollowSymLinks and SymLinksIfOwnerMatch options in virtual-host configuration.

In my case, I have a project inside ~/projects/myproject . I create a symlink of this directory inside ~/Sites, like this using Terminal (command-prompt)

$ ln -s ~/projects/myproject ~/Sites/myproject

I have following virtual-host configuration for this project:

<VirtualHost *:80>
 DocumentRoot "/Users/myusername/Sites/myproject/trunk/web"
 ServerName  myproject
 ServerAdmin myusername@localhost
 Options Indexes MultiViews Includes +FollowSymlinks +SymLinksIfOwnerMatch
 CustomLog "/private/var/log/apache2/myproject_access.log" common
 ErrorLog "/private/var/log/apache2/myproject_error.log"
</VirtualHost>

I use it on my development machine (i.e. my laptop), so I don’t really bother about security at Apache level, and I take care of security at firewall/other levels.

If you are going to use above technique/configuration, please understand everything (by reading documentation) before you use it.

This set up works for me and solves some problems for me – I don’t have to change default directory permissions, and I don’t have to keep my projects within ~/Sites or /Library/WebServer/Documents directory.

Installing Riak on Mac OSX

I am evaluating various nosql solutions for our existing/new projects. Bluesmoon recommended about Riak which is an awesome nosql datastore/database (and lot more).  I couldn’t wait to check it out.

As usual, I relied on Homebrew – the best package manage for OSX – to install applications/libraries. While installing, I got an error:

$ brew install riak
$ ...
$ Error: Failed executing: make all rel

After searching for a while, I figured out that there are known issues. With the help of Adam‘s comment on github, I was able to install Riak finally.

We make brew ignore Riak’s dependencies while building it.

Following commands should build and install Riak:

$ brew update
$ brew install erlang
$ brew install --HEAD --ignore-dependencies riak -v

Ideas: FlashDevelop on OSX and GNU/Linux

FlashDevelop is an open-source IDE for Flash Platform development (ActionScript, MXML, HAXE, etc.) on Windows platform. I have extensively used it in past, and still, painfully, use it via windows virtual-machine on OSX host.

Couple of years back, I looked at FlashDevelop code to figure out, if we can port it for other operating-systems, such as Mac OSX and GNU/Linux.

I posted on Flash Develop forum about my experiments:

I have been trying to run FlashDevelop under OSX. In last couple of years, whenever I got sometime, I tried these:-

  1. Run FlashDeveloper with DotGNU: FlashDevelop was running but due to a lot of native (Win32) API calls, lots of components were failing (screenshot: http://pic.im/5Xk)
  2. Run Flash Developer with Mono: I tried to compile FlashDevelop using MonoDevelop and run using Mono for OSX. Most of the problems is one component/library i.e. DockPanelSuite (http://sourceforge.net/projects/dockpanelsuite/), an opensource code that uses a lot of PInvoke calls (Win32 API).

I am really excited about the possibilities, if we can port this one library we can get very closer to run FlashDevelop on OSX using Mono.

Note: pics.im seems to be dead, so I have uploaded new screen-shots
Flash Develop on OSX - ScreenshotFlash Develop on OSX

Some Ideas:

MonoDevelop is good enough and works well on OSX, I guess also GNU/Linux. However, I am yet to look at licensing and possibilities of forking the project (MonoDevelop)?

BTW! I have been lazy to write about such experiments on the blog, but while commenting on Jesse Warden’s post, I thought, it makes sense to post it here, so it lives.

Please let me know, if you have any ideas about making this happen? I would be happy to collaborate, contribute and donate in whatever capacity I can.

Mac OSX: Leopard to Snow Leopard Upgrade

Snow Leopard Installer DVD was delivered in our office on Saturday and I couldn’t wait to upgrade to Snow Leopard (10.6.x). I could have upgraded earlier, if Apple had enough stores and better reseller network in India.

Anyway, upgrade was smoother  compared with Tiger(10.4.x) to Leopard (10.5.x) upgrade. Installer UI has around 4-5 steps and none of steps mention “upgrade” word. Installer is smart enough to detect existing installations, figure out which printer drivers to keep or install. However, it chooses all languages (translation) to install even when you didn’t have those in Leopard.

Within fourty mintues, upgrade was completed and I was back in action.

However, In my case, I have to spend some more time to setup/fix things which were broken, such as:-

  1. Reinstalled MacPort using installer for snow-leopard and upgraded some of packages (libiconv, jpeg, libpng, libmycrypt, openssl, gettext, freetype, openssl, curl) and their dependencies for 64bit compatibilities (+universal, +variants)
  2. Compiled Apache, MySQL and PHP for 64 bit
  3. Reinstalled Remote Desktop Connection using latest installer to fix crash issue on Snow Leopard

If you don’t want to use MacPorts, you can download source of these libraries separately, compile and install. These would be installed in /usr/local unless you change the prefix.

Installing 64 bit version of Apache, MySQL and PHP took around two-three hours because of some issues related to libiconv.2.dylib. Apache would compile but fail to run, reporting incorrect version of libiconv. I downloaded libiconv source, compiled and installed it in /usr/lib (instead of /usr/local/lib). Apache started working but  vim, make, other unix programs (chmod, etc) failed to run using latest libiconv.2.dylib.

I tweaked the setting in /usr/sbin/envvars to use following:-

DYLD_LIBRARY_PATH="/usr/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib:/opt/local/lib:/sw/lib

Basically, added a fallback path so if library is not found in /usr/lib, it would look into other directors, as specified.  After doing this, Apache (64bit) and vim, make, chmod, etc started working.

MySQL compilation was straight forward with following command, thanks to this link, I just added CFLAGS=”-arch x86_64″  while compiling to make sure mysql is compiled for 64 bit. Moved data directory back to new mysql installation directory.

Compiling php 5.2.13 resulted into some errors related to iconv, hash and gd. After spending sometime, I decided to compile without these extensions with following commands:

MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch x86_64 -g -Os -pipe"
LDFLAGS="-arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
./configure --prefix=/usr/local/php5 --exec-prefix=/usr/local/php5 --disable-dependency-tracking --sysconfdir=/private/etc --with-apxs2=/usr/sbin/apxs --enable-cli --with-config-file-path=/etc --with-libxml-dir=/usr --with-openssl=/usr --with-kerberos=/usr --with-zlib=/usr --enable-bcmath --with-bz2=/usr --enable-calendar --with-curl=/usr --enable-exif --enable-ftp --without-gd --with-jpeg-dir=/opt/local/lib --with-png-dir=/usr/local/lib --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6 --with-ldap=/usr --with-ldap-sasl=/usr --enable-mbstring --enable-mbregex --with-mysql=mysqlnd --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-iodbc=/usr --enable-shmop --with-snmp=/usr --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --without-xmlrpc --without-iconv --with-xsl=/usr

#if everything goes well
make

#if everything goes above, install php5 in /usr/local/php5
sudo make install

I checked (php -m) some extensions (xdebug, etc) were not loading, so I updated those individually, specially iconv, xmlrpc and gd. Compiling an extension is generally four step process. For example, if you want to compile iconv, you can do the following:

$ cd /php-source/ext/iconv
$ phpize
$ ./configure --with-iconv=/usr
$ make
$ sudo make install

It all worked fine, apache was loading php fine and all my websites and applications work fine.

iSync: SyncSession record validation failure

ISyncSession record validation failure: Value other pushed for enumeration property service on com.apple.contacts.IM is not an allowed value.

If you get above error while synchronising your OSX addressbook with Google Contacts, you might want to remove various IM types (Skype, Google Talk, etc) specified for contacts. OSX AddressBook can only accept “AIM”, “Yahoo”, “Jabber”, “MSN” and “ICQ” as types.