Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give a more useful error message when running non-nix ELF binaries on NixOS #208187

Closed
tejing1 opened this issue Dec 29, 2022 · 7 comments · Fixed by #269551
Closed

Give a more useful error message when running non-nix ELF binaries on NixOS #208187

tejing1 opened this issue Dec 29, 2022 · 7 comments · Fixed by #269551
Labels
0.kind: enhancement Add something new 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 9.needs: community feedback

Comments

@tejing1
Copy link
Contributor

tejing1 commented Dec 29, 2022

Issue description

$ ./foo
bash: ./foo: No such file or directory

This error message is just awful.

We all know what the issue is and why this can't be made to work, but we could at least improve the error message by creating a stub ELF interpreter in the default location that just prints out an error message when called.

This would need to interact with modules like nix-ld appropriately, but seems doable enough.

Thoughts?

@FliegendeWurst FliegendeWurst added 0.kind: enhancement Add something new 9.needs: community feedback 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS labels Oct 15, 2023
@eclairevoyant
Copy link
Contributor

eclairevoyant commented Oct 16, 2023

The stub should be controlled by a module option, on by default, and easy to disable; otherwise I agree

@tejing1
Copy link
Contributor Author

tejing1 commented Nov 23, 2023

I'm in the process of implementing and testing this now.

In the process, I also discovered something interesting. bash has changed the error message it shows in this scenario:

bash: ./foo: cannot execute: required file not found

Which at least points in roughly the right direction.

@tejing1
Copy link
Contributor Author

tejing1 commented Nov 24, 2023

Draft PR is up. I would appreciate feedback on what the message should look like, in particular.

@bjornfor
Copy link
Contributor

Can't we try to get this upstream behaviour

$ ./binaryfile
ERROR: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

in all Linux distros, instead of making something bespoke for NixOS?

@eclairevoyant
Copy link
Contributor

Not really, because that error message is unhelpful for everyone who needs it, and the NixOS solution is different from other distros

@tejing1
Copy link
Contributor Author

tejing1 commented Nov 27, 2023

The first problem is that error message is nearly as impenetrable to most as the old one. NixOS is truly different from the entire rest of the linux space in this regard, and just dumping an error message about an aspect of the environment even most accomplished linux users don't know exists isn't really good enough.

The second problem is that bash, or whatever is trying to start the executable, can't actually determine what precisely is missing. All it has to go on is an error code from the kernel afaik. The new behavior of bash is as good as their error reporting can actually be, given the interfaces they're working with.

@tejing1
Copy link
Contributor Author

tejing1 commented Nov 27, 2023

We should maybe tell the fish people to do better than this, though:

$ ./foo
fish: Job 1, './foo' terminated by signal SIGSEGV (Address boundary error)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 9.needs: community feedback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants