Skip to content
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

rustfmt package tries to load non-existing dylib #1386

Closed
3 tasks done
knutwalker opened this issue Jun 30, 2023 · 4 comments
Closed
3 tasks done

rustfmt package tries to load non-existing dylib #1386

knutwalker opened this issue Jun 30, 2023 · 4 comments

Comments

@knutwalker
Copy link

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

@bluthej
Copy link

bluthej commented Jul 2, 2023

I'm having the same issue on archlinux with an AMD processor so it might not be related to Apple silicon stuff. Here is my log:

[TRACE dim. 02 juil. 2023 11:56:46] /home/joffrey/.local/share/nvim/site/pack/packer/start/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:205: error output: /home/joffrey/.local/share/nvim/mason/bin/rustfmt: error while loading shared libraries: librustc_driver-5d7211076ef5de36.so: cannot open shared object file: No such file or directory

I had to remove the rustfmt Mason package to get formatting to work again.

I'm also using NVIM v0.9.1

@williamboman
Copy link
Owner

It seems like the release binaries for >=1.5.3 started dynamically linking to rust libraries (librustc_driver and libstd) and assumes these exist in your library path. I don't believe this is intentional as these libraries don't have stable ABIs and would require users to have the same rustc toolchain version installed as the one used to build the binaries. I've asked for more information here.

I'm certainly not aware of rustfmt internals, but I have a feeling the best practice is to install it via rustup component add rustfmt to ensure it's targeting your local toolchain version and ABIs.

@benediktms
Copy link

I'm having the exact same issue, removing rust-fmt from mason things started to work again. My version of rust-fmt was installed via rustup as well... Does mason install a binary?

@williamboman
Copy link
Owner

Resolved in mason-org/mason-registry#2059 and #1391.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants