Mercurial hg 克隆错误 - “中止:错误:名称或服务未知”

发布于 2024-09-04 16:21:05 字数 578 浏览 4 评论 0原文

我已经安装了适用于 Fedora Linux 的最新 hg 软件包。但是,hg clone 报告错误。

hg clone http://localmachine001:8000/ repository

报告:

"abort: error: Name or service not known"

localmachine001 是本地网络内的一台计算机。我可以从我的 Linux 机器上 ping 通它,没有任何问题。我还可以使用相同的http地址并浏览现有的代码。然而,hg克隆不起作用。

如果我从我的 Macintosh 机器执行相同的命令,我可以轻松克隆存储库。

一些互联网资源建议编辑 .hgrc 文件,并向其添加代理:

[http_proxy]
host=proxy:8080

我已经尝试过,但没有成功。另外,我假设在这种情况下不需要代理,因为 hg 服务器计算机位于我的本地网络中。

谁能建议我应该做什么,或者如何跟踪问题?

先感谢您。

I have installed the latest hg package available for Fedora Linux. However, hg clone reports an error.

hg clone http://localmachine001:8000/ repository

reports:

"abort: error: Name or service not known"

localmachine001 is a computer within the local network. I can ping it from my Linux box without any problems. I can also use the same http address and browse the existing code. However, hg clone does not work.

If I execute the same command from my Macintosh machine, I can easily clone the repository.

Some Internet resources recommend editing .hgrc file, and adding proxy to it:

[http_proxy]
host=proxy:8080

I have tried that without any success. Also, I assume that proxy is not needed in this case, since the hg server machine is in my local network.

Can anyone recommend me what should I do, or how could I track the problem?

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

生生漫 2024-09-11 16:21:05

以 root 身份运行 hg 解决了我的问题。但还是不知道为什么。

Running hg as root solved the problem for me. But still don't know why.

像你 2024-09-11 16:21:05

问题是(可能)您的 http 代理无法:

  1. 解析 localmachine
  2. 到达您(或 localmachine)的本地 IP,即使它可以解析“localmachine”到您正确的本地地址。

首先,确保您这边(iptables / NAT / 防火墙)没有任何东西阻止代理端口上的出站或入站。 如果您是root用户,如果它有效,那就是问题所在 - 从那里开始向后工作。

也可以想象,您的代理正在破坏来自远程HG的响应,足以迷惑Mercurial,但不会迷惑您的浏览器。无论哪种情况,如果 HG 位于本地 (localhost/lan) 网络上,最好绕过代理。

幸运的是,[http_proxy] 指令支持绕过某些主机名的代理,这非常适合处理 NAT 同一侧的内容,或仅存在于一台计算机上的主机(例如通过解析) /etc/hosts。)这可以避免每次需要更改行为时都必须编辑 .hgrc 的麻烦。

请参阅文档,或者只是让您的 .hgrc 看起来像一些东西像这样:

[http_proxy]
host=proxy:8080
no=localmachine,192.168.1.123,192.168.1.234,...,...

操作指令当然是no。我不确定在指定主机时是否可以使用通配符(我不使用代理功能,因此无法测试该功能..并且文档中未指定)。您可以尝试尝试一下,例如192.168.1.*,并让我们知道这是否也有效。

无论如何,对于极度懒惰的人(或非常匆忙的人),上面链接的文档的相关部分:

http_proxy

Used to access web-based Mercurial repositories through a HTTP proxy.

host
    Host name and (optional) port of the proxy server, for example "myproxy:8000".
no
    Optional. Comma-separated list of host names that should bypass the proxy.
passwd
    Optional. Password to authenticate with at the proxy server.
user
    Optional. User name to authenticate with at the proxy server.

The problem is (likely) that your http proxy is not able to:

  1. Resolve localmachine
  2. Reach your (or localmachine's) local IP, even if it could resolve 'localmachine' to your correct local address.

First, make sure nothing on your side (iptables / NAT / firewall) is preventing egress or ingress on the proxy port. If it works if you're root, that's the problem - work backwards from there.

Its also conceivable that your proxy is mangling the responses from the remote HG sufficiently to confuse Mercurial, but not your browser. In either case, its best to just go around the proxy if the HG is on the local (localhost/lan) network.

Fortunately, the [http_proxy] directive supports bypassing the proxy for certain host names, which is ideal for dealing with stuff on the same side of a NAT, or hosts that only exist on one machine (e.g. resolved via /etc/hosts.) This saves the pain from having to edit .hgrc every time you need to change the behavior.

See the documentation, or simply make your .hgrc look something like this:

[http_proxy]
host=proxy:8080
no=localmachine,192.168.1.123,192.168.1.234,...,...

The operative directive of course being no. I'm not sure if you can use wildcards when specifying the hosts (I don't use the proxy feature, so no way of testing that .. and its not specified in the documentation). You might try experimenting with that, e.g. 192.168.1.* and let us know if that works as well.

Anyway, for the terminally lazy (or people in a rather big hurry), the related section of the documentation linked above:

http_proxy

Used to access web-based Mercurial repositories through a HTTP proxy.

host
    Host name and (optional) port of the proxy server, for example "myproxy:8000".
no
    Optional. Comma-separated list of host names that should bypass the proxy.
passwd
    Optional. Password to authenticate with at the proxy server.
user
    Optional. User name to authenticate with at the proxy server.
卸妝后依然美 2024-09-11 16:21:05

当我的 DNS 名称服务器设置未配置时,我就发生了这种情况。尝试 ping 远程存储库主机并尝试 ping 一些知名主机,例如 google.com。如果不起作用,请修复您的 DNS 设置。

This happened to me when my DNS name server settings weren't configured. Try to ping the remote repository host and try to ping some well-known host e.g. google.com. If it doesn't work, fix your DNS settings.

凯凯我们等你回来 2024-09-11 16:21:05

该错误是由于 DNS 引起的,请在 /etc/resolve.conf 中添加条目。

$ cat /etc/resolve.conf
search xyz.com abc.com   --> DOMAINS
nameserver 10.192.160.12 -->DNS1
nameserver 10.193.180.23 -->DNS2

这使得能够通过名称访问本地计算机,&这样克隆就会成功。

The error is because of DNS, add entry into /etc/resolve.conf.

$ cat /etc/resolve.conf
search xyz.com abc.com   --> DOMAINS
nameserver 10.192.160.12 -->DNS1
nameserver 10.193.180.23 -->DNS2

This enables to reach local machine by name, & hence clone will be successful.

帅气尐潴 2024-09-11 16:21:05

克隆和 Web 界面使用完全相同的机制,因此很奇怪您可以在 http://localmachine001:8000 看到存储库/ 但你不能从中克隆。

尝试通过 IP 地址访问该机器怎么样?像 hg clone http://192.168.0.4:8080 之类的东西,看看会发生什么?

有关 --debug 的更多详细信息吗?

Clone and the web interface use exactly the same mechanism, so it's very odd that you can see the repo at http://localmachine001:8000/ but you can't clone from it.

What about trying to go to that machine by IP address? Something like hg clone http://192.168.0.4:8080 and see what happens?

Any more detail with --debug?

挖鼻大婶 2024-09-11 16:21:05

我遇到了同样的问题,

为了解决这个问题,我只是从笔记本电脑上断开了互联网连接,然后再次重新连接,

谢谢快乐编码;)

I Faced same issue,

To resolve this issue i just disconnected my internet from my laptop and reconnected again

Thankyou Happy coding ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文