nvim-neorocks / rocks-git.nvim

Use rocks.nvim to install plugins from git!
GNU General Public License v3.0
35 stars 3 forks source link

Update: Set `rev` to the latest tag or revision if it isn't set. #36

Closed teto closed 4 days ago

teto commented 1 week ago

while trying to sync my config on another computer, many of my plugins installed via git failed with

ERROR | 2024-07-04 14:51:37 | /home/teto/rocks.nvim/lua/rocks/operations/init.lua:99 | SYNC ERROR: Failed to install cloak.nvim: No version specified

:Rocks install laytan/cloak.nvim generated

[plugins."cloak.nvim"]
# can conceal some patterns in some specific files
git = "laytan/cloak.nvim"
opt = true

because the upstream repo doesnt have any tag.

and it worked on install but on another machine, rocks-git.nvim wants a rev I think (which makes sense for a sync).

I tried to work around it by adding version = "648aca6d33ec011dc3166e7af3b38820d01a71e4" or rev = "648aca6d33ec011dc3166e7af3b38820d01a71e4" but none of those worked.

rocks-git should add the git revision if the repo does not contain a tag. I would even say that in case the user used a ref, the config.toml should contain the "ref" and "revision" similar to lockfiles. Rocks update would keep the ref but update the revision.

teto commented 1 week ago

the No version specified comes from rocks.nvim and rocks-git.nvim looks like it should work with a commit id as rev so the problem seems to come from somewhere else related to my config, some bad loading order. I will try to debug

teto commented 1 week ago

from what I understand of the code is that if rocks.nvim can't install the plugin, it defers those plugin to the extensions. -- Save skipped rocks for later, when an external handler may have been bootstrapped.

            -- rocks.nvim sync handlers should be installed now.
            -- try installing any rocks that rocks.nvim could not handle itself
            for _, skipped_rock in ipairs(skipped_rocks) do

In my case for some reason the rocks-git hander probably doesn't get registered.

mrcjkb commented 1 week ago

@teto have you solved this?

teto commented 1 week ago

solved it. My config contains a rocks_subdir ="" which triggered weird error messages because the plugins were "half" installed: lua files were installed in rtp but not the .vim for instance which explained why the callbacks were not registered but I could require 'rocks-git' lua files for instance.

I leave this open because of:

rocks-git should add the git revision if the repo does not contain a tag. I would even say that in case the user used a ref, the config.toml should contain the "ref" and "revision" similar to lockfiles. Rocks update would keep the ref but update the revision.

I still like this idea. If you approve as well, I can take a stab at it.

A related PR to what caused my pain yesterday: https://github.com/NixOS/nixpkgs/pull/324812

mrcjkb commented 1 week ago

I think I'm fine with that.

Historically, we allowed entries without a rev because sync was the only operation that rocks-git hooked into, so leaving rev unset was a way of saying "I don't care about pinning, I just want the latest version".

Now that rocks-git also hooks into Rocks update, there's no need for that anymore.

mrcjkb commented 1 week ago

I've updated the title to reflect the new desired behaviour.

Note: technically, this is a breaking change.

mrcjkb commented 4 days ago

Actually, sync handlers don't have access to the mutable rocks.toml reference. But we can make update update the rev if none is set.

TarunDaCoder commented 1 day ago

Hmmmm, I seem to be running into this error once again. My rocks-git.nvim version seems to be the latest. And, this only happens with plugins installed via rocks-git.nvim

EDIT: This seems to get fixed after I do :Rocks update and then :Rocks sync

PS: Sorry to disturb you Mark, feel free to take your time to reply to this :D