1

I'm trying to install a package (android-studio) through ppa, and am having some troubles. I'm 95% sure it is related to the corporate proxy we're behind of.

These are my settings:

env | grep -i proxy
http_proxy=http://1.2.3.4:5678/
ftp_proxy=http://1.2.3.4:5678/
socks_proxy=socks://1.2.3.4:5678/
https_proxy=http://1.2.3.4:5678/

set | grep -i proxy
ftp_proxy=http://1.2.3.4:5678/
http_proxy=http://1.2.3.4:5678/
https_proxy=http://1.2.3.4:5678/
socks_proxy=socks://1.2.3.4:5678/
      -p --http-proxy --no-http-proxy\
      -p --http-proxy --no-http-proxy\
      -p --http-proxy --no-http-proxy\
      -p --http-proxy --no-http-proxy\
      -p --http-proxy --no-http-proxy\
      -p --http-proxy --no-http-proxy\
      -p --http-proxy --no-http-proxy\

Then, when I execute the command, the process gets stuck while trying to download the package from terminal.

sudo apt-get install android-studio
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
Paquetes sugeridos:
  default-jdk
Se instalarán los siguientes paquetes NUEVOS:
  android-studio
0 actualizados, 1 se instalarán, 0 para eliminar y 2 no actualizados.
4 no instalados del todo o eliminados.
Se necesita descargar 0 B/36,2 kB de archivos.
Se utilizarán 98,3 kB de espacio de disco adicional después de esta operación.
(Leyendo la base de datos ... 885309 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../android-studio_162.3934792~trusty_amd64.deb ...
--2017-05-18 10:37:30--  https://dl.google.com/dl/android/studio/ide-zips/2.3.2.0/android-studio-ide-162.3934792-linux.zip
Resolviendo dl.google.com (dl.google.com)... 216.58.202.206, 2800:3f0:4001:815::200e
Conectando con dl.google.com (dl.google.com)[216.58.202.206]:443... 

PS: I can download the file through browser, and using wget from terminal

Does any1 know how I could solve this, even if I have to use a temporal setting or command?

Thanks

Enrique
  • 339
  • instead of sudo apt-get install android-studio run LC_ALL=c sudo apt-get install android-studio and add the output to your question, so it's more helpful to diagnose your problem. – Ravexina May 18 '17 at 13:59
  • Your proxy seems to be IPv4 and the address is resolving to IPv6 – muru May 18 '17 at 14:47
  • @Ravexina here's the output with suggested command https://pastebin.com/pe1z6ze5 – Enrique May 18 '17 at 15:26
  • Your question has been marked as a duplicate question, see the duplicate question it might help you. – Ravexina May 18 '17 at 15:27
  • @muru please check, tried the suggestion in the question you link, but I think that is not an IPv4 related problem, the output is the same... https://pastebin.com/ycrmdmxf – Enrique May 18 '17 at 15:35
  • @Ravexina no, it didn't help, nor LC_ALL=c command as you can see in the previous pastebin link. Thanks – Enrique May 18 '17 at 15:36
  • Add the output of sudo env | grep -i proxy and sudo -l, please – muru May 18 '17 at 15:37
  • @muru here it is. thanks https://pastebin.com/gayDz55U – Enrique May 18 '17 at 15:49
  • @muru sudo env | grep -i proxy throws nothing, maybe there is the problem – Enrique May 18 '17 at 15:50
  • You see the env_reset there? That means the environment variables are being reset. Set your apt proxy settings in apt.conf instead. See https://askubuntu.com/questions/257290/configure-proxy-for-apt – muru May 18 '17 at 15:51
  • @muru then how it comes that env | grep -i proxy (and) set | grep -i proxy commands do the output with the proxy settings I've already have? I mean, suto apt-get update works fine, wget fine, but this only thing that tries to download a file don't... maybe sudo does not have proxy set? – Enrique May 18 '17 at 15:53
  • Yes, sudo resets the environment because env_reset is set in sudo's configuration. – muru May 18 '17 at 15:54
  • @muru i've went with gksudo gedit /etc/apt/apt.conf and here is the output. I mean, I've aready the proxy settings in that file .... http://storage5.static.itmages.com/i/17/0518/h_1495122998_1352957_e3312245dd.jpeg – Enrique May 18 '17 at 15:58
  • Hi again @muru I've noticed i'm having this problem only when bash needs to get a https url on the 443 port. I don't know why but I've specified https in every config file as stated in original question... the problem occurs when i sudo and when not sudoing... http://storage1.static.itmages.com/i/17/0524/h_1495642381_5306668_8ad43e2cad.jpeg – Enrique May 24 '17 at 16:13

2 Answers2

0

From my experience, terminal does not respect gnome system settings.

When we had a coporate proxy, we needed to set those in .bashrc. So, set your proxy in ~/.bashrc by adding these lines to the end of the file and try again (it might be enough to set http and https proxy only, but you never know...) :

export http_proxy=http://1.2.3.4:5678/
export ftp_proxy=http://1.2.3.4:5678/
export socks_proxy=socks://1.2.3.4:5678/
export https_proxy=http://1.2.3.4:5678/

.bashrc is executed every time you start up a terminal. So do not forget to close and reopen your terminal after saving .bashrc.

Good luck and have fun.

mondjunge
  • 3,296
  • thanks @mondjunge but no luck. Added those lines to the end of ~/.bashrc then exited the terminal, restarted, but again it hangs on https://pastebin.com/ycrmdmxf – Enrique May 18 '17 at 16:03
  • can you download the file in terminal with wget https://dl.google.com/dl/android/studio/ide-zips/2.3.2.0/android-studio-ide-162.3934792-linux.zip? If yes, you have a problem with AptGet, if no, there is still a connection problem in terminal. – mondjunge May 18 '17 at 16:11
  • Yes, as described in the question, i can download the file with wget in terminal... – Enrique May 18 '17 at 16:17
  • that's odd. Might be a wild guess, but have you tried using apt instead of apt-get? I guess you already know that you can just download the zip and unpack it somewhere to home to use it. – mondjunge May 18 '17 at 19:54
  • yes, will try that... and in case i get no luck, will install manually... – Enrique May 19 '17 at 14:59
0

I've created a script to make it easier for the new user to record their proxy credentials without relying on a third party. Modify the proxy addresses for your (ironport ...)

#!/bin/bash

clear
if [ $(id -u) != "0" ]; then
    echo "You must be the superuser to run this script" >&2
    exit 1
fi



echo "******************************************************************************"
echo "*                                                                            *"
echo "*                                                                            *"
echo "*                          Salvar credenciais no PC                          *"
echo "*                                                                            *"
echo "*                                                                            *"
echo "******************************************************************************" 
echo                                                                            
echo "Digite sua m#chmod 755 $HOME/script/enviromentatricula do XXX de até 4 digitos"
read matricula    
clear #!/bin/bash
echo "******************************************************************************"                                                       
echo "*                                                                            *"
echo "*                       Sua matricula é $matricula                           *"
echo "*                                                                            *"
echo "******************************************************************************"
echo "Digite sua senha do TRT" 
read -s senha
echo "************************* Criando arquivos **********************************"
local="http://"$matricula":"$senha"@ironport.br:80/"
local1="https://"$matricula":"$senha"@ironport.br:80/"
local2="ftp://"$matricula":"$senha"@ironport.br:80/"
local3="socks://"$matricula":"$senha"@ironport.br:80/"
#echo -e "HTTP_proxy $local \nFTP_proxy=$local \nHTTPS_proxy=$local \n" "http_proxy=$local \n""ftp_proxy $local \n""https_proxy $local"
echo -e "HTTP_proxy=$local \nFTP_proxy=$local \nHTTPS_proxy=$local \nhttp_proxy=$local \nftp_proxy=$local \nhttps_proxy=$local" > tmpfile
#mv tmpfile $HOME/script/enviroment
#chmod 755 $HOME/script/enviroment
#mv tmpfile /etc/enviroment
cat tmpfile > $HOME/script/environment
cat tmpfile > /etc/environment
chmod 755 /etc/enviroment
echo -e "Acquire::http::proxy \"$local\"; \nAcquire::https::proxy \"$local1\"; \nAcquire::ftp::proxy \"$local2\"; \nAcquire::socks::proxy \"$local3\"; "> apt
#mv apt $HOME/script/apt.conf
#mv apt /etc/apt/apt.conf
cat apt.txt > $HOME/script/apt.conf
cat apt.txt > /etc/apt/apt.conf
clear 
echo "******************************************************************************"
echo "*                                                                            *"
echo "*         Arquivos gravados com sucesso                                      *"
echo "*         /etc/environment                                                   *"
echo "*         /etc/apt/apt.conf                                                  *"
echo "*                                  Cópia de I                                          *"
echo "******************************************************************************" 
echo " testar configuração digite S" Cópia de I
read testar
if [ $testar = "S" ]; then
    apt-get update
fi

save as arquivo.sh and chmod -x ./arquivo.sh and run ./arquivo.sh

To test without the super user comment (#) lines 4, 5, 6 and 7

derHugo
  • 3,356
  • 5
  • 31
  • 51
Max
  • 31
  • 1
    sory error in this scrip change "mv" lines cat tmpfile > $HOME/script/environment cat tmpfile > /etc/environment chmod 755 /etc/environment

    cat apt.txt > $HOME/script/apt.conf cat apt.txt > /etc/apt/apt.conf

    – Max May 22 '17 at 16:44