Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: assertion failed! when trying to copy a link #257

Closed
loganswartz opened this issue Jan 17, 2025 · 7 comments · Fixed by #258
Closed

Bug: assertion failed! when trying to copy a link #257

loganswartz opened this issue Jan 17, 2025 · 7 comments · Fixed by #258

Comments

@loganswartz
Copy link

Ever since updating to f643cdf or newer, I get this error every time I try to copy a link:

Error executing Lua callback: ...nvim/lazy/gitlinker.nvim/lua/gitlinker/commons/async.lua:78: assertion failed!
stack traceback:
        [C]: in function 'assert'
        ...nvim/lazy/gitlinker.nvim/lua/gitlinker/commons/async.lua:78: in function '_sync_link'
        .../.local/share/nvim/lazy/gitlinker.nvim/lua/gitlinker.lua:335: in function <.../.local/share/nvim/lazy/gitlinker.nvim/lua/gitlinker.lua:321>

Specifically, this assert fails:

assert(not coroutine.running())

After reverting to 8e193f0, everything works as expected. I don't think this is linked to a Neovim update, since it's been happening for a while and I'm on nightly, but just in case here's my current version:

NVIM v0.11.0-dev+1551-ge8ddb7a46
Build type: RelWithDebInfo
LuaJIT 2.1.1720049189

What's the output of git remote get-url origin?

It happens on every repo, but here's an example: git@github.com:loganswartz/dotfiles.git

what's the expect git host url you want to generate?

N/A

how do you configure this plugin?

Via lazy.nvim:

{
    'linrongbin16/gitlinker.nvim',
    main = 'gitlinker',
    config = true,
    keys = {
        {
            '<leader>gy',
            function() require('gitlinker').link() end,
            silent = true,
            noremap = true,
            desc = "Copy git permlink to clipboard",
            mode = { 'n', 'v' }
        },
    },
}
@linrongbin16
Copy link
Owner

linrongbin16 commented Jan 18, 2025

hi @loganswartz , thanks for report this issue.

Would you tell me what OS you're using? For example Windows 10 x86_64 (with Intel/AMD chip), or MacBook with M1/M2 silicon chip, or Ubuntu/Fedora/ArchLinux x86_64 (with Intel/AMD chip)?

I'm using macbook with M1 chip, I cannot re-produce this issue. I had tested with both v0.10.3 and latest nightly neovim, with two git repos:

  • https://github.com/linrongbin16/gitlinker.nvim (start with https://)
  • git@github.com:personalorg/personalrepo.git (start with git@)

Note: this async module is actually copied from lewis6991/async.nvim. I just read again the document, I think I use the API correctly.

But I am not a master about lua coroutine, @lopi-py could you give some suggestions?


Maybe, when @loganswartz is running this plugin (either require('gitlinker').link() API or :GitLink command), you're already inside a coroutine (just like the assertion failed error said)?
The difference could be (I'm not 100% sure), in the previous async module, when we invoked the async.void API, see this line:

f643cdf#diff-e85b0a73f385d3b9be62752dbc0afd2ca8eba8b75c12d7667a5514b8b35755eeL276

Image

We didn't enable the strict check, see this line:

f643cdf#diff-61eaf9e597ea38a64d3b8fcf9bf9a8b2c3b58cbc3fd4a66b16c69357a5a5c4b9L184

Image

This helps avoid such assertion errors, maybe?

If so, maybe I should revert back to previous version of async module?

@linrongbin16
Copy link
Owner

hi @loganswartz , I create a revert PR #258 (on branch fix-async), do you want to have a try? see if it works for you.

@linrongbin16
Copy link
Owner

linrongbin16 commented Jan 18, 2025

For the long term, I think maybe I should try to learn how this async module works, so I could maintain it by myself.... Or just don't touch it any more.....

@loganswartz
Copy link
Author

I just did some testing on several machines with the exact same config, and attempted to copy a link to the exact same line, in the exact same file, in the exact same repo:

  • AMD Ryzen 7 5825U, Fedora 41 - doesn't work, throws the error I mentioned above
  • Intel i7 8750H, Fedora 40 - doesn't work, exact same error
  • x86_64 Ubuntu 20.04 VM - works without issue
  • Late 2014 Intel i7 Mac Mini, macOS Monterey 12.7.6 - works without issue

So perhaps this is a Fedora-specific issue?

I also tested out that revert branch, and it does work on the Fedora 41 machine.

@linrongbin16
Copy link
Owner

hi @loganswartz , thanks for this information! I merged the fix PR #258 , please pull master branch.

@linrongbin16
Copy link
Owner

I report this here: lewis6991/async.nvim#7

@linrongbin16
Copy link
Owner

linrongbin16 commented Feb 1, 2025

I just reproduced this bug in #262 , I think this issue worth some attention.


Or we can depend on the "async" module in "plenary.nvim".

Since it is quite a widely used library so we could avoid such non-complete testing issues in different OS/platforms and linux distributions. And we don't have to maintain it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants