dnf fails to install for some user due to unknown proxy setting

asked 2019-04-10 21:00:16 -0500

felichas gravatar image

Hi, I am on fedora-29. The computer is 50% of the time behind a corporate proxy, 50% of the time without proxy.
The user account I normally use is part of the wheel group and can use sudo successfully.
In the network without proxy, after changing environment variables, I can use curl, browsers, etc without problems. I can use sudo to perform system changes successfully. But I cannot use dnf.

With my unprivileged account:

$ env |grep -i proxy
$ cat /etc/dnf/dnf.conf

But if I try to install any package with dnf, it fails. The error is this. I can confirm the same behaviour in /var/log/dnf.log:

Error: Error downloading packages:
Curl error (5): Couldn't resolve proxy name for https://mirrors.fedoraproject.org/metalink?repo=updates-released-f29&arch=x86_64 [Could not resolve proxy: my.proxy.corp]

I do not understand where is this proxy setting being pulled from. If I change to root, dnf works as expected.
I can install packages only from root. I can remove packages from any account... it only fails when trying to reach out.

$ sudo su -
# dnf install gitk
# dnf remove gitk
# exit
$ sudo dnf install gitk
Error: Error downloading packages:
$ sudo su -
# dnf install gitk
# exit
$ sudo dnf remove gitk
$ sudo dnf install gitk
Error: Error downloading packages:

I have reviewed everything I can think of. Am I missing something?

edit retag flag offensive close merge delete


Do you configure you corporate proxy in Gnome's settings (in Network section)?

Also to clarify: do dnf fail when you're behind the proxy, or when you're not?

Night Romantic gravatar imageNight Romantic ( 2019-04-11 09:51:03 -0500 )edit

Also you can try curl -v 'https://mirrors.fedoraproject.org/met...' in the same setting and see if curl itself is successful or not, and if not -- does it tell you something useful.

Night Romantic gravatar imageNight Romantic ( 2019-04-11 09:59:24 -0500 )edit

Hi, I am not running Gnome, but Mate. For my user, Mate's "Network Proxy Preferences" is set to use a proxy.pac endpoint that is only reachable when I am in the corporate network. The file /etc/environment also has proxy configuration that shows up as http_proxy/https_proxy/no_proxy environment variables. When I am not in the corporate network, I run a script that unsets them. This strategy allows my user to run curl successfully everywhere (in/out corporate net) dnf works inside the corporate network, but not outside. If I understand where dnf gets this proxy from, I can fix it in the scrip.

felichas gravatar imagefelichas ( 2019-04-11 13:13:08 -0500 )edit

I don't use proxy, so there's quite a small chance I can offer something useful, only if it's something generic enough, or something like looking with a fresh eye.

Observation 1. env and sudo env do give somewhat different results on my system. Am I correct in reading from you post/comment that curl 'https://mirrors.fedoraproject.org/metalink?repo=updates-released-f29&arch=x86_64' does get mirror list successfully?

How about sudo curl the_same_url?

Also you can try sudo -i dnf install *something* (-i sets the environment to more closely resemble user's one).

Night Romantic gravatar imageNight Romantic ( 2019-04-12 01:40:01 -0500 )edit

There can be some other switches to sudo that have something to do with environment variables, I don't know any of the top of my head, but that can be explored too.

Second suggestion is to try something like sudo NO_PROXY=* dnf install *something*, i.e. manually saying any proxies should not be used for this call of dnf.

Basically, the main idea is that environment is a bit different when you call for example curl and sudo curl.

Also from all I see you should be able to recreate the same behavior (i.e. errors) with just calling curl, not dnf itself.

Night Romantic gravatar imageNight Romantic ( 2019-04-12 01:52:10 -0500 )edit