12

I want to run a web server with Rust and Actix-Web. After following these steps of their documentation everything works as expected: the server runs on port 8080.

The problem I have is that VSCode shows errors

Screenshot from VSCode with errors

This error message is shown in the tooltip upon hovering the error in the IDE

proc macro main not expanded: Cannot create expander for /Users/name/Documents/projects/project-rust/target/debug/deps/libactix_web_codegen-b262af45f63000f3.dylib: Io(Custom { kind: InvalidData, error: DlOpen { desc: "dlopen(/Users/name/Documents/projects/project-rust/target/debug/deps/libactix_web_codegen-b262af45f63000f3.dylib, 0x000A): tried: '/Users/name/Documents/projects/project-rust/target/debug/deps/libactix_web_codegen-b262af45f63000f3.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/libactix_web_codegen-b262af45f63000f3.dylib' (no such file), '/usr/lib/libactix_web_codegen-b262af45f63000f3.dylib' (no such file)" } })

Environemnt - macOS Monterey 12.1 (M1)

rioV8
  • 24,506
  • 3
  • 32
  • 49
Roman Mahotskyi
  • 4,576
  • 5
  • 35
  • 68
  • 2
    See [this rust-analyzer issue](https://github.com/rust-lang/rust-analyzer/issues/12525). Based on the error message it might be that you're running x86 VSCode but your code is being compiled to arm64. – smitop Jun 23 '22 at 15:20
  • I understand that its annoying, but maybe sometimes its OK to just ignore the errors reported by the VSCode while the codebase compiles flawlessly. FWIW, I also read the answer & it fixed my issue. – behkod Feb 17 '23 at 21:52

2 Answers2

9

VS Code


Thanks, @Smitop for the tip

I reinstalled VSCode with universal build and the errors are gone

enter image description here

P.S. I tried to install the build for Apple Silicon, but it didn't help

NVIM (macOS, arm64, m1)


For those experiencing the same issue in NeoVim, the following steps helped resolve the errors.

  1. Open a terminal
  2. Execute rustup toolchain list

It should print

stable-aarch64-apple-darwin (default)
stable-x86_64-apple-darwin 
  1. Copy the stable-x86_64-apple-darwin and make it default, by using rustup default stable-x86_64-apple-darwin
  2. Re-open NeoVim.
  3. Errors should disappear
Roman Mahotskyi
  • 4,576
  • 5
  • 35
  • 68
5

For me, reinstalling VS Code was not necessary:

  • Go into plugin settings in VSCode, uninstall the Rust-Analyzer plugin
  • Restart VS Code
  • Reinstall Rust-Analyser

The restart was necessary for me, because otherwise reinstallation would fail.

Uwe Pachler
  • 51
  • 1
  • 3