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: Targets from included Makefile only visible on first execution #280

Closed
sieuwerts opened this issue Apr 8, 2024 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@sieuwerts
Copy link

sieuwerts commented Apr 8, 2024

Neovim version (nvim -v)

0.9.5

Operating system/version

MacOS 14.4

Describe the bug

When including an external Makefile, the targets are only found by overseer once.
When opening neovim and running :OverseerRun I can see that all of my expected targets are there, also if I run :OverseerInfo the number of tasks are correct.

However, if I close this window and run either of the commands above again, the targets in the included Makefile is not found.

Restarting Neovim will fix it temporarily, but then again only once. See the Steps to Reproduce for more information.
image
image

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. Create two Makefiles, one in the project root (will be referred to as the Main Makefile), one in a sub directory (git submodule in my case, will be referred to as Shared Makefile)
  2. In the Shared Makefile, add any target, e.g shared/test, it doesn't matter what it does.
  3. In the Main Makefile, start by adding the line include ./<subdirectory-where-you-stored-shared-makefile>/Makefile
  4. Add another target in the Main Makefile e.g. main/test
  5. Now open neovim and run :OverseerInfo or :OverseerRun and you will see two different make targets available.
  6. Close the window with Esc (or q if info screen).
  7. Run :OverseerInfo or :OverseerRun again and only the target from the Main Makefile is visible in the Task template list (or only 1/1 task available on the overseer info screen).
  8. On restart of neovim, overseer will find the targets again, but only once.

Expected Behavior

That the targets from the shared Makefile is available more than once per session.

Minimal example file

Examples

Main Makefile:

include ./subdir/Makefile

main/test:
echo "this is main"

Shared Makefile:

shared/test:
echo "this is shared"

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "stevearc/dressing.nvim", config = true },
  {
    "stevearc/overseer.nvim",
    dependencies = {
	"nvim-telescope/telescope.nvim",
	"stevearc/dressing.nvim",
    },
    config = function()
      require("overseer").setup({})
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

No response

@sieuwerts sieuwerts added the bug Something isn't working label Apr 8, 2024
@NicolasGB
Copy link

Hey! having the exact same problem, when i run a target from a Makefile they all disappear and have to close and open the project again.

Bumping for visibility :D

@stevearc
Copy link
Owner

stevearc commented Jun 6, 2024

I tried the repro that you suggested, but it seems to be working fine for me. Could you create a tiny repo with the Makefiles required to see this issue? Also double check that it happens with the minimal repro.lua file you provided (the current one is missing the plenary dependency, so OverseerRun errors out).

The only thing I can think of that this could be related to is caching. You could try disabling caching with

require("overseer").setup({
  template_cache_threshold = 0,
})

@stevearc stevearc added the question Further information is requested label Jun 6, 2024
@sieuwerts
Copy link
Author

sieuwerts commented Jun 11, 2024

Thank you @stevearc for getting back to me on this, I really want to start using this plugin, it looks amazing. Here is a small repository containing information about how to reproduce the issue and test it. Hopefully it's enough, let me know if there is anything else that you need.

Edit: I tried setting the template_cache_threshold option to 0 but it did not solve my issue.

Thanks ⭐

@github-actions github-actions bot removed the question Further information is requested label Jun 11, 2024
stevearc added a commit that referenced this issue Jun 13, 2024
We also have a function that uses treesitter to parse the Makefile and
get the list of tasks from that, but it doesn't handle the `include`
command mentioned in the issue. The weird flakiness was because on the
first run the pcall to get the parser failed somewhere in _memoize
(which seems like a Neovim bug), so we would fall back to parsing the
output of `make` and actually produce the correct result. On subsequent
runs, the parser would be fetched correctly and so the results would be
missing the included tasks. The only advantage of the treesitter method
is that it's faster, but parsing the output of `make` is fast enough,
and it's better to be correct. We can just get rid of the treesitter
logic entirely and always rely on parsing the output of `make`.
@stevearc
Copy link
Owner

Thanks for the repro repo! It was very helpful; I was able to find the issue right away. Should be fixed now!

@sieuwerts
Copy link
Author

Thank you! Can confirm that it's been resolved. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants