Friday, June 8, 2012

Aptana Studio 3 and AFP (Apple Shares)

(The JavaVM -Dosgi.locking=none trick, from Eclipse)


Problem:


I installed Aptana Studio 3 on my MacBook.  I use Aptana because I am partial to the slimed down Eclipse environment it offers.  Majority of my code and scripts are Python, Java, and XHTML so it makes sense not to use the entire Eclipse suite.  However I came across the strangest error when I pointed Aptana's workspace to my AFP share on my NAS.



Many failed attempts to diagnose why Aptana saw the share as "read-only" had occurred when looking in the logs.  So, I went Geek on it.  I tried using the command line argument -data [path] when launching Aptana.  This forces Aptana to use the value provided (replace [path] with your intended path) as the workspace directory.  

With a Mac this is not as simple as running Aptana.app -data [path].  In very high level terms I will explain why.  The [name].app items in your Applications folder are actually Directories.  These hold all the vital contents and resources required to launch you Mac Application.  When you click (launch or execute) the directory, it will proceed to launch [name].app/Contents/MacOS/[name]
In the case of Aptana we can list the directory like so:
ls /Applications/Aptana\ Studio\ 3/AptanaStudio3.app/Contents/MacOS/
-rwxr-xr-x  1  70368 May 30 02:13 AptanaStudio3
-rw-r--r--  1  458 May 30 02:13 AptanaStudio3.ini

So now we can test the argument in a terminal window. 
/Applications/Aptana\ Studio\ 3/AptanaStudio3.app/Contents/MacOS/AptanaStudio3 -data [path]

It is more than likely that your AFP share still will not work, you will probably see one of two errors.
  1. The folder "[path]" is read-only.
  2. Locking is not possible in the directory "[path]". A common reason is that the Runtime Environment does not support file locking for that location. Please choose a different location , or disable file locking passing "-Dosgi.locking=none" as a VM argument.

This all means that Aptana's underlying JavaVM can't perform a file lock on the target AFP share.  To disable file locking you need to add two parameters to your command.
 -vmargs
 -Dosgi.locking=none




Solution:



The first way to do this is to add the  "-Dosgi.locking=none" to the Aptana ini file.
/Applications/Aptana\ Studio\ 3/AptanaStudio3.app/Contents/MacOS/AptanaStudio3.ini 
This must come after the -vmargs entry in your AptanaStudio3.ini file.

This will not work for me under OS X Lion.  So my preferred solution is the second method.  Create and automator application "run shell script".


Save this Automator script in your applications and you'll be able to launch AFP workspaces without error.

“Let someone else praise you, not your own mouth - a stranger, not your own lips.”
Proverbs 27:2

No comments:

Post a Comment