curlsusezypper

Curl download error in Zypper


I'm trying to install a package via zypper:

sudo zypper install ambari-server

Download (curl) error for 'http://public-repo-1.hortonworks.com/AMBARI-1.x/repos/suse11/repodata/repomd.xml':
Error code: Connection failed
Error message: couldn't connect to host

Apparently zypper can't connect to the server. However I'm able to download the file via cUrl directly:

 curl  'http://public-repo-1.hortonworks.com/AMBARI-1.x/repos/suse11/repodata/repomd.xml'

 <?xml version="1.0" encoding="UTF-8"?>
 <repomd xmlns="http://linux.duke.edu/metadata/repo">
      [...]
 </repomd>

I'm behind a proxy that is set up in /etc/sysconfig/proxy. Any ideas?


Solution

  • The problem was that sudo didn't preserve my environment variables like $http_proxy and $no_proxy.

    There are two possible solutions:

    1. Call sudo with the parameter -E to preserve the current environment
    2. Configure sudo to keep the proxy variables: Run visudo as root and add the following:

      Defaults env_keep+=http_proxy

      Defaults env_keep+=https_proxy

      Defaults env_keep+=no_proxy