snacks.nvim icon indicating copy to clipboard operation
snacks.nvim copied to clipboard

bug: lazygit throws fatal error when default config file is absent

Open BirdeeHub opened this issue 9 months ago • 11 comments

Did you check docs and existing issues?

  • [x] I have read all the snacks.nvim docs
  • [x] I have updated the plugin to the latest version before submitting this issue
  • [x] I have searched the existing issues of snacks.nvim
  • [x] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.11.0-nightly+e02ee74

Operating system/version

NixOS 25.05 (linux, any)

Describe the bug

If you delete the config file for lazyvim, open neovim and try to open it via snacks, it errors out.

2025/03/09 17:05:30 stat /home/birdee/.config/lazygit/config.yml: no such file or directory

[Process exited 1]

Its not enough to just create ~/.config or even ~/.config/lazygit

You have to create the actual ~/.config/lazygit/config.yml file or it errors out

Lazygit itself on its own is able to handle this, so it shouldn't be happening.

Steps To Reproduce

Install snacks.nvim and lazygit

Delete ~/.config/lazygit/config.yml

Open lazygit via snacks

Observe error

Expected Behavior

It should make the file if it doesn't exist, avoid requesting the file if it doesn't exist, or allow lazygit to do that for you.

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {
      lazygit = {},
    } },
  },
})

BirdeeHub avatar Mar 10 '25 00:03 BirdeeHub

It looks to me like here you should be checking if the file exists first (or something to that effect) before adding it.

BirdeeHub avatar Mar 10 '25 01:03 BirdeeHub

In my personal opinion I don't believe it's Snacks' responsibility to ensure that the user has a working lazygit configuration.

The assumption is that the user already has a working lazygit configuration and snacks.lazygit only adds to that. That's why the error is also thrown. So, the user should just run lazygit once outside of Neovim for the config file to be populated and then run snacks.lazygit.

What if the user doesn't have lazygit installed? Should Snacks install it for the user?

But in the end it's up to the maintainer to decide, as I'm just a simple user.

PS: In retrospect maybe the check could be changed into if #config_files == 0 and vim.fn.filereadable(config_dir .. "/config.yml") == 1 then

dpetka2001 avatar Mar 10 '25 09:03 dpetka2001

Your PS is exactly the PR I was planning on doing I just hadnt gotten around to it yet XD

BirdeeHub avatar Mar 10 '25 11:03 BirdeeHub

It not a problem with me. Go ahead and create the PR.

My initial assumption was that you wanted snacks.lazygit to create that file. But i tested and it works correctly even without that file present, since lazygit_theme will be present. I didn't think that snacks.lazygit should be responsible for the creation of that file. But since it works without it, a check about its existence makes sense indeed.

dpetka2001 avatar Mar 10 '25 11:03 dpetka2001

Yeah I took a snoop around and found the issue but I had to go.

I felt lazy pointing out the exact bug, and saying in words what to do, its just the right thing to do to finish the job at that point.

BirdeeHub avatar Mar 10 '25 11:03 BirdeeHub

I also encountered this problem and wanted to report the issue but found this one.

IMO snacks.lazygit should not assume that a default config file exists. You can install Lazygit and run it in the terminal without creating a config first. The plugin should provide the same user experience.

The difference with snacks.lazygit is that it uses LG_CONFIG_FILE to specify configuration files directly. I think the assumption with Lazygit is that if you pass in specific configuration files, you should make sure those files exist.

The same is true in the terminal. We will get the exact same error if we run:

LG_CONFIG_FILE=./does-not-exist.yml lazygit

Thanks for the fix, I hope it will be merged soon!

dpomykala avatar Mar 16 '25 17:03 dpomykala

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Apr 23 '25 02:04 github-actions[bot]

Not stale

dpetka2001 avatar Apr 23 '25 06:04 dpetka2001

I mean, stale doesnt mean its not gonna happen.

It just means that folke is busy and has a bot of questionable usefulness.

BirdeeHub avatar Apr 23 '25 07:04 BirdeeHub

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar May 25 '25 02:05 github-actions[bot]

Im not stale. You are stale, github-actions.

BirdeeHub avatar May 25 '25 02:05 BirdeeHub

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 25 '25 02:06 github-actions[bot]

get deleted bot

dpetka2001 avatar Jun 25 '25 06:06 dpetka2001

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 30 '25 02:07 github-actions[bot]

shh

dpetka2001 avatar Jul 30 '25 07:07 dpetka2001

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Sep 01 '25 02:09 github-actions[bot]

.

dpetka2001 avatar Sep 01 '25 04:09 dpetka2001

Every day folke stays on vacation the more I get jealous of Europeans XD (JK I realize not paying attention to github is not the same thing as a vacation from an actual job lol)

BirdeeHub avatar Sep 01 '25 06:09 BirdeeHub

found this thread after throwing up a pr for the same issue, hopefully folke can get around to looking at this quick fix soon 🤞

cosmicbuffalo avatar Oct 10 '25 18:10 cosmicbuffalo

Doesn't matter to me whose PR it is who gets it through, just glad to stop getting the stale notification XD

BirdeeHub avatar Oct 10 '25 21:10 BirdeeHub