macOS下stack ghci出现不兼容GHC选项问题求助
stack ghci on High Sierra Hey there! Let's dig into why you're hitting those stubborn warnings when running stack ghci with your setup—MacBook High Sierra, Stack 1.6.3, and the default project using lts-10.5. These issues are pretty common with older Stack/resolver combos on that OS, so here are the most likely culprits:
Common Causes
Stack-resolver compatibility quirks
Stack 1.6.3 is a relatively old release (circa 2018), and while it technically supports lts-10.5 (which uses GHC 8.2.2), there are small bugs in dependency resolution and system library handling that can trigger warnings. High Sierra's system libraries (like libc) have subtle differences from what the precompiled GHC binaries in Stack 1.6.3 were built against, leading to load-time warnings.Deprecated dependencies in the default template
The lts-10.5 default project template relies on some packages or functions that were already marked as deprecated by that point. For example, certain utilities in thebaselibrary or older versions of helper packages likemtlmight have known deprecation warnings that Stack surfaces during the build/ghci launch.High Sierra's security restrictions
System Integrity Protection (SIP) on High Sierra can interfere with how Stack loads shared libraries from its local cache. This might lead to warnings about missing or incompatible libraries, even though the dependencies are technically installed.Corrupted Stack cache
Over time, your local Stack cache (~/.stack) can get corrupted—maybe from interrupted downloads or version mismatches. This causes Stack to misresolve dependencies, resulting in unexpected warnings.
Fixes to Try
Upgrade Stack (if possible)
Even a small upgrade to a newer Stack version (like 1.9.x or early 2.x releases, which still support lts-10.5) can patch those compatibility bugs. Runstack upgradeif your current version supports it, or grab a compatible binary and replace your existing installation.Get verbose logs to pinpoint the issue
Runstack ghci --verboseto see exactly which package or step is triggering the warning. This will help you narrow down whether it's a deprecation, library load issue, or something else.Clean and rebuild the cache
Wipe out the corrupted cache with these steps:stack clean --full rm -rf ~/.stack/indices ~/.stack/packages stack build stack ghciThis forces Stack to re-download all dependencies from scratch, which often resolves cache-related warnings.
Switch to a more compatible resolver
If upgrading Stack isn't an option, try a resolver that's a better match for Stack 1.6.3. lts-9.x (e.g., lts-9.21, which uses GHC 8.0.2) was released around the same time as Stack 1.6.3 and has fewer compatibility hiccups. Edit your project'sstack.yamlto change the resolver line, then rebuild.
内容的提问来源于stack exchange,提问作者Arkady Rost

