Skip to content

MasonInstallAll Command not found in headless #507

@ahmad9059

Description

@ahmad9059

Title: Unable to exit Neovim headless mode after nvchad.mason.install_all() finishes

Description:
I am trying to automate installing all Mason packages defined in M.mason.ensure_installed as well as LSPs defined in .config/nvim/lua/configs/lspconfig.lua and formatters in .config/nvim/lua/configs/conform.lua.

When I run inside Neovim:

:MasonInstallAll

everything works fine.

However, I want to run this in headless mode for automation (as part of my setup script) and ran into two problems:

  1. Running the direct command:
nvim --headless -c "MasonInstallAll" -c "quitall"

fails with:

E492: Not an editor command: MasonInstallAll%
  1. Running the Lua method works:
nvim --headless +"lua require('nvchad.mason').install_all()" +"autocmd User MasonUpdateAllComplete qa"

This successfully installs all packages, but Neovim stays stuck in headless mode after installation finishes. I expected it to quit automatically.

Full script I am using:

#!/bin/bash
set -e

# Step 1: Bootstrap NvChad
nvim --headless -c 'qa'

# Step 2: Sync Lazy.nvim plugins
nvim --headless -c 'Lazy sync' -c 'qa'

# Step 3: Install Mason packages
nvim --headless +"lua require('nvchad.mason').install_all()" +"autocmd User MasonUpdateAllComplete qa"

echo -e "\nNvChad, plugins, and Mason packages installed successfully!"

Expected behavior:
Neovim should quit automatically after Mason finishes installing all packages in headless mode.

Actual behavior:
It installs everything but does not exit headless mode, leaving the process hanging.

Environment:


If you want, I can also rewrite it so it includes the exact install list from lspconfig.lua and conform.lua for clarity before posting. This might help maintainers reproduce your case faster. Do you want me to do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions