image

Sascha Depold

Engineering Manager

Blog

[sdepold] Sharing Rubymine preferences via Dropbox

devanda:

Motivation

If you are using Rubymine (like ~50% of the DaWanda devs is), you might have got the idea of sharing your preferenceswith multiple computers. Because most of us are coding on Apple hardware, this description is for MacOSX, butwill work similarly on linux as well.

The naive way

When thinking about sharing stuff on multiple devices, you will stumble across Dropbox. The first and obvious way is movingyour preferences folder into it and symlinking it into the origin place:

mv ~/Library/Preferences/RubyMine31 ~/Dropbox/System/Preferences/
ln -s ~/Dropbox/System/Preferences/RubyMine31 ~/Library/Preferences/RubyMine31

When starting RubyMine for the next time, it will complain about a missing preferences folder and bootup some strange environmentin which you can work almost normally but have no shortcuts etc. The very next thing I tried was symlink without the -s flag.This will fail due to MacOSX missing support of hardlinks for directories.

Solution

After googling for a while, I found this discussion on StackOverflow. It explains how to compile a binary for creating directory symlinks. So copy the following snippet and paste it into your favorite place for binaries and shell scripts (because I like sharing custom binaries via Dropbox it is ~/Dropbox/System/Bin/hlink.c for me).

#include <unistd.h>
#include <stdio.h>

int main(int argc, char* argv[]) {
if (argc != 3) {
fprintf(stderr,Use: hlink <src_dir> <target_dir>\n);
return 1;
}
int ret = link(argv[1],argv[2]);
if (ret != 0)
perror(link);
return ret;
}

Afterwards cd into that specific folder and do this:

cd ~/Dropbox/System/Bin
gcc hlink.c -o hlink

And finally:

mv ~/Library/Preferences/RubyMine31~/Dropbox/System/Preferences/
./hlink ~/Dropbox/System/Preferences/RubyMine31 ~/Library/Preferences/RubyMine31

When running RubyMine for the next time, everything should be just as before!

Have fun,
sdepold