SuperBo / fugit2.nvim

Neovim git GUI powered by libgit2
MIT License
352 stars 7 forks source link

bug: make the plugin compatible with Neovide GUI #30

Closed alex35mil closed 3 months ago

alex35mil commented 4 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

Current implementation doesn't work with Neovide on macOS.

ffi.load "libgit2" uses DYLD_LIBRARY_PATH to search for libgit2.dylib. But macOS's SIP blocks passing DYLD_LIBRARY_PATH to GUI apps, so Neovide doesn't have this var set and this plugin fails to load.

Describe the solution you'd like

The only option I see is to make path to libgit2.dylib configurable.

Describe alternatives you've considered

-

Additional context

No response

SuperBo commented 4 months ago

Thank you, I will test with neovide tomorrow. For now, can you copy libgit2.dylib to neovide Application directory?

alex35mil commented 4 months ago

@SuperBo I build Neovide from source and symlinking libgit2.dylib to ~/.cargo/bin doesn't work. I tried to symlink it to /usr/local/bin where my nvim is, but it doesn't work either.

When I run nvim from terminal, it works fine since DYLD_LIBRARY_PATH is set correctly.

SuperBo commented 4 months ago

@alex35mil , how do you install neovide?

I install "neovide" by brew install neovide and brew install --cask neovide and I can run Fugit2 normally with both.

Screenshot 2024-03-27 at 17 03 11
alex35mil commented 4 months ago

@SuperBo I build it from source. I.e., I sync the neovide repo and run cargo install --path .. But I haven't updated it for quite a while, so maybe it works with the latest version. I will update it in the upcoming days and get back to you.

SuperBo commented 4 months ago

@alex35mil, any update with your testing, are you able to use Fugit2 with Neovide?

alex35mil commented 4 months ago

@SuperBo Updated Neovide to the latest master and I still get the same error when building Neovide from source.

SuperBo commented 4 months ago

@alex35mil, can you share with me your PATH as well as LD_LIBRARY_PATH env var.

alex35mil commented 4 months ago

@SuperBo I assume when you run Neovide, :echo expand('DYLD_LIBRARY_PATH') gets expanded to a proper path, right?

alex35mil commented 4 months ago
PATH:
/Users/Alex/.local/share/devbox/global/default/.devbox/nix/profile/default/bin:/nix/store/lhqd2mwnd8wf1zh4jrd73hp8z1v5q9jw-clang-wrapper-11.1.0/bin:/nix/store/adq7mqvlblq6ck2a3qcimlx7lgaj71p6-clang-11.1.0/bin:/nix/store/kmvdv9dda4064k9bmmy8540xzaprc8ls-coreutils-9.3/bin:/nix/store/ng9j7s9nv2gy17m4n4078cdmnlg3rpga-cctools-binutils-darwin-wrapper-11.1.0-973.0.1/bin:/nix/store/4cyq37pwgzcnlzysqkpvrlaxp54ckvar-cctools-binutils-darwin-11.1.0-973.0.1/bin:/nix/store/m7f28sddyphl7ya506h8qmw6bxyz91gc-brotli-1.0.9/bin:/nix/store/98iwixkvi1wggfzgyjwiv7v9hy16cdvd-libkrb5-1.20.1-dev/bin:/nix/store/pph5ycjm921nxc55ax3yhkcbs7fn5hpp-libkrb5-1.20.1/bin:/nix/store/53mn26z66yn7pm8j0jbskhf0jh752r1y-nghttp2-1.54.0/bin:/nix/store/xqn4n32k3kljh3a5sbvhma6sqp84c5qn-libidn2-2.3.4-bin/bin:/nix/store/vfhqzf1nq4cadzkcz2yfip67zl69x5h1-openssl-3.0.10-bin/bin:/nix/store/1j48s9vcbykmaa6jj378q1dr3pwvsf50-zstd-1.5.5-bin/bin:/nix/store/ay59b8c1s2p2wr292ssa353ww0smczc3-zstd-1.5.5/bin:/nix/store/9pzdafwfyjk6aryx0jyz031b9i9pqlz0-curl-8.2.1-bin/bin:/nix/store/38hrq70jzqsq81v7gim7j3q45955186l-jq-1.7-bin/bin:/nix/store/i8ghysdn40c2i6b9maylmn3d1d7x0ix3-findutils-4.9.0/bin:/nix/store/a18724qp7yrm4hr9swqp9asa4xd291q2-diffutils-3.10/bin:/nix/store/niqr00gsad0gfxx3skr1vhl7wb76idml-gnused-4.9/bin:/nix/store/cdmbbylvs8hr92b41a6v1ds874z2rmz2-gnugrep-3.11/bin:/nix/store/w0q2n50cjbgqqn18pg1miganjhny6ws4-gawk-5.2.2/bin:/nix/store/ppznc7jmszsjkgc9b3n98wr16bwgjckv-gnutar-1.35/bin:/nix/store/ia55kybwcyr5x26kkggghmi4l3bjifhb-gzip-1.13/bin:/nix/store/66wm4b5pms454m30gf2f7g9sqpryk49q-bzip2-1.0.8-bin/bin:/nix/store/86rrxgy5bc461gr44qdpr9bwc3dxggqd-gnumake-4.4.1/bin:/nix/store/hm8sxwvz7qbf5kzgprdlggj231l5g2s4-bash-5.2-p15/bin:/nix/store/p07ddiglrh562addqvmm8spkvwc9pcsa-patch-2.7.6/bin:/nix/store/zdlgkkgmnfn4xkfsbmpxqsmzfjb2jlwa-xz-5.4.4-bin/bin:/nix/store/f8fhzgd8j037nxq9c1f1cwqanxdczs5i-file-5.45/bin:/Users/Alex/.local/share/devbox/global/default/.devbox/virtenv/runx/bin:/Users/Alex/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/Users/Alex/.cargo/bin:/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:/Users/Alex/.npm-global/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/share/dotnet

LD_LIBRARY_PATH:
/Users/Alex/.local/share/devbox/global/default/.devbox/nix/profile/default/lib
SuperBo commented 4 months ago

@alex35mil, looks like you are using nix, can you help me check whether libgit2 is in /Users/Alex/.local/share/devbox/global/default/.devbox/nix/profile/default/lib?

alex35mil commented 4 months ago

@SuperBo Yup, it’s there. The plugin works in terminal-based nvim because it picks up DYLD_LIBRARY_PATH, which points to this folder.

SuperBo commented 4 months ago

@alex35mil , Oh I know, please tackle this the Nix way :D.

Edit this nix recipe https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/neovim/neovide/default.nix.

Add libgit2 and gpgme to Librarypath after line https://github.com/NixOS/nixpkgs/blob/a2d38866bdaeb787a3f3c67dc7d5eafb281599a4/pkgs/applications/editors/neovim/neovide/default.nix#L88

alex35mil commented 4 months ago

@SuperBo I build neovide from source, not via nix.

SuperBo commented 4 months ago

@alex35mil, Did you follow this instruction to build Neovide, https://neovide.dev/installation.html#mac-source, if not please provide your steps.

I can't reproduce this on MacOS Sonoma 14.4. What Mac OS Version are you using, Arm or Intel?

Can you try unset DYLD_LIBRARY_PATH before running Neovide.

DYLD_LIBRARY_PATH="" neovide
alex35mil commented 4 months ago

@SuperBo I have Rust toolchain installed via rustup official script, not brew. To install neovide, I just pull neovide's master and run cargo install --path .. I don't build an app bundle because I don't need it, as I run neovide from terminal only.

I'm on macOS 14.0 (ARM).

By default, my shell has only $LD_LIBRARY_PATH set. Ie, it doesn't have $DYLD_LIBRARY_PATH set.

In this default environment, the plugin doesn't work in neither terminal-based nvim, nor in neovide.

When I set $DYLD_LIBRARY_PATH, the plugin works in terminal-based nvim, where $DYLD_LIBRARY_PATH is picked up (ie, :echo expand('DYLD_LIBRARY_PATH') expands into a correct path), but it doesn't work in neovide, where $DYLD_LIBRARY_PATH is unset.

SuperBo commented 4 months ago

I think this problem is specific to how nix manage dependencies path. Can you try edit your zprofile as mentiond by Neovide. Append libgit2 path to LD_LIBRARY_PATH.

Screenshot 2024-04-05 at 16 47 20
alex35mil commented 3 months ago

@SuperBo Sorry for delay. You're right, it works when setting a var in non-interactive shell. Except it should be DYLD_LIBRARY_PATH. Thanks for the help!