Skip to content

Conversation

oliverwiegers
Copy link

VM startup will fail if '/etc/hosts' does not exist.

Up until trying to start everything works but than this error is shown:

❯ limactl start  --foreground rosetta-builder-vm
INFO[0000] Using the existing instance "rosetta-builder-vm"
INFO[0000] Starting the instance "rosetta-builder-vm" with VM driver "vz"
INFO[0000] Running the host agent in the foreground
{"level":"debug","msg":"ResolveVMType: resolved VMType \"vz\" (existing instance, with \"/Users/oliver.wiegers/.lima/rosetta-builder-vm/vz-identifier\")","time":"2025-03-10T07:07:47+01:00"}
{"level":"debug","msg":"Creating iso file /Users/oliver.wiegers/.lima/rosetta-builder-vm/cidata.iso","time":"2025-03-10T07:07:48+01:00"}
{"level":"debug","msg":"Using /var/folders/p_/_t2_qt755974fjg43mttbz6w0000gn/T/diskfs_iso1327180885 as workspace","time":"2025-03-10T07:07:48+01:00"}
{"level":"debug","msg":"Failed to detect CPU features. Assuming that AES acceleration is available on this Apple silicon.","time":"2025-03-10T07:07:48+01:00"}
{"level":"debug","msg":"OpenSSH version 9.8.1 detected","time":"2025-03-10T07:07:48+01:00"}
{"level":"debug","msg":"AES accelerator seems available, prioritizing [email protected] and [email protected]","time":"2025-03-10T07:07:48+01:00"}
{"level":"info","msg":"hostagent socket created at /Users/oliver.wiegers/.lima/rosetta-builder-vm/ha.sock","time":"2025-03-10T07:07:48+01:00"}
{"level":"info","msg":"Starting VZ (hint: to watch the boot progress, see \"/Users/oliver.wiegers/.lima/rosetta-builder-vm/serial*.log\")","time":"2025-03-10T07:07:48+01:00"}
{"level":"debug","msg":"Start udp DNS listening on: 127.0.0.1:54615","time":"2025-03-10T07:07:48+01:00"}
{"level":"debug","msg":"Using search domains: [oliverwiegers.de oliverwiegers.net]","time":"2025-03-10T07:07:48+01:00"}
{"level":"debug","msg":"Start tcp DNS listening on: 127.0.0.1:56519","time":"2025-03-10T07:07:48+01:00"}
{"time":"2025-03-10T07:07:48.10548+01:00","status":{"exiting":true}}
{"level":"fatal","msg":"cannot add network services: open /etc/hosts: no such file or directory","time":"2025-03-10T07:07:48+01:00"}

❯ cat /etc/hosts
[bat error]: '/etc/hosts': No such file or directory (os error 2)

VM startup will fail if '/etc/hosts' does not exist.
@oliverwiegers
Copy link
Author

@cpick any thoughts on this?

@cpick
Copy link
Owner

cpick commented Apr 2, 2025

It looks like that error is generated within the github.com/containers/gvisor-tap-vsock/pkg/virtualnetwork module's virtualnetwork.new() so if this is an issue it may need to be addressed upstream.

nix-rosetta-builder uses a fork of lima in a rather "unconventional" way (it starts it under launchd socket activation and passes that accepted socket through to the lima process). So it definitely won't behave the same way as it does if run manually via limactl. That said, I haven't tested without a "/etc/hosts" file present on the host, Darwin/macOS machine.

A few questions:

  1. Do you see this issue when running the builder as installed by the module as described in the README.md? (You would be able to find the analogous error messages in "/var/lib/rosetta-builder/.lima/rosetta-builder-vm/ha.stderr.log").
  2. Are you intentionally running without an "/etc/hosts" file, I imagine it causes other issues?

@oliverwiegers
Copy link
Author

oliverwiegers commented Apr 6, 2025

@cpick I do know that it isn't an issue of your work but Lima itself refuses to start the VM if the file is missing.

To answer your questions:

  1. That issue was not present after installing the builder. The hosts file was still present at that time.

  2. It did not cause any other issues. And no it was not on purpose. I stumbled on this by accident. I briefly managed the hosts file using nix-darwin but removed that nix code a little later. Which removed the symlink to the nix managed file and MacOS didn't recreate the default one. This in turn caused the builder to not come up while rebuilding my system the next time.

It took me quite some time to figure out what had happened.
So I wanted to save other people the time should they run into this edge case scenario 😊

P.S. the output in the initial comment is from running limactl manually in the terminal, but it behaves like this wenn running using your described implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants