eatgrass / maven.nvim

for java developer, interactively execute maven command without leaving your editor
MIT License
22 stars 1 forks source link

Error launching Maven command #1

Open TheRustifyer opened 7 months ago

TheRustifyer commented 7 months ago

Hello!

I instaled today the plugin, with lazy. This is my config:

    {
        'eatgrass/maven.nvim',
        cmd = { 'Maven', 'MavenExec' },
        dependencies = 'nvim-lua/plenary.nvim',
        config = function()
            require('maven').setup({
                executable = 'mvn', -- `mvn` should be in your `PATH`, or the path to the maven exectable
                -- TODO: since I just use Java in my job, and all the projects has literally the same structure,
                -- I could use for a while the assumption that the mvn project root (root pom.xml) is under /code
                -- but it could be nicer if I can dynamically load this option from a configuration file
                cwd = vim.fn.getcwd() .. '\\code', -- work directory, default to `vim.fn.getcwd()`
                settings = nil, -- specify the settings file or use the default settings
                commands = { -- add custom goals to the command list
                    { cmd = { 'clean', 'compile' }, desc = 'clean then compile' },
                    { cmd = { 'clean', 'install' }, desc = 'clean then install' },
                    { cmd = { 'clean', 'package' }, desc = 'clean then package' },
                },
            })
        end
    },

I am facing the following error:

Error executing vim.schedule lua callback: ...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:405: Failed to spawn process: {                                                                             _additional_on_exit_callbacks = {},                                                                                                                                                                              _raw_cwd = "[obscured Windows path]\\code",                                                                                                                            _shutdown_check = <userdata 1>,                                                                                                                                                                                  _stderr_results = {},                                                                                                                                                                                            _stdout_results = {},                                                                                                                                                                                            _user_on_stderr = <function 1>,                                                                                                                                                                                  _user_on_stdout = <function 2>,                                                                                                                                                                                  args = { "validate" },                                                                                                                                                                                           command = "mvn",                                                                                                                                                                                                 enable_handlers = true,                                                                                                                                                                                          interactive = true,                                                                                                                                                                                              pid = "ENOENT: no such file or directory",                                                                                                                                                                       stderr = <userdata 2>,                                                                                                                                                                                           stdin = <userdata 3>,                                                                                                                                                                                            stdout = <userdata 4>,                                                                                                                                                                                           user_data = {},                                                                                                                                                                                                  <metatable> = <1>{                                                                                                                                                                                                 __index = <table 1>,                                                                                                                                                                                             _create_uv_options = <function 3>,                                                                                                                                                                               _execute = <function 4>,                                                                                                                                                                                         _pipes_are_closed = <function 5>,                                                                                                                                                                                _prepare_pipes = <function 6>,                                                                                                                                                                                   _reset = <function 7>,                                                                                                                                                                                           _shutdown = <function 8>,                                                                                                                                                                                        _stop = <function 9>,                                                                                                                                                                                            add_on_exit_callback = <function 10>,                                                                                                                                                                            after = <function 11>,                                                                                                                                                                                           after_failure = <function 12>,                                                                                                                                                                                   after_success = <function 13>,                                                                                                                                                                                   and_then = <function 14>,                                                                                                                                                                                        and_then_on_failure = <function 15>,                                                                                                                                                                             and_then_on_failure_wrap = <function 16>,                                                                                                                                                                        and_then_on_success = <function 17>,                                                                                                                                                                             and_then_on_success_wrap = <function 18>,                                                                                                                                                                        and_then_wrap = <function 19>,                                                                                                                                                                                   chain = <function 20>,                                                                                                                                                                                           chain_status = <function 21>,                                                                                                                                                                                    co_wait = <function 22>,                                                                                                                                                                                         is_job = <function 23>,                                                                                                                                                                                          join = <function 24>,                                                                                                                                                                                            new = <function 25>,                                                                                                                                                                                             pid = <function 26>,                                                                                                                                                                                             result = <function 27>,                                                                                                                                                                                          send = <function 28>,                                                                                                                                                                                            shutdown = <function 29>,                                                                                                                                                                                        start = <function 30>,                                                                                                                                                                                           stderr_result = <function 31>,                                                                                                                                                                                   sync = <function 32>,                                                                                                                                                                                            wait = <function 33>                                                                                                                                                                                           }                                                                                                                                                                                                              }                                                                                                                                                                                                                stack traceback:                                                                                                                                                                                                         ...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:405: in function '_execute'                                                                                                                          ...ta/Local/nvim-data/lazy/plenary.nvim/lua/plenary/job.lua:448: in function 'start'                                                                                                                             ...pData/Local/nvim-data/lazy/maven.nvim/lua/maven/init.lua:96: in function 'execute_command'

And after the error, when I try to close the opened buffer by the plugin:

Error detected while processing BufLeave Autocommands for "maven":                                                                                                                                               Error executing lua callback: ...pData/Local/nvim-data/lazy/maven.nvim/lua/maven/view.lua:91: bad argument #1 to 'kill' (number expected, got string)                                                            stack traceback:                                                                                                                                                                                                         [C]: in function 'kill'                                                                                                                                                                                          ...pData/Local/nvim-data/lazy/maven.nvim/lua/maven/view.lua:91: in function <...pData/Local/nvim-data/lazy/maven.nvim/lua/maven/view.lua:89> 

I use mostly Java only on my company, in a Windows 11 machine, and they are all Java Maven based projects (almost them multimodule projects).

Java and Maven are correctly on path.

Java version is 17 (17.0.8) and Maven is in the 3.9.5 version.

I also tried to change the path to some directory that doesn't contains any pom.xml, and I received a nice Vim notification telling me that such directory doesn't contains any pom.xml.

But when I point to the directory where's the main pom.xml of the project lives, the first error that I paste is the one that's triggered, but as a runtime error (not a notification).

I am missing something in my configuration?

Thanks.

PD: Maybe this part is where I am failing?

command = "mvn"
enable_handlers = true
interactive = true                                                                                                                                                                           
pid = "ENOENT: no such file or directory"
sselesstin commented 1 month ago

I experienced the same issue and was able to resolve it by specifying the full path to the executable.