我在http代理后面,想要使用sudo port selfupdate
更新macports。但它总是失败,输出如下:
$ sudo port -d selfupdate
DEBUG: Copying /Users/simon/Library/Preferences/com.apple.dt.Xcode.plist to /opt/local/var/macports/home/Library/Preferences
DEBUG: MacPorts sources location: /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
---> Updating MacPorts base sources using rsync
rsync: getaddrinfo: rsync.macports.org 873: nodename nor servname provided, or not known
rsync error: error in socket IO (code 10) at /SourceCache/rsync/rsync-42/rsync/clientserver.c(105) [receiver=2.6.9]
Command failed: /usr/bin/rsync -rtzv --delete-after rsync://rsync.macports.org/release/tarballs/base.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
Exit code: 10
DEBUG: Error synchronizing MacPorts sources: command execution failed
while executing
"macports::selfupdate [array get global_options] base_updated"
Error: /opt/local/bin/port: port selfupdate failed: Error synchronizing MacPorts sources: command execution failed
显然问题是rsync
没有连接到服务器,所以我单独尝试了rsync
,它给了我类似的结果。
$ sudo /usr/bin/rsync -rtzvvv --delete-after rsync://rsync.macports.org/release/tarballs/base.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
opening tcp connection to rsync.macports.org port 873
rsync: getaddrinfo: rsync.macports.org 873: nodename nor servname provided, or not known
rsync error: error in socket IO (code 10) at /SourceCache/rsync/rsync-42/rsync/clientserver.c(105) [receiver=2.6.9]
_exit_cleanup(code=10, file=/SourceCache/rsync/rsync-42/rsync/clientserver.c, line=105): about to call exit(10)
我确实设置了我的RSYNC_PROXY
环境变量并且代理正在运行,但是根据rsync
的输出,它似乎没有使用我给它的代理但是直接尝试连接而不是。有人可以帮忙吗?谢谢!
如果需要,可以提供更多信息。
$ echo $RSYNC_PROXY
127.0.0.1:3128
$ curl -x localhost:3128 http://rsync.macports.org:873/
@RSYNCD: 30.0
$ uname -a
Darwin Simon-MP.local 12.0.0 Darwin Kernel Version 12.0.0: Sun Jun 24 23:00:16 PDT 2012; root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64
答案 0 :(得分:3)
问题解决了。
事实证明sudo
确实将RSYNC_PROXY环境传递给rsync
。要保留环境sudo
,请接受-E
选项:
-E(保留环境)选项将覆盖env_reset sudoers中的选项(5))。它仅在匹配时可用 command具有SETENV标记或setenv选项在sudoers(5)中设置。