madjar / nox

Tools to make nix nicer to use
MIT License
308 stars 35 forks source link

Crash on ill-formed package expression #12

Closed aherrmann closed 9 years ago

aherrmann commented 9 years ago

First off thanks for making this tool. I think this is immensely useful.

Here's the issue: I just managed to crash nox on the first refreshing of the cache.

$ nox clang
Refreshing cache
error: undefined variable ‘licenses’ at "/home/me/.nixpkgs/config.nix":137:19
Traceback (most recent call last):
  File "/nix/store/s09c6d03a6yfgc6skhkb9rh96famm7gs-nox-0.0.1/bin/..nox-wrapped-wrapped", line 11, in <module>
    sys.exit(main())
  File "/nix/store/iai3907c36s6qi74ry0v74yhr6gnambz-python3.4-click-2.1/lib/python3.4/site-packages/click/core.py", line 488, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/iai3907c36s6qi74ry0v74yhr6gnambz-python3.4-click-2.1/lib/python3.4/site-packages/click/core.py", line 474, in main
    self.invoke(ctx)
  File "/nix/store/iai3907c36s6qi74ry0v74yhr6gnambz-python3.4-click-2.1/lib/python3.4/site-packages/click/core.py", line 653, in invoke
    ctx.invoke(self.callback, **ctx.params)
  File "/nix/store/iai3907c36s6qi74ry0v74yhr6gnambz-python3.4-click-2.1/lib/python3.4/site-packages/click/core.py", line 325, in invoke
    return callback(*args, **kwargs)
  File "/nix/store/s09c6d03a6yfgc6skhkb9rh96famm7gs-nox-0.0.1/lib/python3.4/site-packages/nox/search.py", line 48, in main
    results = [p for p in all_packages()
  File "/nix/store/s09c6d03a6yfgc6skhkb9rh96famm7gs-nox-0.0.1/lib/python3.4/site-packages/nox/search.py", line 39, in all_packages
    packages_json = region.get_or_create(key, nix_packages_json)
  File "/nix/store/kp03c6jq8rgqbz41zmnbmakxmq2s8rmz-python3.4-dogpile.cache-0.5.4/lib/python3.4/site-packages/dogpile/cache/region.py", line 640, in get_or_create
    async_creator) as value:
  File "/nix/store/ymarjk1sq4w2bnd3ina1vz7zlmcfp1m7-python3.4-dogpile.core-0.4.1/lib/python3.4/site-packages/dogpile/core/dogpile.py", line 158, in __enter__
    return self._enter()
  File "/nix/store/ymarjk1sq4w2bnd3ina1vz7zlmcfp1m7-python3.4-dogpile.core-0.4.1/lib/python3.4/site-packages/dogpile/core/dogpile.py", line 98, in _enter
    generated = self._enter_create(createdtime)
  File "/nix/store/ymarjk1sq4w2bnd3ina1vz7zlmcfp1m7-python3.4-dogpile.core-0.4.1/lib/python3.4/site-packages/dogpile/core/dogpile.py", line 149, in _enter_create
    created = self.creator()
  File "/nix/store/kp03c6jq8rgqbz41zmnbmakxmq2s8rmz-python3.4-dogpile.cache-0.5.4/lib/python3.4/site-packages/dogpile/cache/region.py", line 612, in gen_value
    created_value = creator()
  File "/nix/store/s09c6d03a6yfgc6skhkb9rh96famm7gs-nox-0.0.1/lib/python3.4/site-packages/nox/search.py", line 14, in nix_packages_json
    universal_newlines=True)
  File "/nix/store/c4vxfd06bb65i74pwkdixwh2pgcaajxk-python3-3.4.2/lib/python3.4/subprocess.py", line 620, in check_output
    raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command '['nix-env', '-qa', '--json']' returned non-zero exit status 1

As it turns out the issue was an ill-formed package in my packageOverrides. It contained the following lines.

meta = {
  # ...
  license = licenses.asl20;
};

But, licenses was not defined anywhere. I must have remove the corresponding with stdenv.lib a while ago, but never noticed since I didn't use the package since, and Nix's laziness avoided the error.


I think it would be better to handle this more gracefully. Either, just ignore the broken package. Or, maybe, print a warning.

madjar commented 9 years ago

I'm not sure if I can ignore the broken packages, but that is indeed an ugly error message.

I'll look into it, see if I can skip broken packages. If not, I'll just put a nice error message.