-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
error: TemporaryNameServerFailure when using package management on Termux #14636
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
Comments
I'm also getting this on Arch Linux with systemd-networkd and systemd-resolved. Working just fine on macOS though. Not sure if this helps but:
|
A related issue, #14900, was solved recently. Did it solve this issue as well? |
I see a different error now, |
Still doesn't work, I also got |
I went to debug this by altering std.http.Client, but got a strange result before I even changed any code. I checked out 602029b (commit of latest release at the time of this test), build stage3 (Release) and stage4 (Debug), and ran zig build on a project with dependencies, making sure to clear the global package cache between runs. Both of those built zig executables successfully fetched deps. But I downloaded the official release with the same commit hash and got |
just to rule it out, does this run without error? const std = @import("std");
pub fn main() !void {
var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = general_purpose_allocator.allocator();
var http_client: std.http.Client = .{ .allocator = gpa };
defer http_client.deinit();
const uri = try std.Uri.parse("http://github.com");
var req = try http_client.request(uri, .{}, .{});
defer req.deinit();
} |
@mikdusan It does not! Good idea to test by using an HTTP client directly. Error output:
I added a log right before the error return in
|
I fixed the issue on my machine. I'll report what I found in case it helps @leap0x7b or others, but I'm left to speculate about the original root cause. The issue was mundane: my My guess is that my system got into a bad state long ago but didn't show symptoms until the Zig HTTP client tried to resolve DNS by reading resolv.conf directly. It was an empty file (except for a comment), so name resolution obviously failed. I don't understand why every other program was still able to use DNS — maybe glibc falls back to discovering a local nameserver, while musl doesn't. In fact, Zig built locally with glibc was able to make these HTTP requests, even with my previously bad system state. As for how my system got into that state, who knows, but I have had at least one service that modifies Anyway, no Zig bug here as far as I am concerned. |
On Android (termux), /etc/resolv.conf doesn't exist const std = @import("std");
pub fn main() !void {
var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = general_purpose_allocator.allocator();
var http_client: std.http.Client = .{ .allocator = gpa };
defer http_client.deinit();
const uri = try std.Uri.parse("http://github.com");
var req = try http_client.request(.GET, uri, .{
.allocator = gpa,
}, .{});
defer req.deinit();
} openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
Packages in the termux package manager have to patch this folder it seems: https://github.com/termux/termux-packages/pull/14738/files Applying these patches to std/net.zig appears to fix the issue for using http_client.request, but zig would have to be recompiled with these changes to fix zig build: - const file = fs.openFileAbsoluteZ("/etc/hosts", .{}) catch |err| switch (err) {
+ const file = fs.openFileAbsoluteZ("/data/data/com.termux/files/usr/etc/hosts", .{}) catch |err| switch (err) {
- const file = fs.openFileAbsoluteZ("/etc/resolv.conf", .{}) catch |err| switch (err) {
+ const file = fs.openFileAbsoluteZ("/data/data/com.termux/files/usr/etc/resolv.conf", .{}) catch |err| switch (err) { I'm not sure what to do about this?
Some possible solutions:
|
Until the problem is solved in zig, the likely temporary solution seems to be laid out in the https://wiki.termux.com/wiki/Differences_from_Linux that you linked. You can use |
+1, I'm also hitting this problem on my Ubuntu laptop. For some reason, specifically github.com takes 10 seconds to resolve when pinging (github.io is fast). Git operations are also delayed by those 10 seconds but eventually work. The Zig package manager however fails with TemporaryNameServerFailure. (PS: zig 0.12.0-dev.2236+32e88251e) PS: it works after changing DNS servers from my router to 8.8.8.8 and 8.8.4.4 (make sure that systemd actual sees those changes via PPS: FWIW, on my Mac it's always fast, no matter if my router is used for DNS or the Google DNS servers. |
Great stuff @pfgithub! Having looked at #14146 a bit, I also got interested in wanting to get this fixed. I think adding an There could also be fallback nameservers for popular providers like |
@JerwuQu Wouldn't this mean any program using zig http would need to have its own |
@pfgithub That is very true. I honestly didn't consider that at first, only thinking about the In that case I feel more strongly that an environment variable for specifying DNS servers (or an alternative I searched quite a bit and can't find any good names that are shared between multiple projects. I therefore see two options:
The downside here is that package maintainers can't reasonably set this variable for their users, and would still need to patch the stdlib to get their I would be keen to hear the thoughts of a Zig maintainer on this issue. |
I just use "proot-distro" within Termux https://github.com/termux/proot-distro?tab=readme-ov-file#installing Install and login as root
My fish config has these line.
Also you can just mount resolve.conf with I tried but zig prints warning about linker and it's annoying |
I am facing this same issue on termux, a simple fetch to example.com raises this, I am not finding any solutions |
I think fixing the DNS resolution logic makes the most sense... this workaround should not be necessary. |
Zig Version
0.11.0-dev.1606+3c2a43fdc
Steps to Reproduce and Observed Behavior
zig init-lib
orzig init-exe
zig build
Expected Behavior
It should be able to resolve github.com and download the file.
The text was updated successfully, but these errors were encountered: