williamboman / mason.nvim

Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters.
Apache License 2.0
7.86k stars 277 forks source link

Using a registry from `file:` fails with a jq-related error #1764

Closed antoineco closed 3 months ago

antoineco commented 3 months ago

I've searched open issues for similar requests

I've recently downloaded the latest plugin version of mason.nvim

Problem description

While following the instructions at mason-registry/CONTRIBUTING.md to add a new package to Mason's registry, I ran into the following error:

Output of :MasonLog:

[ERROR Fri Aug  2 14:30:11 2024] ...nvim/lazy/mason.nvim/lua/mason-registry/sources/file.lua:176: Failed to install registry FileRegistrySource(path=/Users/acotten/git/mason-org/mason-registry). "Failed to parse package YAML: /nix/store/5dsicv93i37c4rqr08r1zdj8dwpa63nj-jq-1.7.1-bin/bin/jq: Unknown option -I0\nUse /nix/store/5dsicv93i37c4rqr08r1zdj8dwpa63nj-jq-1.7.1-bin/bin/jq --help for help with command-line options,\nor see the jq manpage, or online docs  at https://jqlang.github.io/jq\nyq: Error running jq: BrokenPipeError: [Errno 32] Broken pipe.\n"

Neovim error:

Error executing luv callback:
EPIPE
stack traceback:
        [C]: in function 'error'
        ...share/nvim/lazy/mason.nvim/lua/mason-core/async/init.lua:113: in function 'callback'
        ...share/nvim/lazy/mason.nvim/lua/mason-core/async/init.lua:91: in function 'cb'
        ...share/nvim/lazy/mason.nvim/lua/mason-core/async/init.lua:21: in function 'reject'
        ...share/nvim/lazy/mason.nvim/lua/mason-core/async/init.lua:52: in function <...share/nvim/lazy/mason.nvim/lua/mason-core/async/init.lua:50>

Expected behavior

The local registry installation succeeds.

Steps to reproduce

  1. Install jq 1.7.1

  2. Clone https://github.com/mason-org/mason-registry.git

  3. Set up mason.nvim to source its registry from the clone's directory, as documented in mason-registry/CONTRIBUTING.md:

    require("mason").setup {
      registries = {
        "file:/Users/acotten/git/mason-org/mason-registry"
      }
    }

Neovim version (>= 0.7)

NVIM v0.11.0-nightly+9322b7e
Build type: Release
LuaJIT 2.1.1713773202

Operating system/version

Darwin Kernel Version 23.6.0

Healthcheck output

mason: require("mason.health").check()

mason.nvim ~
- OK mason.nvim version v1.10.0
- OK PATH: prepend
- OK Providers: 
    mason.providers.registry-api
    mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries] ~
- ERROR Registry `local: /Users/acotten/git/mason-org/mason-registry [uninstalled]` is not installed.
  - ADVICE:
    - Run :MasonUpdate to install.

mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send`
- WARNING wget: not available
  - ADVICE:
    - spawn: wget failed with exit code - and signal -. wget is not executable
- OK curl: `curl 8.8.0 (aarch64-apple-darwin23.5.0) libcurl/8.8.0 OpenSSL/3.0.14 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0 nghttp2/1.61.0`
- OK gzip: `Apple gzip 430.140.2`
- OK tar: `bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.12 liblzma/5.4.3 bz2lib/1.0.8 `
- OK bash: `GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)`
- OK sh: `Ok`

Screenshots

No response

antoineco commented 3 months ago

I'm confused as to what is causing jq to be involved at all here.

After the lines below, the value of yq is the string "/Users/acotten/.nix-profile/bin/yq": https://github.com/williamboman/mason.nvim/blob/e2f7f9044ec30067bc11800a9e266664b88cda22/lua/mason-registry/sources/file.lua#L76-L79

I can confirm that the executable at that path is indeed yq:

% /Users/acotten/.nix-profile/bin/yq --version
yq 3.4.3

Further inspection of mason-core.spawn inside a.wait() also shows the right command and args: https://github.com/williamboman/mason.nvim/blob/e2f7f9044ec30067bc11800a9e266664b88cda22/lua/mason-core/spawn.lua#L88-L89

{ "/Users/acotten/.nix-profile/bin/yq", {
    args = { "-I0", "-o", "json" },
    stdio_sink = {
      stderr = <function 1>,
      stdout = <function 2>
    }
  }, <function 3> }%
antoineco commented 3 months ago

Now I see what's going on.

% yq --help
usage: yq [options] <jq filter> [input file...]
yq: Command-line YAML processor - jq wrapper for YAML documents

yq transcodes YAML documents to JSON and passes them to jq.
See https://github.com/kislyuk/yq for more information.

There are two yq programs:

I have the wrong one installed.