Skip to content

Instantly share code, notes, and snippets.

@grahamc

grahamc/error.md Secret

Last active June 24, 2020 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahamc/a5e79e44087442b4afedbb46248bcf57 to your computer and use it in GitHub Desktop.
Save grahamc/a5e79e44087442b4afedbb46248bcf57 to your computer and use it in GitHub Desktop.

I just want to say I got the most wonderful error message from a Nix evaluation today:

trace: warning: In file [...]/packet-spot-buildkite-agent/network.nix
a list is being assigned to the option config.programs.ssh.knownHosts.
This will soon be an error as type loaOf is deprecated.
See https://git.io/fj2zm for more information.
Do
  programs.ssh.knownHosts =
    { flexo.gsc.io = {...}; }
instead of
  programs.ssh.knownHosts =
    [ { hostNames = [ "flexo.gsc.io" "r13y.com" "147.75.105.137" ]; ...} ]

This error message:

✔️ is specific: "a list is being assigned to the option config.programs.ssh.knownHosts"

✔️ tells me where to go for more information: https://git.io/fj2zm

✔️ tells me where the violation is: .../packet-spot-buildkite-agent/network.nix

✔️ SHOWS me the code which is wrong:

      programs.ssh.knownHosts =
        [ { hostNames = [ "flexo.gsc.io" "r13y.com" "147.75.105.137" ]; ...} ]

✔️ AND tells me the solution:

      programs.ssh.knownHosts =
        { flexo.gsc.io = {...}; }

This is incredible, and ticks the main three boxes of good errors:

  1. What is the problem?
  2. Why did it happen?
  3. How do I fix it?

Way to go everyone, this is a massive step forward for our community and I am completely floored and delighted. Thank you.

@tewfik-ghariani
Copy link

Great warning message indeed! :D

One question though, what would you do if you have multiple hostnames associated with the same publicKey? Would you associate the same key to every hostname entry?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment