nvim-telescope / telescope-fzf-native.nvim

FZF sorter for telescope written in c
1.38k stars 45 forks source link

telescope-fzf-native doesn't work with Apple M1 #23

Closed jay-dee7 closed 3 years ago

jay-dee7 commented 3 years ago

Hey guys, i've been using fzf with telescope for a while but i recently bought a new MBP with Apple Silicon. When i try to follow the installation and setup instructions, it fails with the following error:

telescope-fzf-on-m1-error
Conni2461 commented 3 years ago

It seems like it was build with the wrong architecture. I know for a fact that it should work, @tami5 has M1 and he made it work.

Maybe you can navigate to /Users/jasdeep/.config/nvim/plugged/telescope-fzf-native.nvim and do a make clean + make to build it again. Maybe that fixes the issue. You can validate this with make ntest (runs the lua tests). For the c tests make test you need to have cmocka installed, but you don't need to do this. make ntest should be enough to validate this.

If that doesn't, i would be interested in a make output and maybe @tami5 help

kkharji commented 3 years ago

Yes, true fzf built without issue on my mac m1, make sure that the terminal isn't open under rossta 2

jay-dee7 commented 3 years ago

@tami5 @Conni2461 I see, my terminal is running under rosetta 2 (Alacritty) Im not sure if they have a native M1 build for it. I tried with default terminal with a rebuild and it worked just fine.

Thank you so much guys for the help :)

kkharji commented 3 years ago

@tami5 @Conni2461 I see, my terminal is running under rosetta 2 (Alacritty) Im not sure if they have a native M1 build for it. I tried with default terminal with a rebuild and it worked just fine.

Thank you so much guys for the help :)

np ;)

For Alacritty, I had to download it locally and build it myself, which is quite easy and straightforward process, I encourage you to do the same.

Good luck

dkarter commented 2 years ago

I had the same issue. Turns out it was because of having 2 installations of neovim, one from Homebrew, which was compiled correctly for arm64, and the other from ASDF which was compiled for Intel. The intel version was getting launched sometimes and caused arm binaries to not work. Removing the Intel arch Neovim seems to have solved the issue (for now).

lucasfcosta commented 2 years ago

In case anyone is having problems because you can't load an x86 extension on an M1, I've got it working on my fork here.

" Make sure to remove the old .config/nvim/plugged/telescope-fzf-native.nvim directory before PlugInstalling.
Plug 'lucasfcosta/telescope-fzf-native.nvim', { 'do': 'make' }

All I had to do was update the build script so that it uses the correct target:

build/$(TARGET): src/fzf.c src/fzf.h
    $(MKD) build
    $(CC) -O3 $(CFLAGS) -shared src/fzf.c -o build/$(TARGET) -target arm64-apple-macos11

There's probably a better way to do this by updating the Makefile if condition on the top, but I just thought it would be easier for me to do this change and keep a fork for now.

If folks find it useful just react to this comment and I'd be happy to make a proper port upstream.

Conni2461 commented 2 years ago

We have support for cmake for quite some time, to improve compatibility (mostly with windows). Would be good to know if that would also help with this issue.

https://github.com/nvim-telescope/telescope-fzf-native.nvim#cmake-windows-linux-macos

None the less i would prefer a patch here that adds the target automatically. I do not have a mac so i cant test anything but wont this work

UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),arm64)
    CFLAGS += -target arm64-apple-macos11
endif

and this right after line 11? Can you test this and open a PR?