drahnr / cargo-spellcheck

Checks all your documentation for spelling and grammar mistakes with hunspell and a nlprule based checker for grammar
Apache License 2.0
314 stars 32 forks source link

Installing the crate in a macbook machine #320

Closed Owen-CH-Leung closed 1 month ago

Owen-CH-Leung commented 5 months ago

I tried to install this crate into my macbook machine following the documentation. So I run:

cargo install --locked cargo-spellcheck

which returned the following error when compiling:

error: failed to run custom build command for `hunspell-sys v0.3.1`

Caused by:
  process didn't exit successfully: `/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-installS4VX2v/release/build/hunspell-sys-2aba3f0e9baf644a/build-script-build` (signal: 6, SIGABRT: process abort signal)
  --- stderr
  dyld[28610]: Library not loaded: @rpath/libclang.dylib
    Referenced from: <4E7CEE65-E915-386C-83A4-83815EA2231B> /private/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-installS4VX2v/release/build/hunspell-sys-2aba3f0e9baf644a/build-script-build
    Reason: tried: '/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-installS4VX2v/release/deps/libclang.dylib' (no such file), '/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-installS4VX2v/release/libclang.dylib' (no such file)

It's complaining that the dynamic linker is unable to locate the libclang.dylib library on the machine. After some googling, I managed to resolve the issue with the following command

export DYLD_FALLBACK_LIBRARY_PATH="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/lib/" && cargo install --locked cargo-spellcheck

I believe we can enrich the installation guide a bit to specify the necessary env variable that needs to be present in order to install the crate successfully (for all the 3 OS: Windows, Linux & Mac).

drahnr commented 5 months ago

I'd be happy to include this as part of the README.md, could you create such a PR?

jgrund commented 4 months ago

On MacOS 14.2, I needed to do the following:

export DYLD_FALLBACK_LIBRARY_PATH="$(xcode-select --print-path)/usr/lib" && cargo install --locked cargo-spellcheck

drahnr commented 4 months ago

@Owen-CH-Leung which OS X version did you test your instructions with? @jgrund I am curious how your setup differs from @Owen-CH-Leung 's

Owen-CH-Leung commented 4 months ago

I tested the instructions with macOs Sonoma 14.1.1

drahnr commented 4 months ago

I tested the instructions with macOs Sonoma 14.1.1

Do @jgrund's instruction work there too?

Owen-CH-Leung commented 4 months ago

No it errors out:

error: failed to run custom build command for `hunspell-sys v0.3.1`

Caused by:
  process didn't exit successfully: `/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-install78RxcC/release/build/hunspell-sys-577c44aadb168bc2/build-script-build` (signal: 6, SIGABRT: process abort signal)
  --- stderr
  dyld[74671]: Library not loaded: @rpath/libclang.dylib
    Referenced from: <0A527F70-81F5-3FEF-B909-A98787A7F277> /private/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-install78RxcC/release/build/hunspell-sys-577c44aadb168bc2/build-script-build
    Reason: tried: '/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-install78RxcC/release/deps/libclang.dylib' (no such file), '/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-install78RxcC/release/libclang.dylib' (no such file), '/opt/homebrew/Cellar/rust/1.76.0/lib/rustlib/aarch64-apple-darwin/lib/libclang.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/usr/lib/libclang.dylib' (no such file)
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-spellcheck v0.13.2`, intermediate artifacts can be found at `/var/folders/0n/fkgm548x15q996h51xlpc2rh0000gn/T/cargo-install78RxcC`.
drahnr commented 4 months ago

@jgrund could you create PR making it per OS X version?

johnsonw commented 2 months ago

I'm on OS X Ventura (13.4) and setting the following environment variable as @jgrund stated worked for me:

export DYLD_FALLBACK_LIBRARY_PATH="$(xcode-select --print-path)/usr/lib"