Skip to content

rustfmt package tries to load non-existing dylib #1386

@knutwalker

Description

@knutwalker

I've searched open issues for similar requests

  • Yes

I've manually reviewed logs to find potential errors

  • Yes

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

  • Yes

Problem description

I'm not entirely sure if this is actually an issue with the Mason package, but this is where my bug hunt ended, so here it is.

Some time recently, the formatting of rust files stopped working, whether it is a manual invocation of vim.lsp.buf.format or via an auto group. I've configured null_ls to do the formatting, but I also installed the rustmft package via Mason.

After some time debugging null_ls, I eventually got this error trace from them

[TRACE Fri Jun 30 12:05:53 2023] /Users/knut/.local/share/nvim/lazy/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:205: error output: dyld[67127]: Library not loaded: @rpath/librustc_driver-df6ae6b885ff3d02.dylib
  Referenced from: <ED438352-C295-373D-8071-02BDBF718EF4> /Users/knut/.local/share/nvim/mason/packages/rustfmt/rustfmt_macos-x86_64_v1.5.2/rustfmt
  Reason: tried: '/usr/local/lib/librustc_driver-df6ae6b885ff3d02.dylib' (no such file), '/usr/lib/librustc_driver-df6ae6b885ff3d02.dylib' (no such file, not in dyld cache)

which I also get when I call the binary directly

$ /Users/knut/.local/share/nvim/mason/packages/rustfmt/rustfmt_macos-x86_64_v1.5.2/rustfmt
dyld[69199]: Library not loaded: @rpath/librustc_driver-df6ae6b885ff3d02.dylib
  Referenced from: <ED438352-C295-373D-8071-02BDBF718EF4> /Users/knut/.local/share/nvim/mason/packages/rustfmt/rustfmt_macos-x86_64_v1.5.2/rustfmt
  Reason: tried: '/usr/local/lib/librustc_driver-df6ae6b885ff3d02.dylib' (no such file), '/usr/lib/librustc_driver-df6ae6b885ff3d02.dylib' (no such file, not in dyld cache)
Abort trap: 6

I then uninstalled the Mason rustfmt package (rustfmt was in my PATH via other means anyways) and with that, formatting works again.

I am on an Apple silicon mac, and the log indicated that a x86 binary of rustfmt is being installed/used by Mason. I would guess that there is some situation where running this binary on aarch64 doesn't work, which means it could very well be a rustfmt issue and nothing related to Mason. Also the rustfmt binary from the rustup toolchain is an aarch64 binary:

$ lipo -archs /Users/knut/.local/share/nvim/mason/packages/rustfmt/rustfmt_macos-x86_64_v1.5.2/rustfmt
x86_64
$ lipo -archs $(which rustfmt)
arm64

The Rosetta translation layer is installed and working otherwise, so maybe for some reason that particular binary is not actually working properly under Rosetta and Mason could try to install the one with the correct architecture instead?

Anyways, formatting now works by uninstalling the formatter package 🙃

Expected behavior

rustfmt to not fail

Steps to reproduce

  1. Have an Apple silicon mac
  2. Install the rustfmt package
  3. Try to use it

Affected packages

rustfmt

Neovim version (>= 0.7)

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.1/share/nvim"

Run :checkhealth for more info

Operating system/version

Darwin River.fritz.box 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000 arm64

Healthcheck

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

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

mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2023-06-30-baggy-video` is installed.

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 7.88.1 (x86_64-apple-darwin22.0) libcurl/7.88.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.0`
- OK gzip: `Apple gzip 403.100.6`
- OK tar: `bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 `
- OK bash: `GNU bash, version 5.2.15(1)-release (aarch64-apple-darwin22.1.0)`
- OK sh: `Ok`

mason.nvim [Languages] ~
- WARNING luarocks: not available
  - ADVICE:
    - spawn: luarocks failed with exit code - and signal -. luarocks is not executable
- WARNING Composer: not available
  - ADVICE:
    - spawn: composer failed with exit code - and signal -. composer is not executable
- OK Go: `go version go1.20.5 darwin/arm64`
- OK Ruby: `ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]`
- OK node: `v20.3.1`
- OK PHP: `PHP 8.2.7 (cli) (built: Jun 20 2023 20:52:12) (NTS)`
- OK cargo: `cargo 1.70.0 (ec8a8a0ca 2023-04-25)`
- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- OK python: `Python 3.11.4`
- OK java: `openjdk version "17.0.7" 2023-04-18`
- OK JAVA_HOME: `openjdk version "17.0.7" 2023-04-18`
- OK RubyGem: `3.0.3.1`
- OK javac: `javac 17.0.7`
- OK npm: `9.6.7`
- OK pip: `pip 23.0.1 from /opt/homebrew/lib/python3.11/site-packages/pip (python 3.11)`
- OK python venv: `Ok`

mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 0. Remaining: 5000. Limit: 5000. Reset: Fri Jun 30 13:33:20 2023.

Screenshots or recordings

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions