commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

Unclear error message for invalid extra-package-dbs #1738

Open pakanek opened 8 years ago

pakanek commented 8 years ago

Steps to reproduce Add invalid value to extra-package-dbs eg.

extra-package-dbs:
- ghc-datasize-0.1.2
stack build

Expected

Database 'ghc-datasize-0.1.2' does not exist

Actual

ghc-datasize-0.1.2: canonicalizePath: does not exist (No such file or directory)
$ stack --version
Version 1.0.2, Git revision fa09a980d8bb3df88b2a9193cd9bf84cc6c419b3 (3084 commits) x86_64

ghc-datasize belongs to extra-deps (my mistake). Error message does not tell you that stack is looking for database instead of package.

mitchellwrosen commented 7 years ago

I think it makes sense to standardize have one "directory not found" exception, and share it everywhere.

There is a NoSuchDirectory constructor in Stack.Types.Config.ConfigException, but Stack.Config is not the only module that calls resolveDir/resolveDir':

src/Stack/Config.hs:316:                     Nothing -> resolveDir' userPath
src/Stack/Config.hs:318:                     Just (_, configYaml) -> resolveDir (parent configYaml) userPath)
src/Stack/Config.hs:538:    extraPackageDBs <- mapM resolveDir' (projectExtraPackageDBs project)
src/Stack/Config.hs:566:            subs -> mapM (resolveDir entryRoot) subs
src/Stack/Config.hs:597:resolvePackageLocation _ projRoot (PLFilePath fp) = resolveDir projRoot fp
src/Stack/Coverage.hs:279:            dest <- resolveDir' destDir
src/Stack/Fetch.hs:151:    dest' <- resolveDir' dest
src/Stack/GhcPkg.hs:60:    resolveDir' fp
src/Stack/Image.hs:113:              do sourcePath <- resolveDir (bcRoot bconfig) source
src/Stack/Init.hs:75:    dirs <- mapM (resolveDir' . T.unpack) (searchDirs initOpts)
src/main/Main.hs:688:                pkgDir <- resolveDir' dir
src/main/Main.hs:707:            else mapM resolveDir' dirs