tmatilai / vagrant-proxyconf

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

Problems with manual installation / Plugin not working #70

Closed kevinpapst closed 10 years ago

kevinpapst commented 10 years ago

Hi!

Thanks for your plugin, very much appreciated :+1:

I have an obscure problem, which I cannot solve and like to ask for your help. Usecase is a simple setup of a new Vagrant Linux-Guest box on a Windows machine behind a companies very restrictive proxy.

I couldn't use the default "vagrant plugin install vagrant-proxyconf" due to the proxy (even with env vars HTTP_PROXY and HTTPS_PROXY set). So I downloaded two different version (the https://github.com/tmatilai/vagrant-proxyconf/releases/tag/v1.2.0 and master) which both have the same problem. Installation as suggested via wiki worked:

C:\HashiCorp\Vagrant\embedded\bin\gem build vagrant-proxyconf.gemspec
vagrant plugin install vagrant-proxyconf-*.gem

But when using "vagrant up" or "vagrant reload --provision" I always receive the message:

There are errors in the configuration of this machine. Please fix the following errors and try again:

Vagrant:
* Unknown configuration section 'proxy'.

The Vagrantfile is as simple as possible:

Vagrant.configure("2") do |config|
  config.vm.box = "puphpet/centos65-x64"
  config.vm.box_url = "puphpet/centos65-x64"

  if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http = "http://myproxyip:8080/"
  else
    raise 'ProxyConf plugin not installed!'
  end
end

The raise condition is never met, so the plugin seems to be loaded (just to make sure: I tried to moved the raise into the if_has_plugin clause and the provisioning stopped directly with the expected "ProxyConf plugin not installed!" message).

Here is some output using the "vagrant reload --provision --debug" flag:

INFO global: Vagrant version: 1.6.3
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: VAGRANT_EXECUTABLE="C:\\HashiCorp\\Vagrant\\embedded\\gems\\gems\\vagrant-1.6.3\\bin\\vagrant"
INFO global: VAGRANT_HTTPS_PROXY="\"http://myProxy:8080\""
INFO global: VAGRANT_HTTP_PROXY="\"http://myProxy:8080\""
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="C:\\HashiCorp\\Vagrant\\embedded"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1"
INFO global: VAGRANT_LOG="debug"
INFO global: VAGRANT_YUM_HTTP_PROXY="\"http://myProxy:8080\""
INFO global: Plugins:
INFO global:   - bundler = 1.6.2
INFO global:   - mime-types = 2.3
INFO global:   - rest-client = 1.6.7
INFO global:   - vagrant-login = 1.0.1
INFO global:   - vagrant-proxyconf = 1.3.3.dev
INFO global:   - vagrant-share = 1.1.0

Which tells me that the plugin is loaded, same applies for "vagrant plugin list":

vagrant-login (1.0.1, system)
vagrant-proxyconf (1.3.3.dev)
  - Version Constraint: 1.3.3.dev
vagrant-share (1.1.0, system)

I use Vagrant 1.6.3 as seen in "vagrant version":

Installed Version: 1.6.3
Latest Version: 1.6.3

You're running an up-to-date version of Vagrant!

Now being at home I tried 'vagrant plugin install vagrant-proxyconf' on my Mac and the box/plugin is working as expected. So it must be either the Windows7 environment at work or the installation method.

Can you give me some hints on how to debug the problem? It seems that the plugin is not loaded properly, as config.proxy is not registered as possible key.

tmatilai commented 10 years ago

Hi Kevin,

Nice that you like the plugin! =)

And sorry for problems. To be honest, I don't right away understand what's the issue. I run Vagrant 1.6.3 on OS X with the master version of vagrant-proxyconf just fine. Could you please gist the full debug output of a failed run. You can get it to file with:

vagrant up --debug > vagrant.log 2>&1

I don't normally have access to a Windows machine so it's difficult for me to debug this myself.

By the way, you can also install a released version of any plugin by downloading the gem manually from rubygems.org (e.g. https://rubygems.org/gems/vagrant-proxyconf) and installing it with vagrant plugin install.

tmatilai commented 10 years ago

Oh, and why doesn't the normal installation work even with HTTP_PROXY and HTTPS_PROXY env vars? A Vagrant issue or too enthusiastic filtering rules on the proxy?

kevinpapst commented 10 years ago

Too strict proxy rules, I couldn't even download the released gem file, thats why I used the source code built. I am trying to get the IT department to remove some of these proxy rules, because further puppet installations will fail too, but you might know that feeling: once you wrap your head around a problem, you just have to solve it ;-)

Will upload the full debug log tomorrow and thanks for your quick feedback! And if you have any idea what I could do to debug the problem, let me know. I am not a ruby dev, but I should be able to add some debug messages and recompile the plugin.

otahi commented 10 years ago

how about http_proxy for environment?

otahi commented 10 years ago

@kevinpapst It could be the strict proxy rules..

Your computer seems Windows machine. So I checked the execution on my windows7 machine. The result of vagrant plugin install vagrant-proxyconf on my machine is like that. (a little old vagrant version)

Have you done like this?

C:\tmp>vagrant --version
Vagrant 1.4.2

C:\tmp>set HTTP_PROXY=
C:\tmp>vagrant plugin install vagrant-proxyconf
Installing the 'vagrant-proxyconf' plugin. This can take a few minutes...
The plugin 'vagrant-proxyconf' could not be found in local or remote
repositories. Please check the name of the plugin and try again.

C:\tmp>set HTTP_PROXY=http://myproxy:3128/
C:\tmp>vagrant plugin install vagrant-proxyconf
Installing the 'vagrant-proxyconf' plugin. This can take a few minutes...
Installed the plugin 'vagrant-proxyconf (1.3.2)'!
C:\tmp>
kevinpapst commented 10 years ago

Hey guys, thanks for all your feedback. @otahi I tried all that before I posted here. The proxy blocked the ruby client (or whatever fetches the gems when using "vagrant plugin install"), assuming that it is some kind of infected browser.

My real problem was: Vagrant reported that it loaded the proxyconf plugin but at the same time reported that the config section ".proxy" was unknown.

Must have been somehow related to my build from the source code. Today I brought the downloaded plugin gem (from rubygems) from home to work today and after installing that one everything worked now!

I don't know why the version that I did built from the sources had that problem, as I got no error during building the gem. I tried it on two different Windows7 machines with the same result. But as it works now with the pre-built version => I am closing this issue.

Sorry for stealing your time ;-)

tmatilai commented 10 years ago

@kevinpapst if you have time and can still reproduce the issue on Windows and bleeding edge plugin version, I would be interested to see the full debug log. That anyway feels like a bug somewhere (probably in Vagrant itself).

kevinpapst commented 10 years ago

Sure, I will sent you the full debug output next week.

btrepp commented 10 years ago

I was trying to running bleeding edge to get docker support :(. Getting the same issue

Debug log is here https://gist.github.com/btrepp/be32169ea83b7c289878

Kindof strange actually. The proxy config stuff is in a detection block

        if Vagrant.has_plugin?("vagrant-proxyconf")
                config.proxy.http ="http://10.0.2.2:8888"
                config.proxy.https="http://10.0.2.2:8888"
                config.proxy.no_proxy="localhost,127.0.0.1"
        end

So that's interesting, it seems like it knows proxyconf is installed, but its not attaching the proxy object to config when it does.

tmatilai commented 10 years ago

Yes, that's really strange. The plugin is listed in the beginning of the debug output, but it's never loaded/registered later. I can try to investigate later, but might be difficult as there are no hints of any kind in the debug log.

btrepp commented 10 years ago

This was actually me failing to build the gem correctly. I had to tweak the gemspec (git's not on the path for how vagrant needs it. Windows ends up being a horrible combination of cygwin+normal shell and remembering which tool runs where).

So I had to edit the spec.files section in the gemspec, and I messed up and didn't include the lib folder properly :(. Fixing that mistake and re-installing it made it work.

runefs commented 9 years ago

I had a similar issue running

vagrant plugin install vagrant-proxyconf --plugin-source file://vagrant-proxyconf.1.4.4.gem

however running

vagrant plugin install vagrant-proxyconf.1.4.0.gem

worked

shriharshmishra commented 9 years ago

runefs's approach worked for me as well.