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

bug: "hostname: Unknown host" error #5665

Closed
2 tasks done
bryango opened this issue Jul 25, 2024 · 0 comments · Fixed by #5683
Closed
2 tasks done

bug: "hostname: Unknown host" error #5665

bryango opened this issue Jul 25, 2024 · 0 comments · Fixed by #5683
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@bryango
Copy link
Contributor

bryango commented Jul 25, 2024

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

Note: migrated from #5462 (comment).

After #5462, if the hostname is not set in /etc/hosts, the fqdn command hostname -f may fail with:

$ hostname -f
hostname: Unknown host

This shows up in the home-manager switch printout and is mildly annoying. Could it be changed to:

hostname -f 2>/dev/null

to suppress this inconsequential warning? Thank you!

Maintainer CC

@gauravjuvekar

System information

$ nix run nixpkgs#nix-info -- -m                               
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.32-1-MANJARO, Manjaro Linux, noversion, rolling`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - nixpkgs: `/home/bryan/.nix-defexpr/channels/nixpkgs`
@bryango bryango added bug triage Issues or feature request that have not been triaged yet labels Jul 25, 2024
@rycee rycee closed this as completed in 89670e2 Jul 30, 2024
PerchunPak pushed a commit to PerchunPak/home-manager that referenced this issue Sep 17, 2024
`hostname -f` could fail depending on the resolver. Discard any stderr
and test for the exit status before using the value for flake attribute
lookup.

I was unable to repro the exact bad exit status in nix-community#5665.
With
  - nscd disabled,
  - nsswitch.conf pointing to 'files',
  - hostname entry removed from /etc/hosts
`hostname -f` from inetutils-2.5 fell back to showing just the nodename
from `uname(2)`. Injecting an empty string into the
`(struct utsname).nodename` field of `uname(2)` using strace still
exited with empty output and 0 exit-status.

Fixes nix-community#5665
brckd pushed a commit to brckd/home-manager that referenced this issue Sep 24, 2024
`hostname -f` could fail depending on the resolver. Discard any stderr
and test for the exit status before using the value for flake attribute
lookup.

I was unable to repro the exact bad exit status in nix-community#5665.
With
  - nscd disabled,
  - nsswitch.conf pointing to 'files',
  - hostname entry removed from /etc/hosts
`hostname -f` from inetutils-2.5 fell back to showing just the nodename
from `uname(2)`. Injecting an empty string into the
`(struct utsname).nodename` field of `uname(2)` using strace still
exited with empty output and 0 exit-status.

Fixes nix-community#5665
Mikilio pushed a commit to Mikilio/home-manager that referenced this issue Oct 11, 2024
`hostname -f` could fail depending on the resolver. Discard any stderr
and test for the exit status before using the value for flake attribute
lookup.

I was unable to repro the exact bad exit status in nix-community#5665.
With
  - nscd disabled,
  - nsswitch.conf pointing to 'files',
  - hostname entry removed from /etc/hosts
`hostname -f` from inetutils-2.5 fell back to showing just the nodename
from `uname(2)`. Injecting an empty string into the
`(struct utsname).nodename` field of `uname(2)` using strace still
exited with empty output and 0 exit-status.

Fixes nix-community#5665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants