tmatilai / vagrant-proxyconf

Vagrant plugin that configures the virtual machine to use proxies
MIT License
531 stars 74 forks source link

pip doesn't recognize proxy settings #84

Closed fernandojsg closed 10 years ago

fernandojsg commented 10 years ago

Dear all,

I've used vagrant-proxyconf and it works well with apt-get without problems, but It seems it's not recognized by pip so I need to set it by hand like:

exec { "pip-install-requirements":
    command => "sudo /usr/bin/pip install --proxy http://myproxy:8080 -r $proj_dirrequirements.txt",
    tries => 2,
    timeout => 600, # Too long, but this can take awhile
    require => Package['python-pip', 'python-dev'], # The package dependecies needs to run first
    logoutput => on_failure,
 }

Is there any way to get it working with the plugin? Or at least access to the config.proxy.http variables defined on the VagrantFile ?

otahi commented 10 years ago

Hi, @kile.

Can you give more information?

I don't use python very much. So I'm not familiar pip. But I found StackOverFlow:Using pip behind a proxy sudo -E pip install somepackage

Can you try it?

fernandojsg commented 10 years ago

Hi @otahi Thank you very much! It works with the sudo -E option. It seems that the HTTP_PROXY environment variable is not set for the root user so it needs the -E option.

Now I've it workiing without problem.

Btw the OS was a Ubuntu Server 14 and this code correspond to a provision puppet file for installing python packages.

Thank you again

sradhakrishna commented 9 years ago

@otahi, @fernandojsg,

Am in a similar situation - pip doesn't work behind proxy in my vagrant guest. Can you please help me address this?

Where do I setup the sudo -E option? In VagrantFile?

Can you please help elaborate?

Regards, Radha.

fernandojsg commented 9 years ago

Hi @sradhakrishna You should inlcude the -E option where you call pip.

I've a puppet module for install python requirements. This of this file (puppet\modules\python\manifests\init.pp) is the following:

class python {

    package { [ 'python', 'python-virtualenv', 'python-dev', 'python-pip', 'build-essential',
        'libxml2-dev', 'libxslt1-dev', 'python-lxml',
        'libjpeg8', 'libjpeg62-dev', 'libfreetype6', 'libfreetype6-dev' ]:
        ensure => installed,
    }

    # Let's install the project dependecies from pip
    exec { "pip-install-requirements":
        command => "sudo -E /usr/bin/pip install -r /vagrant/serverside/requirements.txt",
        tries => 2,
        timeout => 600, # Too long, but this can take awhile
        require => Package['python-pip', 'python-dev'], # The package dependecies needs to run first
        logoutput => on_failure,
    }
}

Note how I use a command with sudo -E to install the packages required by my webapp, defined on a .txt instead of the puppet itself.