Schniz / fnm

🚀 Fast and simple Node.js version manager, built in Rust
https://fnm.vercel.app
GNU General Public License v3.0
17.99k stars 461 forks source link

Failed to install fnm on M1 #701

Open lencx opened 2 years ago

lencx commented 2 years ago

System

System:
  OS: macOS 12.2.1
  CPU: (8) x64 Apple M1

Install

❯ cargo install fnm
    Updating crates.io index
  Installing fnm v1.29.2
   Compiling libc v0.2.121
   ...
   Compiling reqwest v0.11.10
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "/var/folders/kr/zc5bcm512fz_q1l3cn7mn1y80000gn/T/cargo-installHKCyw2/release/deps/fnm-a559d747324ad05b.fnm.5b596350-cgu.0.rcgu.o"
...
  = note: ld: warning: ignoring file /opt/homebrew/Cellar/xz/5.2.5/lib/liblzma.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
          Undefined symbols for architecture x86_64:
            "_lzma_code", referenced from:
                xz2::stream::Stream::process::h01923b18f94ccbb5 in libxz2-473c87ad6c004cb0.rlib(xz2-473c87ad6c004cb0.xz2.6ea371ad-cgu.10.rcgu.o)
            "_lzma_stream_decoder", referenced from:
                xz2::stream::Stream::new_stream_decoder::h386b68a455b6ff0b in libxz2-473c87ad6c004cb0.rlib(xz2-473c87ad6c004cb0.xz2.6ea371ad-cgu.10.rcgu.o)
            "_lzma_end", referenced from:
                xz2::stream::Stream::new_stream_decoder::h386b68a455b6ff0b in libxz2-473c87ad6c004cb0.rlib(xz2-473c87ad6c004cb0.xz2.6ea371ad-cgu.10.rcgu.o)
                _$LT$xz2..stream..Stream$u20$as$u20$core..ops..drop..Drop$GT$::drop::h55dfc3efbab9b82d in libxz2-473c87ad6c004cb0.rlib(xz2-473c87ad6c004cb0.xz2.6ea371ad-cgu.10.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: failed to compile `fnm v1.29.2`, intermediate artifacts can be found at `/var/folders/kr/zc5bcm512fz_q1l3cn7mn1y80000gn/T/cargo-installHKCyw2`

Caused by:
  could not compile `fnm` due to previous error
❯ curl -fsSL https://fnm.vercel.app/install | bash
Downloading fnm using Homebrew...
Checking dependencies for the installation script...
Checking availability of curl... OK!
Checking availability of unzip... OK!
Checking availability of Homebrew (brew)... OK!
/opt/homebrew/Library/Homebrew/os/mac/version.rb:32:in `block in from_symbol': unknown or unsupported macOS version: :dunno (MacOSVersionError)
    from /opt/homebrew/Library/Homebrew/os/mac/version.rb:32:in `fetch'
    from /opt/homebrew/Library/Homebrew/os/mac/version.rb:32:in `from_symbol'
    from /opt/homebrew/Library/Homebrew/os/mac.rb:28:in `version'
    from /opt/homebrew/Library/Homebrew/os/mac.rb:60:in `prerelease?'
    from /opt/homebrew/Library/Homebrew/os.rb:43:in `<module:OS>'
    from /opt/homebrew/Library/Homebrew/os.rb:7:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/homebrew/Library/Homebrew/global.rb:80:in `<top (required)>'
    from /opt/homebrew/Library/Homebrew/brew.rb:31:in `require_relative'
    from /opt/homebrew/Library/Homebrew/brew.rb:31:in `<main>'
Schniz commented 2 years ago

Is your shell/terminal emulator compiled to ARM? I had the same issues when I first got my M1 and installed Alacritty that was compiled for x86_64

lencx commented 2 years ago

How should I set terminal if I want to install it?

jonahsnider commented 2 years ago

I had the same exact issue when I used the macOS Migration Assistant to move my entire user profile from an Intel MacBook to an M1 MacBook. The solution was to fully reinstall Homebrew and its xz formula, which would use the correct liblzma.dylib file for the computer's CPU architecture (x86_64 to arm64).

cargo_install.log

baobaodu commented 2 years ago

Using a release binary

Schniz commented 2 years ago

Hey there. There isn’t a prebuilt M1 release just yet. Please use homebrew to install fnm on Mac machines