zwilias / elm-json

Install, upgrade and uninstall Elm dependencies
MIT License
183 stars 9 forks source link

Confusing message if offline and elm-json can’t find stuff locally? #31

Open lydell opened 4 years ago

lydell commented 4 years ago

Steps to reproduce:

  1. Go to any folder with a valid elm.json where elm-json solve elm.json usually succeeds. The one created by elm init is fine for testing.

  2. Either:

    • Run ELM_HOME=does/not/exist elm-json --offline solve elm.json
    • Disconnect from the Internet and run ELM_HOME=does/not/exist elm-json solve elm.json

Example result:

-- NO VALID PACKAGE VERSION ----------------------------------------------------

Because elm/core does not appear to exist and this project depends on
elm/core 1.0.2 <= v < 2.0.0, no valid set of package versions could be
found.

When the --offline flag isn’t used this is also printed before the above:

phase: retrieve
 Oct 17 11:10:47.817 WARN Failed to fetch versions from package.elm-lang.org

So in that case there’s at least a clue that the failure might be due to connectivity issues.

At least for this --offline case, would it be possible to have the error say something like this?

There’s not enough information locally to solve the dependencies. I need to look at package.elm-lang.org to get more information, but I can’t do that when --offline is used.

That message could work for connectivity issues as well, with some tweaks:

There’s not enough information locally to solve the dependencies. I tried to look at package.elm-lang.org to get more information, but doing so failed with the following message: ...

elm-json version: 0.2.8

Maybe related note: elm-json --offline solve elm.json consistently failed for me at work, even though I had just run elm-json solve elm.json successfully right before. Removing ~/.elm/elm-json and running elm-json solve elm.json once more solved the problem – now --offline succeeds. I still have a backup of the old ~/.elm/elm-json if you feel like taking a look at it.

Point is, I was playing around with elm-json --offline to learn more about how it works and was confused by the output I got. You might have better ideas around this.

Edit: Or maybe this is the expected output, it just takes a little learning to understand why.