proxy - 如何暂时禁用用于安装软件包的 apt 代理设置
问题描述
Apt 能够使用代理来安装附加包以及依赖项。我正在开发一个 Python 项目,我需要一些额外的包来提供一个库。
---> sudo apt-get update
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Could not resolve 'proxy.internal'
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Could not resolve 'proxy.internal'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Could not resolve 'proxy.internal'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Could not resolve 'proxy.internal'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Could not resolve 'proxy.internal'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Could not resolve 'proxy.internal'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Could not resolve 'proxy.internal'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Could not resolve 'proxy.internal'
W: Some index files failed to download. They have been ignored, or old ones used instead.
如何临时禁用代理(不更改永久选项/设置)?最好从命令行。
解决方案
在不更改永久设置的情况下临时禁用代理配置的最快方法是使用如下命令行选项:
sudo apt-get -o Acquire::http::proxy=false install <package>
这为用户提供了在开放/公共/家庭网络和带有代理的公司环境之间的移动性。从手册页:
-o, --option Set a Configuration Option; This will set an arbitrary configuration option. The syntax is -o Foo::Bar=bar. -o and --option can be used multiple times to set different options.
推荐阅读
- node.js - 是否可以在仓库中克隆仓库并只提交到内部仓库?
- javascript - 无法使用 REGEX 更改/获取 JSON 值,它返回未定义
- google-apps-script - Google 应用程序脚本函数在 90% 的情况下运行良好,但偶尔会抛出错误:“TypeError: Cannot read property 'length' of undefined”
- python - 使用 Statsmodels 进行 SARIMAX 预测是否存在问题?
- html - 引导程序不起作用:导航栏未正确加载
- asp.net-mvc - 帖子上的 ASP.NET Core MVC 视图模型属性为空
- terraform - Terraform 转义序列
- java - 尽管绑定/连接地址匹配,为什么我会间歇性地收到 PortUnreachableException?
- java - 无论手机处于何种状态,如何确保我的应用程序继续运行?
- azure - 即使身份验证成功,邮递员 OAuth 2.0“请求 url 为空”错误