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

internal ranlib command failed #4380

Closed
QuRyu opened this issue Oct 31, 2018 · 10 comments
Closed

internal ranlib command failed #4380

QuRyu opened this issue Oct 31, 2018 · 10 comments

Comments

@QuRyu
Copy link

QuRyu commented Oct 31, 2018

General summary/comments (optional)

After upgrading the macOS system to the latest version, macOS Mojave, version 10.14, "stack build" does not run properly and reports error "internal ranlib command failed". I am not if this pertains only particularly my laptop or the stack breaks under new system version.

Steps to reproduce

  1. Clone the github repo https://github.com/QuRyu/haskCode and cd pcap.
  2. Run command stack build.

Expected

The build should finish without reporting any error.

Actual

Stack reports "internal ranlib command failed".

$ stack build --verbose
Version 1.9.1, Git revision f9d0042c141660e1d38f797e1d426be4a99b2a3c (6168 commits) x86_64 hpack-0.31.0
2018-10-31 18:35:21.130440: [debug] Checking for project config at: /Users/HereWegoR/Documents/haskCode/pcap/stack.yaml
2018-10-31 18:35:21.131050: [debug] Loading project config file stack.yaml
2018-10-31 18:35:21.132447: [debug] Decoding build plan from: /Users/HereWegoR/.stack/build-plan/lts-10.5.yaml
2018-10-31 18:35:21.132514: [debug] Trying to decode /Users/HereWegoR/.stack/build-plan-cache/lts-10.5.cache
2018-10-31 18:35:21.137630: [debug] Success decoding /Users/HereWegoR/.stack/build-plan-cache/lts-10.5.cache
2018-10-31 18:35:21.138874: [debug] Potential GHC builds: standard
2018-10-31 18:35:21.138966: [debug] Found already installed GHC builds: standard
2018-10-31 18:35:21.139384: [debug] Getting global package database location
2018-10-31 18:35:21.139627: [debug] Getting Cabal package version
2018-10-31 18:35:21.139682: [debug] Run process: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db list --global
2018-10-31 18:35:21.140233: [debug] Asking GHC for its version
2018-10-31 18:35:21.140486: [debug] Run process: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2018-10-31 18:35:21.141566: [debug] Run process: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc --numeric-version
2018-10-31 18:35:21.186874: [debug] Process finished in 47ms: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db list --global
2018-10-31 18:35:21.187296: [debug] Process finished in 47ms: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2018-10-31 18:35:21.211152: [debug] Process finished in 56ms: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc --numeric-version
2018-10-31 18:35:21.211265: [debug] GHC version is: ghc-8.2.2
2018-10-31 18:35:21.211328: [debug] Resolving package entries
2018-10-31 18:35:21.211423: [debug] Trying to decode /Users/HereWegoR/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.2.2/lts-10.5.cache
2018-10-31 18:35:21.255351: [debug] Success decoding /Users/HereWegoR/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.2.2/lts-10.5.cache
2018-10-31 18:35:21.255766: [debug] Starting to execute command inside EnvConfig
2018-10-31 18:35:21.255825: [debug] Parsing the targets
2018-10-31 18:35:21.256081: [debug] Running hpack on /Users/HereWegoR/Documents/haskCode/pcap/package.yaml
2018-10-31 18:35:21.260257: [debug] hpack output unchanged in /Users/HereWegoR/Documents/haskCode/pcap/pcapp.cabal
2018-10-31 18:35:21.262680: [debug] Trying to decode /Users/HereWegoR/.stack/indices/Hackage/01-index.cache
2018-10-31 18:35:21.466090: [debug] Success decoding /Users/HereWegoR/.stack/indices/Hackage/01-index.cache
2018-10-31 18:35:21.487962: [debug] Start: getPackageFiles /Users/HereWegoR/Documents/haskCode/pcap/pcapp.cabal
2018-10-31 18:35:21.492883: [debug] Finished in 5ms: getPackageFiles /Users/HereWegoR/Documents/haskCode/pcap/pcapp.cabal
2018-10-31 18:35:21.494009: [debug] Finding out which packages are already installed
2018-10-31 18:35:21.494650: [debug] Run process: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
2018-10-31 18:35:21.551589: [debug] Process finished in 57ms: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
2018-10-31 18:35:21.552099: [debug] Ignoring package haskeline due to wanting version 0.7.4.2 instead of 0.7.4.0
2018-10-31 18:35:21.552672: [debug] Ignoring package Cabal due to wanting version 2.0.1.1 instead of 2.0.1.0
2018-10-31 18:35:21.552808: [debug] Run process: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --user --no-user-package-db --package-db /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-10.5/8.2.2/pkgdb dump --expand-pkgroot
2018-10-31 18:35:21.683875: [debug] Process finished in 131ms: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --user --no-user-package-db --package-db /Users/HereWegoR/.stack/snapshots/x86_64-osx/lts-10.5/8.2.2/pkgdb dump --expand-pkgroot
2018-10-31 18:35:21.686321: [debug] Run process: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --user --no-user-package-db --package-db /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/install/x86_64-osx/lts-10.5/8.2.2/pkgdb dump --expand-pkgroot
2018-10-31 18:35:21.734539: [debug] Process finished in 48ms: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --user --no-user-package-db --package-db /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/install/x86_64-osx/lts-10.5/8.2.2/pkgdb dump --expand-pkgroot
2018-10-31 18:35:21.735582: [debug] Constructing the build plan
2018-10-31 18:35:21.739362: [debug] Checking if we are going to build multiple executables with the same name
2018-10-31 18:35:21.740738: [debug] Executing the build plan
2018-10-31 18:35:21.746010: [debug] Getting global package database location
2018-10-31 18:35:21.746159: [debug] Run process: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db list --global
2018-10-31 18:35:21.789353: [debug] Process finished in 43ms: /Users/HereWegoR/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db list --global
2018-10-31 18:35:21.792434: [info] Building all executables for `pcapp' once. After a successful build of all of them, only specified executables will be rebuilt.
2018-10-31 18:35:21.795844: [debug] Encoding /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/stack-build-caches/lib
2018-10-31 18:35:21.797156: [debug] Finished writing /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/stack-build-caches/lib
2018-10-31 18:35:21.797349: [debug] Encoding /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/stack-build-caches/exe-pcap-exe
2018-10-31 18:35:21.797769: [debug] Finished writing /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/stack-build-caches/exe-pcap-exe
2018-10-31 18:35:21.797839: [info] pcapp-0.1.0.0: build (lib + exe)
2018-10-31 18:35:21.798391: [debug] Run process within /Users/HereWegoR/Documents/haskCode/pcap/: /Users/HereWegoR/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.0.1.0 build lib:pcapp exe:pcap-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
2018-10-31 18:35:22.011856: [info] Preprocessing library for pcapp-0.1.0.0..
2018-10-31 18:35:22.011973: [info] Building library for pcapp-0.1.0.0..
2018-10-31 18:35:23.399841: [warn] /opt/local/bin/ranlib: object: .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/objs-23564/libHSpcapp-0.1.0.0-5U1ulv6lh1u1l1URP4OoiW.a(Lib.o) malformed object (unknown load command 1)
2018-10-31 18:35:23.400202: [warn] /opt/local/bin/ar: internal ranlib command failed
2018-10-31 18:35:23.415644: [debug] Start: getPackageFiles /Users/HereWegoR/Documents/haskCode/pcap/pcapp.cabal
2018-10-31 18:35:23.421104: [debug] Finished in 5ms: getPackageFiles /Users/HereWegoR/Documents/haskCode/pcap/pcapp.cabal
2018-10-31 18:35:23.421282: [debug] Encoding /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/stack-build-caches/lib
2018-10-31 18:35:23.421686: [debug] Finished writing /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/stack-build-caches/lib
2018-10-31 18:35:23.421767: [debug] Encoding /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/stack-build-caches/exe-pcap-exe
2018-10-31 18:35:23.422085: [debug] Finished writing /Users/HereWegoR/Documents/haskCode/pcap/.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/stack-build-caches/exe-pcap-exe

--  While building package pcapp-0.1.0.0 using:
      /Users/HereWegoR/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.0.1.0 build lib:pcapp exe:pcap-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Stack version

$ stack --version
Version 1.9.1, Git revision f9d0042c141660e1d38f797e1d426be4a99b2a3c (6168 commits) x86_64 hpack-0.31.0

Ranlib version

$ ranlib -V
Apple Inc. version cctools-895

Method of installation

  • Official binary, downloaded from stackage.org or fpcomplete's package repository
@koyedele
Copy link

koyedele commented Nov 1, 2018

@QuRyu From your logs, I can see:

2018-10-31 18:35:23.399841: [warn] /opt/local/bin/ranlib: object: .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/objs-23564/libHSpcapp-0.1.0.0-5U1ulv6lh1u1l1URP4OoiW.a(Lib.o) malformed object (unknown load command 1)
2018-10-31 18:35:23.400202: [warn] /opt/local/bin/ar: internal ranlib command failed

Do you have ar and ranlib installed in /opt/local/bin and are those the correct binaries?

I ran into a similar issue. In my case, Homebrew had installed binutils in /usr/local/bin for some unknown reason and so ar got resolved to /usr/local/bin/ar which is not the same as the Apple-installed /usr/bin/ar.

@QuRyu
Copy link
Author

QuRyu commented Nov 1, 2018

@QuRyu From your logs, I can see:

2018-10-31 18:35:23.399841: [warn] /opt/local/bin/ranlib: object: .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/objs-23564/libHSpcapp-0.1.0.0-5U1ulv6lh1u1l1URP4OoiW.a(Lib.o) malformed object (unknown load command 1)
2018-10-31 18:35:23.400202: [warn] /opt/local/bin/ar: internal ranlib command failed

Do you have ar and ranlib installed in /opt/local/bin and are those the correct binaries?

I ran into a similar issue. In my case, Homebrew had installed binutils in /usr/local/bin for some unknown reason and so ar got resolved to /usr/local/bin/ar which is not the same as the Apple-installed /usr/bin/ar.

Hi @koyedele, ar is present in my /opt/local/bin, and it was installed there long before the problem occurred.

> la ar
-r-xr-xr-x  1 root  admin    32K Jan 23  2018 ar

It seems this ar is not linked to any other ar.

@koyedele
Copy link

koyedele commented Nov 2, 2018

@QuRyu, but do you also have Apple's ar and ranlib installed in /usr/bin/ar and /usr/bin/ranlib? From the logs, it appears that using /opt/local/bin/ar is failing. How about you temporarily remove those files from your $PATH and try to run your build with the stock ar and ranlib and see what happens? Since you just upgraded to Mojave, don't forget to run xcode-select --install to install the latest tools before trying stack build again.

@bonsalldavid
Copy link

Did you find a solution to this? I'm getting the same error when trying to install Apache tomcat

@mattaudesse
Copy link
Member

@QuRyu are you using macports? This sounds like it could be caused by an incomplete migration. These binaries likely need to be rebuilt/relinked. @koyedele is probably onto something with his question about xcode-select --install too - that's a necessary step whenever upgrading macOS distributions if you're using macports.

@bonsalldavid same question I guess - are you using macports but haven't completed the migration? We're probably not the best place to ask about Apache tomcat but if that's the issue then great :-)

@QuRyu
Copy link
Author

QuRyu commented Nov 16, 2018

Sorry to reply late. I had been busy these two weeks with school work.

@koyedele How should I do that? I tried to set the $PATH variable without /opt/local/bin but the stack keeps using the one from /opt/local/bin. I did run xcode-select --install but it doesn't help.

@mattaudesse I uninstalled macports a while ago, without cleaning up all the links and files. Would reinstalling macports and completing the migration process help?

@mattaudesse
Copy link
Member

Hey @QuRyu, no worries - school obviously has to take priority!

Reinstalling macports might help but if you don't want it on your system anymore you could probably just move the binaries that are causing you trouble, e.g.:

$ sudo mv /opt/local/bin/ranlib /opt/local/bin/ranlib-backup-2018-11-16
$ sudo mv /opt/local/bin/ar     /opt/local/bin/ar-backup-2018-11-16

# I'd recommend deleting `.stack-work` from your project directory too:
$ rm -r .stack-work

# Hopefully this completes successfully now
$ stack build

That may not be 100% sufficient but I suspect it'll at least help you get further along - good luck and please let us know either way.

Also, I'm going to go ahead and close this issue since it's not strictly stack-related, but feel free to continue the thread until your builds are working.

@QuRyu
Copy link
Author

QuRyu commented Nov 19, 2018

@mattaudesse Thank you so much! Now stack is running properly.

@lood339
Copy link

lood339 commented Dec 28, 2018

@mattaudesse The method of delete ranlib and ar works for me. My case is not the exactly the same as the original problem, but it is similar (upgrade Mac os to Majave then run something requires libtool).

@chrislconover
Copy link

@QuRyu From your logs, I can see:

2018-10-31 18:35:23.399841: [warn] /opt/local/bin/ranlib: object: .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/objs-23564/libHSpcapp-0.1.0.0-5U1ulv6lh1u1l1URP4OoiW.a(Lib.o) malformed object (unknown load command 1)
2018-10-31 18:35:23.400202: [warn] /opt/local/bin/ar: internal ranlib command failed

Do you have ar and ranlib installed in /opt/local/bin and are those the correct binaries?

I ran into a similar issue. In my case, Homebrew had installed binutils in /usr/local/bin for some unknown reason and so ar got resolved to /usr/local/bin/ar which is not the same as the Apple-installed /usr/bin/ar.

This was my case as well, I had to run brew uninstall cctools

Thanks!

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

7 participants