Emacs, Sunrise Commander and (avfs, fuse, unionfs-fuse) in MAC OS X (Lion)

There is legendary file manager, GNU Midnight Commander. I learned that they made the name of “Midnight” because many computer programmers do coding at night. So, the writer of “Sunrise Commander” makes the name of “Sunrise” hoping all software developers works in day time. 🙂

OK. Now, as a user for emacs, I have been using command line shell, which was good enough since I can create buffers as many as I want. However, I feel that it would be nice if there is a nice file manager like GNU Midnight Commander in Emacs from time to time. Dired is great tool, but whenever I visit a directory, it creates another buffer, which I don’t like.

So, I found the sunrise commander (http://emacswiki.org/emacs/Sunrise_Commander) Yay!

However, the first thing I met was how to easily uncompress a file such as tar, tgz, tar.gz, tar.bz2, zip, and etc.

While reading the sunrise commander page, they do support it using AVFS, and described in (http://emacswiki.org/emacs/Sunrise_Commander#toc3).

It is trivial if you are linux user. In my case, I use Linux based on Ubuntu at work, but I use frequently MacBook Pro which is given by my current employer. The struggling part is how to use it in MAC OS X Lion (OS X 10.7.4).

Here is what I do, but before exposing of it, I want to put disclaimer saying that “I am managed to work this, and it is not guaranteed that it works in other environment and version. Also, I am not sure this is the right thing to do, but it works for me at least.” However, I want to share this and it could be a hint for other version or other situation.

1. prerequisite and version

This should be done before proceeding below.

Here is items to be installed.

  • port
  • Xcode Developer Tools
  • fuse4x
  • lzma

If you don’t know how to port the open source, you need to learn Mac Port (http://www.macports.org/), or simply just install of it with Xcode Developer Tools from Apple Inc.

When you’re ready to use “port” utility, you can do first this:

sudo port install fuse4x fuse4x-framework fuse4x-kext lzma lzmautils

Above will install fuse4x and lzma libraries.

(I’m not sure fuse4x-framework fuse4x-kext are needed or not, but I just installed it just in case.)

2. fuse-2.9.1

3. avfs-1.0.0

To use avfsd, fuse had to be pre-installed, which described in section 2 above.

Now, we are going to install avfs.

  • Download avfs from http://sourceforge.net/projects/avf/
  • Extract it into a directory
  • do
     CFLAGS="-DPTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP=PTHREAD_RECURSIVE_MUTEX_INITIALIZER -D_USE_GNU=1 -D__FreeBSD__=10 -fnested-functions -I/opt/local/include" ./configure --enable-fuse
  • check if the last report should shows like this:
    Configuration details:
      Building library                          : yes (recommended: yes)
      Building avfsd for fuse                   : yes (recommended: yes)
      Building preload library                  : no  (recommended: no)
      Building avfscoda daemon and kernel module: no  (recommended: no)
      Use system zlib                           : no  (recommended: no)
      Use system bzlib                          : no  (recommended: no)
      Use liblzma                               : yes (recommended: yes)
      Installation prefix                       : /usr
  • Do
     make && sudo make install

4. unionfs-fuse-0.26

Actually, this is optional, but if you want to use sunrise-x-mirror.el, you may need this, and I did, too.

  • Download unionfs-fuse from http://podgorny.cz/moin/UnionFsFuse
  • Extract it into a directory
  • Download and Apply 0001-Patches-for-Mac-OS-X-Mountain-Lion-for-unionfs-fuse-0.26.patchby
    git apply 0001-Patches-for-Mac-OS-X-Mountain-Lion-for-unionfs-fuse-0.26.patch
  • do
    CFLAGS="-D__FreeBSD__=10" make

    and do

    sudo make install
  • unionfs is installed by default at /usr/local/bin, but the sunrise-x-mirror expects unionfs-fuse as a filename to use it. So, go to /usr/local/bin, and do
     sudo ln -s unionfs unionfs-fuse

    so that it creates the symbolic link for sunrise-x-mirror

5. Usage

OK. It’s done.

Now, you need to launch avfsd by referring to http://www.emacswiki.org/emacs/Sunrise_Commander_Tips#AvfsSetup, but here is what I do

/usr/bin/avfsd -o allow_other -o intr -o sync_read -o uid=[myuid] -o gid=[mygid] ~/.avfs

uid and gid can be gotten by


command in a shell.

5-1. Emacs path environment

This is also optional, but my Emacs does not recognize the /usr/local/bin path, so I googled and found below at http://stackoverflow.com/questions/6411121/how-to-make-emacs-to-use-my-bashrc-file

(defun set-exec-path-from-shell-PATH ()
  (let ( (path-from-shell (replace-regexp-in-string
                          "[ \t\n]*$"
                          (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))

(if window-system (set-exec-path-from-shell-PATH))

, and I put it into ~/.emacs.d/init.el (or ~/.emacs)

OK, Now, you can use compressed files as you want. The detail info can be found at http://emacswiki.org/emacs/Sunrise_Commander for the use. I only provide the way to use the application on Mac OS X.

5-2. /dev/fuse

Check “ls -al /dev/fuse”. The device’s group may be “fuse”, so in order to use avfsd in userland, your id should be in the “fuse” group. In order to add it, do this


The “groups” CLI shows what groups are being associated with the userid. So, you can copy the groups and added “fuse” if it is not setup, and do like following:

/usr/sbin/usermod -G [groups],fuse [userid]

6. Conclusion

As I said, those patches are only applying to my environment and not guaranteed to others. It may require to tune it, but I guess it will give a hint to get through similar situation.

(Updated 9/28/2012, and 5-2 section may not be needed.)

4 Replies to “Emacs, Sunrise Commander and (avfs, fuse, unionfs-fuse) in MAC OS X (Lion)”

  1. unionfs-fuse-0.26 can’t find malloc.h in mac 10.8.2 with Xcode 4.6.2
    so i modify src/usyslog.c

    #ifdef HAVE_MALLOC_H

    then it can complie.

Leave a Reply

Your email address will not be published. Required fields are marked *