Force `stack` to rebuild an installed package

后端 未结 1 816
野趣味
野趣味 2020-12-31 10:52

I often install a package which depends on external libraries and manage to move those external libraries to other locations afterwards, so that compiled programs exit with

相关标签:
1条回答
  • 2020-12-31 11:09

    Update:

    Based on @Michael Snoyman's comment just using this command should be enough to remove the package:

    stack exec -- ghc-pkg unregister --force regex-pcre
    

    Original Answer:

    I don't know if it's the sanctioned way to do it, but it seems to work. Here is a synopsis:

    1. Locate the ghc-pkg program for the version of GHC you are using
    2. Locate the package-db directory for your resolver version
    3. Run $ghcpkg --package-db $pkgdb unregister --force <package>
    4. Also remove the package file from stack's precompiled directory

    Suppose the package we want to remove is zlib-0.5.4.2.

    Locating ghc-pkg

    Under ~/.stack/programs find the ghc-pkg program appropriate for your compiler version, e.g. ~/.stack/programs/x86_64-osx/ghc-7.10.2/bin/ghc-pkg. Call this $ghcpkg

    Locating the package db

    Under ~/.stack/snapshots find the pkgdb directory for the resolver you are using, e.g. ~/.stack/snapshots/x86_64-osx/lts-3.1/7.10.2/pkgdb. Call this $pkgdb.

    Unregister the package

    Run:

    $ghcpkg --package-db $pkgdb unregister --force zlib-0.5.4.2
    

    Ignore any warnings about broken or breaking packages.

    You can check to see if your package is registered or not with this command:

    $ghcpkg --package-db $pkgdb list | grep zlib
    

    Remove the package from the precompiled directory

    Under ~/.stack/precompiled locate any directories named zlib-0.5.4.2 and remove the one for your the relevant version of GHC:

    find ~/.stack/precompiled -name 'zlib-*'
    /bin/rm -rf ...
    

    Reinstall the package

    stack --resolver=... install zlib
    

    Stack should report that it is rebuilding the package.

    0 讨论(0)
提交回复
热议问题