bug: lazygit throws fatal error when default config file is absent
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 = {},
} },
},
})
It looks to me like here you should be checking if the file exists first (or something to that effect) before adding it.
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
Your PS is exactly the PR I was planning on doing I just hadnt gotten around to it yet XD
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.
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.
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!
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.
Not stale
I mean, stale doesnt mean its not gonna happen.
It just means that folke is busy and has a bot of questionable usefulness.
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.
Im not stale. You are stale, github-actions.
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.
get deleted bot
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.
shh
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.
.
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)
found this thread after throwing up a pr for the same issue, hopefully folke can get around to looking at this quick fix soon 🤞
Doesn't matter to me whose PR it is who gets it through, just glad to stop getting the stale notification XD