eraserhd / parinfer-rust

A Rust port of parinfer.
ISC License
530 stars 41 forks source link

Failure trying to use in an M1 Mac without Rosetta #135

Open pablo-abc opened 1 year ago

pablo-abc commented 1 year ago

Hello! I've been setting up Neovim lately in an M1 MacBook (using both iTerm and Neovide without Rosetta).

I've installed this plugin using Packer. And the installation + build work without any issues. But whenever I try to open a Clojure/Fennel/ClojureScript file, the following error appears:

Error detected while processing BufEnter Autocommands for "<buffer=1>"..function <SNR>43_event[2]..<SNR>43_enter_buffer[8]..<SNR>43_process_buffer:
line   50:
dlerror = "dlopen(/Users/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/target/release/libparinfer_rust.dylib, 0x0001): tried: '/Users/pberganza/.local/share/nvim/site/
pack/packer/start/parinfer-rust/target/release/libparinfer_rust.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexe
s/OS/Users/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/target/release/libparinfer_rust.dylib' (no such file), '/Users/pberganza/.local/share/nvim/site/pack/packer/st
art/parinfer-rust/target/release/libparinfer_rust.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/Users/pberganza/.local/share/nvim/site/pack/p
acker/start/parinfer-rust/target/x86_64-apple-darwin/release/libparinfer_rust.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Pr
eboot/Cryptexes/OS/Users/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/targ
E364: Library call failed for "run_parinfer()"
E474: Attempt to decode a blank string
E474: Failed to parse

Error executing vim.schedule lua callback: Vim(let):dlerror = "dlopen(/Users/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/target/release/libparinfer_rust.dylib, 0x000
1): tried: '/Users/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/target/release/libparinfer_rust.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64
', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/target/release/libparinfer_rust.dylib' (no such file), '/U
sers/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/target/release/libparinfer_rust.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64
')), '/Users/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/target/x86_64-apple-darwin/release/libparinfer_rust.dylib' (mach-o file, but is an incompatible architecture
 (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/pberganza/.local/share/nvim/site/pack/packer/start/parinfer-rust/targ
stack traceback:
        [C]: in function 'bufload'
        ...im/site/pack/packer/start/conjure/lua/conjure/buffer.lua:36: in function 'upsert_buf'
        .../nvim/site/pack/packer/start/conjure/lua/conjure/log.lua:329: in function 'append'
        ...tart/conjure/lua/conjure/client/clojure/nrepl/action.lua:107: in function <...tart/conjure/lua/conjure/client/clojure/nrepl/action.lua:54>

I've tried to run cargo build --release --target=x86_64-apple-darwin and to replace the release folder with its output. But the same error is happening. Would love some help!

Info on my system:

❯ arch
arm64

❯ clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

❯ cargo --version
cargo 1.60.0 (d1fd9fe2c 2022-03-01)

❯ sw_vers
ProductName:        macOS
ProductVersion:     13.0.1
BuildVersion:       22A400
eraserhd commented 1 year ago

I'm currently on an M1, and although I've installed it differently, it definitely builds for arm64.

Have you tried without the --target arg? It should work and build arm64 binaries that do not need rosetta. I've tested locally on my M1 macbook with a fresh checkout:

[nix-shell:~/src/parinfer-rust]$ cargo build --release
   Compiling proc-macro2 v1.0.24
   Compiling ryu v1.0.5
   Compiling serde v1.0.123
   Compiling syn v1.0.60
   Compiling serde_derive v1.0.123
   Compiling serde_json v1.0.64
   Compiling libc v0.2.87
   Compiling quote v1.0.9
   Compiling parinfer_rust v0.4.3 (/Users/jfelice/src/parinfer-rust)
    Finished release [optimized] target(s) in 9.03s

[nix-shell:~/src/parinfer-rust]$ ls
CHANGELOG.adoc  LICENSE.md   Web.toml    derivation.nix  extra-docs   package.json  release.nix  src     tests
Cargo.lock  Makefile     benches     dist        nixpkgs.nix  plugin        script   static
Cargo.toml  README.adoc  default.nix  doc        overlay.nix  rc        shell.nix    target

[nix-shell:~/src/parinfer-rust]$ ls target/
CACHEDIR.TAG  release

[nix-shell:~/src/parinfer-rust]$ ls target/release/
build  deps  examples  incremental  libparinfer_rust.d  libparinfer_rust.dylib  libparinfer_rust.rlib  parinfer-rust  parinfer-rust.d

[nix-shell:~/src/parinfer-rust]$ ls -l target/release/
total 2352
drwxr-xr-x 16 jfelice 151928526     512 Dec  8 16:54 build
drwxr-xr-x 45 jfelice 151928526    1440 Dec  8 16:55 deps
drwxr-xr-x  2 jfelice 151928526      64 Dec  8 16:54 examples
drwxr-xr-x  2 jfelice 151928526      64 Dec  8 16:54 incremental
-rw-r--r--  1 jfelice 151928526     363 Dec  8 16:55 libparinfer_rust.d
-rwxr-xr-x  1 jfelice 151928526  557232 Dec  8 16:55 libparinfer_rust.dylib
-rw-r--r--  1 jfelice 151928526 1124984 Dec  8 16:55 libparinfer_rust.rlib
-rwxr-xr-x  1 jfelice 151928526  710256 Dec  8 16:55 parinfer-rust
-rw-r--r--  1 jfelice 151928526     500 Dec  8 16:55 parinfer-rust.d

[nix-shell:~/src/parinfer-rust]$ file ./target/release/libparinfer_rust.dylib 
./target/release/libparinfer_rust.dylib: Mach-O 64-bit arm64 dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|NO_REEXPORTED_DYLIBS|HAS_TLV_DESCRIPTORS>

[nix-shell:~/src/parinfer-rust]$ file ./target/release/parinfer-rust
./target/release/parinfer-rust: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE|HAS_TLV_DESCRIPTORS>

[nix-shell:~/src/parinfer-rust]$ 

I also verified the version I use regularly is arm64.