I am currently in a situation where I have to build a package with snapcraft when forced to go through a corporate proxy. I always get stuck at some point where snapcraft tries to access the snap store. I currently do these settings ahead of snapcraft (don’t know if all of them are required):
export http_proxy="http://192.169.1.1:8888"
export https_proxy="http://192.169.1.1:8888"
sudo snap set system proxy.http="http://192.169.1.1:8888"
sudo snap set system proxy.https="http://192.169.1.1:8888"
sudo snap set multipass proxy.http="http://192.169.1.1:8888"
sudo snap set multipass proxy.https="http://192.169.1.1:8888"
Thanks for the suggestion, I tried it and the mileage is similar. Apt stuff works fine, but in the end this happens:
Unpacking apt-transport-https (1.6.12ubuntu0.1) ...
Setting up apt-transport-https (1.6.12ubuntu0.1) ...
Waiting for network to be ready...
Failed to setup networking.
error: cannot install "snapd": Post https://api.snapcraft.io/v2/snaps/refresh: dial tcp: lookup
api.snapcraft.io on [fe80::216:3eff:fe25:e4de%39]:53: read udp
[fe80::216:3eff:fef7:50bf%eth0]:60848->[fe80::216:3eff:fe25:e4de%eth0]:53: read: connection
refused
An error occurred when trying to execute 'snap install --channel stable snapd' with 'LXD': returned exit code 1.
I set the proxy that lxd uses like this:
lxc config set core.proxy_http="http://192.169.1.1:8888"
lxc config set core.proxy_https="http://192.169.1.1:8888"
Does this make sense? I was somehow under the impression that this would need to run inside the multipass instance. And why does it succeed if I run it, but not if snapcraft runs it?
Can you try snap refresh snapcraft --channel edge/pr-3343 and see if it solves it for you?
FWIW, what you would need to do is configure snapd proxy inside the build container, something like:
lxc exec snapcraft-<project-name> snap set system proxy.http="http://192.169.1.1:8888"
lxc exec snapcraft-<project-name> snap set system proxy.https="http://192.169.1.1:8888"`
Hi CJ, thanks, thats good news! I will check it out.
FYI, at the moment it works in my own development environment (where I put myself behind a proxy to simulate the setup in a customer environment), but it does not work on the customer site. It fails when accessing the snap store (to probably check for updates of core18 etc.).
Anyway, maybe your suggestion fixes it. In the end, my mileage was better with multipass, is this the equivalent commands?:
multipass exec snapcraft-<project-name> snap set system proxy.http="http://192.169.1.1:8888"
multipass exec snapcraft-<project-name> snap set system proxy.https="http://192.169.1.1:8888"`
It sounds like you are having trouble building a package with snapcraft when you are forced to go through a corporate proxy. You have tried a few different things but still have problems. I’m sorry to hear that you are having trouble. One thing you might want to try is using a different proxy server. If you are using a corporate proxy, they may be blocking access to the snap store. You could try using a different proxy server like UK socks proxy or VPN to see if that makes a difference. Another thing you might want to try is building the package on a different computer. If you can build the package on a different computer, that would probably be the easiest way to fix the problem.