有一个新的Mac,现在我正在尝试安装/更新一些东西。我得到的第一个问题是从脚本/程序内部(例如git或ruby gem)发出的http请求不起作用。我将在下面介绍我使用的解决方法,因为它比任何解释都更好地说明了这个问题。任何帮助表示赞赏!
Leonardos-MacBook-Air:~ leo$ git clone git://github.com/sstephenson/rbenv.git .rbenv
Cloning into '.rbenv'...
fatal: Unable to look up github.com (port 9418) (nodename nor servname provided, or not known)
# it can not find github.com
Leonardos-MacBook-Air:~ leo$ ping github.com
PING github.com (207.97.227.239): 56 data bytes
64 bytes from 207.97.227.239: icmp_seq=0 ttl=50 time=104.279 ms
64 bytes from 207.97.227.239: icmp_seq=1 ttl=50 time=105.658 ms
# it finds it in a ping, curl, or even a browser. this shows that it's not a network (proxy) issue
NOT SO ELEGANT SOLUTION
Leonardos-MacBook-Air:~ leo$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
207.97.227.239 github.com
# I added this last line in the /etc/hosts file
Leonardos-MacBook-Air:~ leo$ git clone git://github.com/sstephenson/rbenv.git .rbenv
Cloning into '.rbenv'...
remote: Counting objects: 1040, done.
remote: Compressing objects: 100% (419/419), done.
remote: Total 1040 (delta 650), reused 959 (delta 593)
Receiving objects: 100% (1040/1040), 138.25 KiB, done.
Resolving deltas: 100% (650/650), done.
# now it works