Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Support #201

Open
samisuteria opened this issue Nov 16, 2024 · 2 comments
Open

Linux Support #201

samisuteria opened this issue Nov 16, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@samisuteria
Copy link

Is there a way to run this package in server environments? I saw https://github.com/automerge/automerge-swift/blob/main/Sources/Automerge/_AutomergeLinux.swift#L8 after trying to run a grpc server in docker/linux instead of macOS.

@heckj heckj self-assigned this Nov 16, 2024
@heckj heckj added the question Further information is requested label Nov 16, 2024
@heckj
Copy link
Collaborator

heckj commented Nov 16, 2024

Hey @samisuteria

I believe it's technically possible, but it's not a drop-in-and-work kind of thing. The complicating bit of this is the core library of Automerge is written in Rust, which we expose to Apple platforms through XCFramework. The XCFramework is a means of packaging a pre-compiled binary for the relevant platform - and XCFramework is an Apple platform specific thing, meaning there's no support for using binaries compiled for linux platforms.

There's two ways of tackling this - the first is to leverage the WASM compilation of this suite, along with the WASM compilation of Automerge, and run the whole bit within a WASM runtime, possible WASMKit or WASMER. This whole space isn't well fleshed out, but we have seen the whole kit working through WASM (primarily running in a browser) and have the WASM compilation support built in for that.

The other path would be to use this same code, but change the dependencies in Package.swift so that instead of referencing an XCFramework, you're loading and referencing a pre-compiled C library.

To my mind, the last would be the "easiest" route to get working - you'd need to compile the automerge core library as a binary library for the linux platform you're running on with Rust, put it into the system library path, and then update the dependencies to use it as a "C system library" from Swift. I'm not certain if there's a clean way to incorporate this setup without forking the repository though.

It's probably worth noting that you utilize Automerge on linux through Deno or NodeJS, which has really very good support, as this library is intentionally cross-platform and cross-language compatible (using the Rust language as a core). The majority of the folks I'm aware of using Automerge on Linux are doing so through that path, that's already been pretty well tread.

@heckj
Copy link
Collaborator

heckj commented Nov 16, 2024

If this is something you'd be interested in helping to sort out - to run Automerge swift natively on Linux - I'd be happy to help work with you through it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants