Running ArchivesSpace on an M1 Mac
A few of us over at Hudson Molonglo have recently been trying out Apple's latest M1 offerings—a new family of CPUs based on the ARM architecture.
At the time of writing (early 2022), there are a few hurdles to getting an ArchivesSpace development environment running, but it can be done. Let's dive in.
Getting Java 8
ArchivesSpace still recommends Java 8, and that's our first hurdle: Oracle doesn't provide ARM64 builds of older versions of Java. Fortunately, the good people at Azul do. If you head over to Azul's download page, you'll find you can download a version of Java as follows:
Java Version: JDK 8 (LTS)
Operating System: macOS
Architecture: ARM 64-bit
Java Package: JDK
Grab whichever package format takes your fancy, download it and unpack it somewhere. I unpacked mine to:
/Users/mst/zulu8.56.0.23-ca-jdk8.0.302-macosx_aarch64/
Setting up ArchivesSpace with a working JRuby version
As of early 2022, ArchivesSpace targets the 9.2 series of JRuby, which is compatible with MRI Ruby 2.5. The latest release (9.2.20.1) is missing some patches that are necessary for running ArchivesSpace on the M1.
We're going to pull in a custom version of JRuby. If you'd like to build it yourself, we have placed a branch here:
https://github.com/marktriggs/jruby/tree/jruby-9.2-aspace-2.8
You can build it by running Maven from a checked out copy:
./mvnw clean && ./mvnw -Pcomplete
Alternatively, you can grab the copy I built and just use that:
https://tsp.nz/d/e22aca32df0e2e092d7d05a54340bb2486ce8995.jar/jruby-complete-9.2.21.0-SNAPSHOT.jar
Once you have a jruby-complete
JAR file, copy it somewhere on your
system where you won't lose it. Your archivesspace/
directory
wouldn't be a bad choice.
Now, you can get ArchivesSpace using it. Open the build/build.xml
file and set your jruby_url
and jruby_file
properties as follows
(replacing the two lines that are already there, and substituting the
right path to your JRuby file):
<property name="jruby_url" value="file:///Users/mst/archivesspace/jruby-complete-9.2.21.0-SNAPSHOT.jar" />
<property name="jruby_file" value="jruby-complete-9.2.21.0-SNAPSHOT.jar" />
That's it for JRuby.
A small ArchivesSpace code change
There is one small code change required to make ArchivesSpace compatible with the latest version of JRuby. Edit the file:
archivesspace/backend/app/model/mixins/dynamic_enums.rb
and replace:
define_method(:values) do
values = super
with:
define_method(:values) do
values = super()
That is, add the empty set of parens to the super
call. If you
don't do that, you'll see this error and wonder why:
[java] RuntimeError: implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly.
[java] uses_enums at /Users/mst/test/archivesspace/backend/app/model/mixins/dynamic_enums.rb:61
We'll be sending a pull request to fix this in future ArchivesSpace versions.
Putting it all together
With all of that, you have Java 8, JRuby 9.2 and a (lightly modified) ArchivesSpace instance. The final steps are:
Make sure your Java 8 install is on your $PATH:
export PATH=/Users/mst/zulu8.56.0.23-ca-jdk8.0.302-macosx_aarch64/bin:$PATH
Confirm you're getting the right version:
% java -version openjdk version "1.8.0_302" OpenJDK Runtime Environment (Zulu 8.56.0.23-CA-macos-aarch64) (build 1.8.0_302-b08) OpenJDK 64-Bit Server VM (Zulu 8.56.0.23-CA-macos-aarch64) (build 25.302-b08, mixed mode)
Bootstrap your ArchivesSpace install to grab all dependencies:
build/run bootstrap
Run the various dev servers:
build/run backend:devserver build/run frontend:devserver build/run indexer