stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
2.58k stars 136 forks source link

bug: isort command fails with unknown error #406

Open szevzol opened 1 month ago

szevzol commented 1 month ago

Neovim version (nvim -v)

v0.9.5

Operating system/version

Windows Version 10.0.19045 Build 19045

Add the debug logs

Log file

09:15:38[DEBUG] Running formatters on C:\Users\****\projects\isort\isort.py: { "isort" }
09:15:38[INFO] Run isort on C:\Users\****\projects\isort\isort.py
09:15:38[DEBUG] Run command: { "isort", "--stdout", "--line-ending", "\r\n", "--filename", "C:\\Users\\****\\projects\\isort\\isort.py", "-" }
09:15:38[ERROR] Formatter 'isort' error in jobstart: Vim:E903: Process failed to start: unknown error: "C:\Users\****\projects\isort\isort.PY

Describe the bug

When saving the buffer I see the following error:

Error detected while processing BufWritePre Autocommands for "*":

Imports are not change in python file.

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. nvim -u repro.lua isort.py
  2. save file with :w

Expected Behavior

Import statements should be fixed without error

Minimal example file

isort.py:

import os
import sys

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/conform.nvim",
    config = function()
      require("conform").setup({
        log_level = vim.log.levels.DEBUG,
        -- add your config here
        formatters_by_ft = {
            python = { "isort" }
        },
          format_on_save = {
            lsp_fallback = true,
            async = false,
            timeout_ms = 5000,
          },
      })
    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

gennaro-tedesco commented 1 month ago

I am seeing a similar error on a macOS 12.7.4 Monterey, the stacktrace being a little more indicative, and namely:

Formatter 'isort' error in jobstart: Vim:E903: Process failed to start: no such file or directory: "/usr/local/bin/isort"

although the executable is indeed present in the specified location

$ which isort
/usr/local/bin/isort