romgrk / fzy-lua-native

Luajit FFI bindings to FZY
118 stars 16 forks source link

Local changes to binaries break updating step of lazy.nvim #28

Closed yochem closed 3 weeks ago

yochem commented 1 month ago

Lazy.nvim or other version-control based package managers break after installing this plugin and building the static files with make:

    ● fzy-lua-native 0.25ms  care.nvim
        You have local changes in `/Users/yochem/.local/share/nvim/lazy/fzy-lua-native`:
          * static/libfzy-darwin-x86_64.so
        Please remove them to update.
        You can also press `x` to remove the plugin and then `I` to install it again.
        static/libfzy-darwin-x86_64.so
        You have local changes in `/Users/yochem/.local/share/nvim/lazy/fzy-lua-native`:
          * static/libfzy-darwin-x86_64.so
        Please remove them to update.
        You can also press `x` to remove the plugin and then `I` to install it again.

I followed the recommended installation steps for care.nvim:

{
    "max397574/care.nvim",
    dependencies = {
        {
            "romgrk/fzy-lua-native",
            build = "make" -- optional, uses faster native version
        }
    },
    config = function()
        -- Set up mappings here
    end
}

But running make during installation creates new static binaries, and Lazy.nvim does not want to overwrite them.

romgrk commented 3 weeks ago

Any way to run git restore . before the update? That would clean up the local changes.

Alternatively, I guess we could create a local directory with priority over the prebuilt one. PR welcome, I don't have much free time at the moment.

yochem commented 3 weeks ago

If I understand correctly:

  1. You want to keep the binaries in the repo for users without make/c compiler/etc
  2. But users can build the binaries themself for a more native binary

Is that correct? If so, we can have Make generate a local-native.so binary. If that file is present, it is used from the lua code. Otherwise the os-arch.so binary. I can for sure create a PR for this. Let me know if my assumptions and approach are right :)

romgrk commented 3 weeks ago
  1. Yes
  2. "for a more native binary": No, that option is there in case the prebuilt binaries don't cover the prebuilt options, e.g. ARM CPU or *BSD OS. If the prebuilt binary for the system is present and works, there is no need to build it again.

I would approach it by creating an empty directory with echo '*' > ./static-local/.gitignore. Then something in make to generate binaries at either ./static (for the CI) or ./static-local (for end-users). Then the lua code can just try ./static-local before trying ./static.