NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.67k stars 13.12k forks source link

esphome impure, causes glibc errors #175290

Open poelzi opened 2 years ago

poelzi commented 2 years ago

Describe the bug

Running esphome from nixpkgs on nixos2111 results in glibc errors.

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix run nixpkgs#esphome compile --debug flipper_switch.yaml

flipper_switch.yaml is basically this config https://www.esphome-devices.com/devices/athom-smart-plug-tp29/

(esphome on nixos2111 was broken for me as well)

Expected behavior

Compiles firmware

Screenshots

acquiring global GC lock '/nix/var/nix/gc.lock'
acquiring read lock on '/nix/var/nix/temproots/986796'
acquiring write lock on '/nix/var/nix/temproots/986796'
downgrading to read lock on '/nix/var/nix/temproots/986796'
using cache entry '{"name":"flake-registry.json","type":"file","url":"https://github.com/NixOS/flake-registry/raw/master/flake-registry.json"}' -> '{"etag":"\"8cb00b8710ab079546c48c7eb41c3b06f603b6a81be44cade2a89ae4d661e5fc\"","url":"https://raw.githubusercontent.com/NixOS/flake-registry/master/flake-registry.json"}', '/nix/store/157arm6mc317qax77qw2jx668fyihx88-flake-registry.json'
acquiring global GC lock '/nix/var/nix/gc.lock'
looked up 'flake:nixpkgs' -> 'github:NixOS/nixpkgs/nixpkgs-unstable'
acquiring write lock on '/nix/var/nix/temproots/986796'
downgrading to read lock on '/nix/var/nix/temproots/986796'
using cache entry '{"name":"source","type":"file","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}' -> '{"etag":"W/\"d9d551f5b9145e1805f02833ef8ed1d3acf9d720ca444c1f481f9bc0e213003c\"","url":"https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable"}', '/nix/store/g87krsh2rb9ims6zmk14lnwwajca0w02-source'
HEAD revision for 'https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable' is 17b62c338f2a0862a58bb6951556beecd98ccda9
acquiring write lock on '/nix/var/nix/temproots/986796'
downgrading to read lock on '/nix/var/nix/temproots/986796'
using cache entry '{"rev":"17b62c338f2a0862a58bb6951556beecd98ccda9","type":"git-tarball"}' -> '{"lastModified":1653738054,"rev":"17b62c338f2a0862a58bb6951556beecd98ccda9"}', '/nix/store/nbph6bdglyhaid9cfbwiwby0fpy6ga6y-source'
got tree '/nix/store/nbph6bdglyhaid9cfbwiwby0fpy6ga6y-source' from 'github:NixOS/nixpkgs/17b62c338f2a0862a58bb6951556beecd98ccda9'
checking access to '/nix/store/nbph6bdglyhaid9cfbwiwby0fpy6ga6y-source/flake.nix'
evaluating file '/nix/store/nbph6bdglyhaid9cfbwiwby0fpy6ga6y-source/flake.nix'
old lock file: {
  "nodes": {
    "root": {}
  },
  "root": "root",
  "version": 7
}
computing lock file node ''
new lock file: {
  "nodes": {
    "root": {}
  },
  "root": "root",
  "version": 7
}
using cached string attribute 'legacyPackages.x86_64-linux.esphome.type'
using cached string attribute 'legacyPackages.x86_64-linux.esphome.drvPath'
using cached string attribute 'legacyPackages.x86_64-linux.esphome.outPath'
using cached string attribute 'legacyPackages.x86_64-linux.esphome.outputName'
using cached string attribute 'legacyPackages.x86_64-linux.esphome.name'
building of '/nix/store/93rvj30xcn83glg53jgaq69wjr24ypjq-esphome-2022.5.1.drv!out' from .drv file: created
building of '/nix/store/93rvj30xcn83glg53jgaq69wjr24ypjq-esphome-2022.5.1.drv!out' from .drv file: woken up
querying info about missing paths...
starting pool of 7 threads
entered goal loop
building of '/nix/store/93rvj30xcn83glg53jgaq69wjr24ypjq-esphome-2022.5.1.drv!out' from .drv file: init
building of '/nix/store/93rvj30xcn83glg53jgaq69wjr24ypjq-esphome-2022.5.1.drv!out' from .drv file: loading derivation
acquiring write lock on '/nix/var/nix/temproots/986796'
downgrading to read lock on '/nix/var/nix/temproots/986796'
building of '/nix/store/93rvj30xcn83glg53jgaq69wjr24ypjq-esphome-2022.5.1.drv!out' from .drv file: have derivation
acquiring write lock on '/nix/var/nix/temproots/986796'
downgrading to read lock on '/nix/var/nix/temproots/986796'
building of '/nix/store/93rvj30xcn83glg53jgaq69wjr24ypjq-esphome-2022.5.1.drv!out' from .drv file: done
building of '/nix/store/93rvj30xcn83glg53jgaq69wjr24ypjq-esphome-2022.5.1.drv!out' from .drv file: goal destroyed
INFO Reading configuration flipper_switch.yaml...
INFO Detected timezone 'Europe/Berlin'
INFO Generating C++ source...
INFO Compiling app...
/nix/store/bcwyhqvik6jhcklib33v6kykdl4zp9d4-bash-5.1-p8/bin/sh: symbol lookup error: /usr/lib/libc.so.6: undefined symbol: _dl_audit_symbind_alt, version GLIBC_PRIVATE
Traceback (most recent call last):
  File "/nix/store/5jngq8dlfvnh75ydhsx1pdz0yr28zw94-platformio-6.0.1/lib/python3.9/site-packages/platformio/project/helpers.py", line 71, in get_default_projects_dir
    assert IS_WINDOWS
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/5jngq8dlfvnh75ydhsx1pdz0yr28zw94-platformio-6.0.1/bin/.platformio-wrapped", line 6, in <module>
    from platformio.__main__ import main
  File "/nix/store/5jngq8dlfvnh75ydhsx1pdz0yr28zw94-platformio-6.0.1/lib/python3.9/site-packages/platformio/__main__.py", line 21, in <module>
    from platformio import __version__, exception, maintenance
  File "/nix/store/5jngq8dlfvnh75ydhsx1pdz0yr28zw94-platformio-6.0.1/lib/python3.9/site-packages/platformio/maintenance.py", line 22, in <module>
    from platformio import __version__, app, exception, fs, telemetry
  File "/nix/store/5jngq8dlfvnh75ydhsx1pdz0yr28zw94-platformio-6.0.1/lib/python3.9/site-packages/platformio/app.py", line 60, in <module>
    "value": get_default_projects_dir(),
  File "/nix/store/5jngq8dlfvnh75ydhsx1pdz0yr28zw94-platformio-6.0.1/lib/python3.9/site-packages/platformio/project/helpers.py", line 81, in get_default_projects_dir
    subprocess.check_output(["xdg-user-dir", "DOCUMENTS"])
  File "/nix/store/vzqny68wq33dcg4hkdala51n5vqhpnwc-python3-3.9.12/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/nix/store/vzqny68wq33dcg4hkdala51n5vqhpnwc-python3-3.9.12/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['xdg-user-dir', 'DOCUMENTS']' returned non-zero exit status 127.

Additional context

Add any other context about the problem here.

Notify maintainers

@globin @elseym @hexa

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here
poelzi commented 2 years ago

I think the problem is actually in platformio:

DEBUG Running add_pin_initial_states_array in esphome.components.esp8266.gpio (num 31)
DEBUG Adding global: const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_MODE[16] = {OUTPUT, 255, 255, INPUT_PULLUP, INPUT_PULLUP, INPUT_PULLUP, 255, 255, 255, 255, 255, 255, OUTPUT, OUTPUT, OUTPUT, 255};
DEBUG Adding global: const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[16] = {1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1, 0, 0, 255};
DEBUG  -> finished
DEBUG Running add_arduino_global_workaround in esphome.core.config (num 33)
DEBUG Adding global: #define yield() esphome::yield()
DEBUG Adding global: #define millis() esphome::millis()
DEBUG Adding global: #define micros() esphome::micros()
DEBUG Adding global: #define delay(x) esphome::delay(x)
DEBUG Adding global: #define delayMicroseconds(x) esphome::delayMicroseconds(x)
DEBUG  -> finished
INFO Compiling app...
DEBUG Running:  platformio run -d .esphome/build/flipperswitch -v
/nix/store/bcwyhqvik6jhcklib33v6kykdl4zp9d4-bash-5.1-p8/bin/sh: symbol lookup error: /usr/lib/libc.so.6: undefined symbol: _dl_audit_symbind_alt, version GLIBC_PRIVATE
Traceback (most recent call last):
  File "/nix/store/5jngq8dlfvnh75ydhsx1pdz0yr28zw94-platformio-6.0.1/lib/python3.9/site-packages/platformio/project/helpers.py", line 71, in get_default_projects_dir
    assert IS_WINDOWS
AssertionError

During handling of the above exception, another exception occurred:
mweinelt commented 2 years ago

cc @oxzi @makefu

oxzi commented 2 years ago

Might this be related to #173599? At least both are mentioning xdg-user-dir.

oxzi commented 2 years ago

Unfortunately I cannot reproduce the error based on the YAML from the posted URL.

$ git describe
22.05-pre-48384-g4a88391c998
$ nix-shell -I nixpkgs=$(pwd) -p esphome --pure --run "esphome compile foo.yml"
. . .
INFO Successfully compiled program.
IvarWithoutBones commented 2 years ago

Im getting a similar glibc error when attempting to use Android Studio:

com.intellij.openapi.vcs.VcsException: /run/current-system/sw/bin/setsid: symbol lookup error: /usr/lib/libc.so.6: undefined symbol: _dl_audit_symbind_alt, version GLIBC_PRIVATE

After looking for a fix I found a few similar issues being reported: https://github.com/rust-lang/rust-analyzer/issues/12410 and https://github.com/haskell/haskell-language-server/issues/2928.

The last latter mentions a channel mismatch, although rebuilding my system (without any channels, just a flake) with my local nixpkgs checkout from which I build Android Studio didn't seem to change anything.

Edit: After rebooting my system with a matching glibc version the error disappeared, that might help with this issue as well.

seriousbusinessuser commented 2 years ago

@IvarWithoutBones What glibc version did you use to fix this? Could you please provide instructions on how to fix this?

IvarWithoutBones commented 2 years ago

@IvarWithoutBones What glibc version did you use to fix this? Could you please provide instructions on how to fix this?

I made my system use glibc from my local nixpkgs checkout so its consistent with the one in the package as follows:

~/nix/nixpkgs > nixos-rebuild switch --override-input nixpkgs .
~/nix/nixpkgs > reboot
~/nix/nixpkgs > nix build -Lf . esphome
~/nix/nixpkgs > ./result/bin/esphome

If you update your system to use the same version of glibc as the nixpkgs flake registry entry it should work as well, so I expect this problem might go away with a regular system upgrade.

poelzi commented 2 years ago

Of course it will go away, but that is the whole point of running NixOS in the first place. The 2022.11 version of esphome was broken so I just tried running the master version and this was broken as well for a different reason. The whole point of nixpkgs/nixos is to run contained reproduceable programs. Otherwise I can safe myself the headache nix brings as well '-)

SohamG commented 1 year ago

Still having this issue in PlatformIO.