harrisoncramer / gitlab.nvim

Create, review, and manage Gitlab reources without leaving Neovim
MIT License
245 stars 34 forks source link

Plugin fails to build #390

Open kostya9 opened 1 week ago

kostya9 commented 1 week ago

Prerequsities

Setup Configuration and Environment

return {
    "harrisoncramer/gitlab.nvim",
    dependencies = {
        "MunifTanjim/nui.nvim",
        "nvim-lua/plenary.nvim",
        "sindrets/diffview.nvim",
        "stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
        "nvim-tree/nvim-web-devicons" -- Recommended but not required. Icons in discussion tree.
    },
    enabled = true,
    build = function() require("gitlab.server").build(true) end, -- Builds the Go binary
    config = function()
        require("gitlab").setup({
            debug = {
                request=true,
                response=true,
                gitlab_request=true,
                gitlab_response=true,
            },
            log_path = "D:/gitlab.nvim.log"

        })
    end,
}

OS: Windows

Bug Description

When installing the plugin, it does not build the server binary. At the same time, building manually via go build -o bin.exe works (running in gitlab.nvim/cmd directory).

My hypothesis: it tries to build the binary in the wrong directory.

Reproduction Steps

  1. Check out the feature branch
  2. Open Neovim
  3. Observe error:
    Could not install gitlab.nvim!
  4. Observe that there is no binary bin.exe in gitlab.nvim folder.

Screenshots

image

harrisoncramer commented 1 week ago

Interesting. I'm not a Windows user so this would be hard for me to debug, as you've already determined there's something going wrong here:

  local file_path = u.current_file_path()
  local parent_dir = vim.fn.fnamemodify(file_path, ":h:h:h:h")
  state.settings.bin_path = parent_dir
  state.settings.bin = parent_dir .. (u.is_windows() and "\\bin.exe" or "/bin")

  if not override then
    local binary_exists = vim.loop.fs_stat(state.settings.bin)
    if binary_exists ~= nil then
      return
    end
  end

  local cmd = u.is_windows() and "cd %s\\cmd && go build -o bin.exe && move bin.exe ..\\"
    or "cd %s/cmd && go build -o bin && mv bin ../bin"

  local command = string.format(cmd, state.settings.bin_path)
  local null = u.is_windows() and " >NUL" or " > /dev/null"

  -- If you add this line we can see the command that's actually being run
  print(command .. null)

  local installCode = os.execute(command .. null)
  if installCode ~= 0 then
    u.notify("Could not install gitlab.nvim!", vim.log.levels.ERROR)
    return false
  end
  u.notify("Gitlab.nvim installed successfully!", vim.log.levels.INFO)
  return true

To debug this, I'd probably want to know the exact command the plugin is trying to run. You can see that if you change into the plugin directory and edit that function in lua/gitlab/server.lua to add a print before the command is actually executed.

To find the source code for this plugin, run the following ex command to see where the plugins are on your system. Then change into your Lazy directory, and into the Gitlab directory:

:lua=vim.fn.stdpath("data") # And then switch into lazy, gitlab.nvim...
harrisoncramer commented 1 week ago

This is something to do with your setup, if you're able to post more information about the command that's actually running and further debug that Lua file, that'd be great.

With an EC2 instance running Windows and with the basic requirements needed for this plugin (Lazy, Neovim, Go, and the bare bones configuration from the Readme), the plugin created and moved the bin.exe in the correct location and everything worked as expected for me.