on master help sign in
Replace ELM_HOME with actual value in error messages
b0b9b19Evan Czaplicki
builder/src/Deps/Explorer.hs+4−2
@@ -19,7 +19,7 @@ The goal of this module is to only pay for (1) and pay for (2) as needed.
19-}
19-}
20
20
21
21
22−import Control.Monad.Except (lift, throwError)
22+import Control.Monad.Except (liftIO, lift, throwError)
23import Control.Monad.State (StateT, evalStateT, gets, modify)
23import Control.Monad.State (StateT, evalStateT, gets, modify)
24import Data.Map (Map)
24import Data.Map (Map)
25import qualified Data.Map as Map
25import qualified Data.Map as Map
@@ -27,6 +27,7 @@ import qualified Data.Map as Map
27import Elm.Package (Name, Version)
27import Elm.Package (Name, Version)
28
28
29import qualified Deps.Get as Get
29import qualified Deps.Get as Get
30+import qualified Elm.PerUserCache as PerUserCache
30import qualified Elm.Project.Json as Project
31import qualified Elm.Project.Json as Project
31import Elm.Project.Constraint (Constraint)
32import Elm.Project.Constraint (Constraint)
32import qualified Reporting.Exit as Exit
33import qualified Reporting.Exit as Exit
@@ -89,7 +90,8 @@ getVersions name =
89 return versions
90 return versions
90
91
91 Left _suggestions ->
92 Left _suggestions ->
93+ do elmHome <- liftIO PerUserCache.getElmHome
92− throwError (Exit.Deps (E.CorruptVersionCache name))
94+ throwError (Exit.Deps (E.CorruptVersionCache elmHome name))
93
95
94
96
95
97
builder/src/Deps/Verify.hs+3−1
@@ -19,6 +19,7 @@ import qualified Elm.Compiler.Module as Module
19import qualified Elm.Compiler.Objects as Obj
19import qualified Elm.Compiler.Objects as Obj
20import qualified Elm.Docs as Docs
20import qualified Elm.Docs as Docs
21import Elm.Package (Name, Version)
21import Elm.Package (Name, Version)
22+import qualified Elm.PerUserCache as PerUserCache
22import Elm.Project.Json (Project(..), AppInfo(..), PkgInfo(..))
23import Elm.Project.Json (Project(..), AppInfo(..), PkgInfo(..))
23import qualified Json.Encode as Encode
24import qualified Json.Encode as Encode
24
25
@@ -192,7 +193,8 @@ toInfo _ answer =
192 return Nothing
193 return Nothing
193
194
194 Err name version ->
195 Err name version ->
196+ do elmHome <- liftIO PerUserCache.getElmHome
195− throw (E.BuildFailure name version)
197+ throw (E.BuildFailure elmHome name version)
196
198
197
199
198ifNotBlocked :: Map Name Answer -> (Map Name PkgInfo -> IO Answer) -> IO Answer
200ifNotBlocked :: Map Name Answer -> (Map Name PkgInfo -> IO Answer) -> IO Answer
builder/src/Elm/PerUserCache.hs+8−2
@@ -2,6 +2,7 @@
2module Elm.PerUserCache
2module Elm.PerUserCache
3 ( getPackageRoot
3 ( getPackageRoot
4 , getReplRoot
4 , getReplRoot
5+ , getElmHome
5 )
6 )
6 where
7 where
7
8
@@ -29,8 +30,7 @@ getReplRoot =
29
30
30getRoot :: FilePath -> IO FilePath
31getRoot :: FilePath -> IO FilePath
31getRoot projectName =
32getRoot projectName =
32− do maybeHome <- Env.lookupEnv "ELM_HOME"
33+ do home <- getElmHome
33− home <- maybe (Dir.getAppUserDataDirectory "elm") return maybeHome
34 let root = home </> version </> projectName
34 let root = home </> version </> projectName
35 Dir.createDirectoryIfMissing True root
35 Dir.createDirectoryIfMissing True root
36 return root
36 return root
@@ -39,3 +39,9 @@ getRoot projectName =
39version :: FilePath
39version :: FilePath
40version =
40version =
41 Pkg.versionToString Compiler.version
41 Pkg.versionToString Compiler.version
42+
43+
44+getElmHome :: IO FilePath
45+getElmHome =
46+ do maybeHome <- Env.lookupEnv "ELM_HOME"
47+ maybe (Dir.getAppUserDataDirectory "elm") return maybeHome
builder/src/File/IO.hs+3−1
@@ -30,6 +30,7 @@ import qualified System.FilePath as FP
30import qualified System.IO as IO
30import qualified System.IO as IO
31import System.IO.Error (ioeGetErrorType, annotateIOError, modifyIOError)
31import System.IO.Error (ioeGetErrorType, annotateIOError, modifyIOError)
32
32
33+import qualified Elm.PerUserCache as PerUserCache
33import qualified Reporting.Exit as Exit
34import qualified Reporting.Exit as Exit
34import qualified Reporting.Exit.Assets as E
35import qualified Reporting.Exit.Assets as E
35import qualified Reporting.Task as Task
36import qualified Reporting.Task as Task
@@ -64,7 +65,8 @@ readBinary path =
64
65
65throwCorruptBinary :: FilePath -> Task.Task a
66throwCorruptBinary :: FilePath -> Task.Task a
66throwCorruptBinary filePath =
67throwCorruptBinary filePath =
68+ do elmHome <- liftIO PerUserCache.getElmHome
67− Task.throw (Exit.Assets (E.CorruptBinary filePath))
69+ Task.throw (Exit.Assets (E.CorruptBinary elmHome filePath))
68
70
69
71
70
72
builder/src/Reporting/Exit/Assets.hs+12−6
@@ -25,7 +25,7 @@ data Exit
25 = BadElmJson ElmJsonProblem
25 = BadElmJson ElmJsonProblem
26 | CorruptElmJson Pkg.Name Pkg.Version
26 | CorruptElmJson Pkg.Name Pkg.Version
27 | CorruptDocumentation Pkg.Name Pkg.Version
27 | CorruptDocumentation Pkg.Name Pkg.Version
28− | CorruptBinary FilePath
28+ | CorruptBinary FilePath FilePath
29
29
30
30
31
31
@@ -51,13 +51,19 @@ toReport exit =
51 CorruptDocumentation pkg vsn ->
51 CorruptDocumentation pkg vsn ->
52 corruptJsonToReport "docs.json" pkg vsn
52 corruptJsonToReport "docs.json" pkg vsn
53
53
54− CorruptBinary path ->
54+ CorruptBinary elmHome path ->
55 Help.report "CORRUPT BINARY" (Just path)
55 Help.report "CORRUPT BINARY" (Just path)
56 ("The binary data at " ++ path ++ " is corrupt.")
56 ("The binary data at " ++ path ++ " is corrupt.")
57− [ D.reflow $
57+ [ D.reflow "Elm caches build artifacts in the following directories:"
58− "Maybe a program is modifying your elm-stuff/ or ELM_HOME\
58+ , D.dullyellow $ D.indent 4 $ D.vcat $
59− \ directory in unexpected ways? Both of those are just caches, so\
59+ [ D.fromString elmHome
60+ , "elm-stuff/"
61+ ]
62+ , D.reflow
63+ "Maybe you recently installed a command line tool or editor plugin that messes\
64+ \ with them? They definitely should not be doing that, but you never know! So\
60− \ you can try deleting them and they will be rebuilt from scratch."
65+ \ maybe try deleting them? Everything will be rebuilt from scratch. This may\
66+ \ help reveal the corrupting influence."
61 ]
67 ]
62
68
63 BadElmJson problem ->
69 BadElmJson problem ->
builder/src/Reporting/Exit/Deps.hs+11−9
@@ -19,13 +19,13 @@ import qualified Reporting.Exit.Help as Help
19
19
20
20
21data Exit
21data Exit
22− = CorruptVersionCache Pkg.Name
22+ = CorruptVersionCache FilePath Pkg.Name
23 | PackageNotFound Pkg.Name [Pkg.Name]
23 | PackageNotFound Pkg.Name [Pkg.Name]
24 -- verify
24 -- verify
25 | AppBadElm Pkg.Version
25 | AppBadElm Pkg.Version
26 | PkgBadElm Con.Constraint
26 | PkgBadElm Con.Constraint
27 | BadDeps
27 | BadDeps
28− | BuildFailure Pkg.Name Pkg.Version
28+ | BuildFailure FilePath Pkg.Name Pkg.Version
29
29
30
30
31
31
@@ -35,13 +35,13 @@ data Exit
35toReport :: Exit -> Help.Report
35toReport :: Exit -> Help.Report
36toReport exit =
36toReport exit =
37 case exit of
37 case exit of
38− CorruptVersionCache pkg ->
38+ CorruptVersionCache elmHome pkg ->
39 Help.report "CORRUPT CACHE" Nothing
39 Help.report "CORRUPT CACHE" Nothing
40 ( "I ran into an unknown package while exploring dependencies:"
40 ( "I ran into an unknown package while exploring dependencies:"
41 )
41 )
42 [ D.indent 4 $ D.dullyellow $ D.fromString $ Pkg.toString pkg
42 [ D.indent 4 $ D.dullyellow $ D.fromString $ Pkg.toString pkg
43 , D.reflow $
43 , D.reflow $
44− "This suggests that your ELM_HOME directory has been corrupted.\
44+ "This suggests that your " ++ elmHome ++ " directory has been corrupted.\
45 \ Maybe some program is messing with it? It is just cached files,\
45 \ Maybe some program is messing with it? It is just cached files,\
46 \ so you can delete it and see if that fixes the issue."
46 \ so you can delete it and see if that fixes the issue."
47 ]
47 ]
@@ -94,11 +94,13 @@ toReport exit =
94 \ you are running into something that seems trickier than this."
94 \ you are running into something that seems trickier than this."
95 ]
95 ]
96
96
97− BuildFailure pkg vsn ->
97+ BuildFailure elmHome pkg vsn ->
98 Help.report "CORRUPT DEPENDENCY" Nothing
98 Help.report "CORRUPT DEPENDENCY" Nothing
99 "I ran into a problem while building the following package:"
99 "I ran into a problem while building the following package:"
100− [ D.indent 4 $ D.dullyellow $ D.fromString $ Pkg.toString pkg ++ " " ++ Pkg.versionToString vsn
100+ [ D.indent 4 $ D.red $ D.fromString $ Pkg.toString pkg ++ " " ++ Pkg.versionToString vsn
101− , D.reflow $
101+ , D.fillSep
102− "This probably means the downloaded files got corrupted somehow.\
102+ ["This","probably","means","the","downloaded","files","got","corrupted","somehow."
103+ ,"Try","deleting",D.dullyellow (D.fromString elmHome),"(a","directory","for"
103− \ Maybe try deleting your ELM_HOME and see if that resolves the issue?"
104+ ,"caching","build","artifacts)","and","see","if","that","resolves","the","issue."
105+ ]
104 ]
106 ]
builder/src/Reporting/Exit/Install.hs+2−2
@@ -28,7 +28,7 @@ data Exit
28toReport :: Exit -> Help.Report
28toReport :: Exit -> Help.Report
29toReport exit =
29toReport exit =
30 case exit of
30 case exit of
31− NoArgs cacheDir ->
31+ NoArgs elmHome ->
32 Help.report "INSTALL WHAT?" Nothing
32 Help.report "INSTALL WHAT?" Nothing
33 "I am expecting commands like:"
33 "I am expecting commands like:"
34 [ D.green $ D.indent 4 $ D.vcat $
34 [ D.green $ D.indent 4 $ D.vcat $
@@ -40,7 +40,7 @@ toReport exit =
40 ["In","JavaScript","folks","run","`npm install`","to","start","projects."
40 ["In","JavaScript","folks","run","`npm install`","to","start","projects."
41 ,"\"Gotta","download","everything!\"","But","why","download","packages"
41 ,"\"Gotta","download","everything!\"","But","why","download","packages"
42 ,"again","and","again?","Instead,","Elm","caches","packages","in"
42 ,"again","and","again?","Instead,","Elm","caches","packages","in"
43− ,D.dullyellow (D.fromString cacheDir)
43+ ,D.dullyellow (D.fromString elmHome)
44 ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
44 ,"so","each","one","is","downloaded","and","built","ONCE","on","your","machine."
45 ,"Elm","projects","check","that","cache","before","trying","the","internet."
45 ,"Elm","projects","check","that","cache","before","trying","the","internet."
46 ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
46 ,"This","reduces","build","times,","reduces","server","costs,","and","makes","it"
ui/terminal/src/Install.hs+5−2
@@ -5,7 +5,10 @@ module Install
5 where
5 where
6
6
7
7
8+import Control.Monad.Trans (liftIO)
9+
8import qualified Elm.Install as Install
10import qualified Elm.Install as Install
11+import qualified Elm.PerUserCache as PerUserCache
9import qualified Elm.Package as Pkg
12import qualified Elm.Package as Pkg
10import qualified Reporting.Exit as Exit
13import qualified Reporting.Exit as Exit
11import qualified Reporting.Exit.Install as E
14import qualified Reporting.Exit.Install as E
@@ -28,8 +31,8 @@ run args () =
28 Task.run reporter $
31 Task.run reporter $
29 case args of
32 case args of
30 NoArgs ->
33 NoArgs ->
31− do cacheDir <- Task.getPackageCacheDir
34+ do elmHome <- liftIO PerUserCache.getElmHome
32− Task.throw (Exit.Install (E.NoArgs cacheDir))
35+ Task.throw (Exit.Install (E.NoArgs elmHome))
33
36
34 Install pkg ->
37 Install pkg ->
35 Install.install pkg
38 Install.install pkg