Skip to content

bug: format command error in ruff v0.9.7 #664

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

Closed
2 tasks done
A-caibird opened this issue Mar 3, 2025 · 2 comments
Closed
2 tasks done

bug: format command error in ruff v0.9.7 #664

A-caibird opened this issue Mar 3, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@A-caibird
Copy link

Neovim version (nvim -v)

nvim v0.10.4

Operating system/version

MacOS 15.1

Read debugging tips

Add the debug logs

  • I have set log_level = vim.log.levels.DEBUG and pasted the log contents below.

Log file

      2025-03-03 15:52:52[INFO] Run ruff on /Users/acaibird/Documents/python/Fastapi/main.py
      2025-03-03 15:52:52[DEBUG] Run command: { "/opt/homebrew/bin/ruff", "check", "--fix", "--force-exclude", "--exit-zero", "--no-cache", "--stdin-filename", "/Users/acaibird/Documents/python/Fastapi/main.py", "-" }
      2025-03-03 15:52:52[DEBUG] Run default CWD: /Users/acaibird/Documents/python/Fastapi
      2025-03-03 15:52:52[DEBUG] ruff exited with code 0

Describe the bug

can not use ruff to format python file, but black ok. I think it's the wrong command to call ruff to format, in ruff 0.9.7 it should be ruff format, but I didn't find it

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. using ruff v0.9.7
  2. modify python file, and save it

Expected Behavior

get formated code,

Minimal example file

require("conform").setup({
  formatters_by_ft = {
    lua = { "stylua" },
    -- Conform will run multiple formatters sequentially
    python = { "ruff" },
    -- You can customize some of the format options for the filetype (:help conform.format)
    rust = { "rustfmt", lsp_format = "fallback" },
    -- Conform will run the first available formatter
    javascript = { "biome", "prettierd", "prettier", stop_after_first = true },
    css = { "biome", "prettier" },
    scss = { "biome", "prettier" },
    go = { "gofmt", "golines" },
    json = { "biome", "prettier" },
  },
  format_on_save = {
    -- These options will be passed to conform.format()
    timeout_ms = 500,
    lsp_format = "fallback",
  },
  log_level = vim.log.levels.DEBUG,
})

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
      })
    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

@A-caibird A-caibird added the bug Something isn't working label Mar 3, 2025
@stevearc
Copy link
Owner

stevearc commented Mar 5, 2025

There are two formatters for ruff: ruff_fix which runs ruff check --fix and ruff_format which runs ruff format. The bare ruff formatter is deprecated and aliases to ruff_fix.

@stevearc stevearc closed this as completed Mar 5, 2025
@A-caibird
Copy link
Author

@stevearc thanks, it's all sorted now!

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

2 participants