Stack: `stack solver` gets caught on infinite symlink loops

Created on 31 Jan 2018  路  6Comments  路  Source: commercialhaskell/stack

General summary/comments

On macOS, stack solver appears to choke on symlinks under ~/Library/Application Support that point to parent directories. I encountered this with a symlink created by Steam that looks like this:

~/Library/Application Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/Frameworks/Steam Helper EH.app/Contents/Frameworks -> ../../../Frameworks

I couldn't reproduce this by adding my own circular symlink in ~/Library/Application Support.

Steps to reproduce

On macOS:

  1. Install Steam (or presumably create a similar directory structure although I couldn't reproduce it this way).
  2. Run stack solver.

Expected

stack only follows a particular symlink once.

Actual

stack may follow the same symlink endlessly.

$ stack solver -v
Version 1.6.3 x86_64 hpack-0.20.0
2018-01-31 15:16:36.602569: [debug] Checking for project config at: /Users/khouli/stack.yaml
@(Stack/Config.hs:842:9)
2018-01-31 15:16:36.603219: [debug] Checking for project config at: /Users/stack.yaml
@(Stack/Config.hs:842:9)
2018-01-31 15:16:36.603344: [debug] Checking for project config at: /stack.yaml
@(Stack/Config.hs:842:9)
2018-01-31 15:16:36.603413: [debug] No project config file found, using defaults.
@(Stack/Config.hs:872:13)
2018-01-31 15:16:36.605563: [debug] Run from outside a project, using implicit global project config
@(Stack/Config.hs:559:13)
2018-01-31 15:16:36.606076: [debug] Using resolver: lts-10.4 from implicit global project's config file: /Users/khouli/.stack/global-project/stack.yaml
@(Stack/Config.hs:573:32)
2018-01-31 15:16:36.606191: [debug] Decoding build plan from: /Users/khouli/.stack/build-plan/lts-10.4.yaml
@(Stack/Snapshot.hs:150:5)
2018-01-31 15:16:36.606271: [debug] Trying to decode /Users/khouli/.stack/build-plan-cache/lts-10.4.cache
@(Data/Store/VersionTagged.hs:66:5)
2018-01-31 15:16:36.634583: [debug] Success decoding /Users/khouli/.stack/build-plan-cache/lts-10.4.cache
@(Data/Store/VersionTagged.hs:70:13)
2018-01-31 15:16:36.635231: [debug] Using standard GHC build
@(Stack/Setup.hs:617:9)
2018-01-31 15:16:36.637726: [debug] Getting global package database location
@(Stack/GhcPkg.hs:46:5)
2018-01-31 15:16:36.638855: [debug] Asking GHC for its version
@(Stack/Setup/Installed.hs:98:13)
2018-01-31 15:16:36.640022: [debug] Run process: /Users/khouli/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Log.hs:37:3)
2018-01-31 15:16:36.640165: [debug] Getting Cabal package version
@(Stack/GhcPkg.hs:185:5)
2018-01-31 15:16:36.663772: [debug] Run process: /Users/khouli/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc --numeric-version
@(System/Process/Log.hs:37:3)
2018-01-31 15:16:36.664086: [debug] Run process: /Users/khouli/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Log.hs:37:3)
2018-01-31 15:16:36.791997: [debug] Process finished in 151ms: /Users/khouli/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db list --global
@(System/Process/Log.hs:44:3)
2018-01-31 15:16:36.807012: [debug] Process finished in 142ms: /Users/khouli/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Log.hs:44:3)
2018-01-31 15:16:36.837523: [debug] Process finished in 173ms: /Users/khouli/.stack/programs/x86_64-osx/ghc-8.2.2/bin/ghc --numeric-version
@(System/Process/Log.hs:44:3)
2018-01-31 15:16:36.838046: [debug] GHC version is: ghc-8.2.2
@(Stack/Setup/Installed.hs:102:13)
2018-01-31 15:16:36.838239: [debug] Resolving package entries
@(Stack/Setup.hs:250:5)
2018-01-31 15:16:36.838748: [debug] Trying to decode /Users/khouli/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.2.2/lts-10.4.cache
@(Data/Store/VersionTagged.hs:66:5)
2018-01-31 15:16:36.900745: [debug] Success decoding /Users/khouli/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.2.2/lts-10.4.cache
@(Data/Store/VersionTagged.hs:70:13)
2018-01-31 15:16:36.901547: [debug] Starting to execute command inside EnvConfig
@(Stack/Runners.hs:170:18)
2018-01-31 15:16:36.901723: [info] Using configuration file: .stack/global-project/stack.yaml
@(Stack/Solver.hs:635:5)
2018-01-31 15:16:36.901818: [debug] Trying to decode /Users/khouli/.stack/indices/Hackage/01-index.cache
@(Data/Store/VersionTagged.hs:66:5)
2018-01-31 15:16:37.114223: [debug] Success decoding /Users/khouli/.stack/indices/Hackage/01-index.cache
@(Data/Store/VersionTagged.hs:70:13)
/Users/khouli/Library/Application Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Steam Helper EH.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/: getSymbolicLinkStatus: invalid argument (File name too long)

Stack version

$ stack --version
Version 1.6.3 x86_64 hpack-0.20.0

Method of installation

  • homebrew, default options
new / init / solver bug

All 6 comments

Is there a workaround for this? I feel like it's sane to want to run stack solver on the global project (although perhaps I'm wrong?)

Hoping this issue gets addressed, I can't run stack solver for this reason even after renaming the symlink.

The problem may be because stack is using its own directory traversal routines which follow symlinks and does not avoid loops. I changed the default behavior in the path-io package some time back to not follow symlinks by default e.g. see listDirRecur in this https://hackage.haskell.org/package/path-io-1.3.3/docs/Path-IO.html. I also added a walkDir routine in path-io which can detect and avoid loops. I guess these APIs can be used to solve this issue.

Can you attempt a PR with the fixes, @harendra-kumar? Thanks

@mihaimaruseac I am pretty busy with work these days, you cannot rely on me. Maybe someone else should take it up, I can help in reviewing though.

We've removed the solver support in #4670

Was this page helpful?
0 / 5 - 0 ratings