I have an Ubuntu 16.04 machine behind a proxy. From this machine I am able to use the proxy as expected using the http_proxy
and https_proxy
environment variables. However, when a new vagrant box is brought up, its provisioning script attempts HTTP accesses and fails.
The answer to this apparently is to install the vagrant-proxyconf plugin as per this SO question:
vagrant plugin install vagrant-proxyconf
With this, I run into a known problem which I am successfully able to patch, but even after that, I run into further problems, apparently HTTP-related:
$ vagrant plugin install vagrant-proxyconf
Installing the 'vagrant-proxyconf' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
Net::HTTPForbidden: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
... <snip - see rendered HTML> ...
</html>
Warning: this Gemfile contains multiple primary sources. Using `source` more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run `bundle config disable_multisource true`.
$
I saved the HTML output from this error and rendered in firefox:
This appears to indicate that the GET http://gems.hashicorp.com/quick/Marshal.4.8/io-console-0.4.3.gemspec.rz
is being denied by my corporate network for some reason, but I am able to wget
this URL from the same machine with no problems.
So my next line of attack is to attempt to install the required ruby gems manually. Previous to the above error, I ran into the same issue with the bigdecimal-1.2.6
gem. In that case, I was able to successfully install the gem manually as follows:
sudo -E gem install bigdecimal -v 1.2.6
However the io-console-0.4.3
gem is a different story. I am able to manually install versions 0.4.2 and 0.4.5, but 0.4.3 is not available on rubygems.org.
How can I install the io-console-0.4.3
gem? Or perhaps is it possible somehow to hack the dependency versions and perhaps use 0.4.5 instead?
After reading the HTTP error more carefully I realised that this is failing because my corporate firewall is blocking HTTP requests with User-Agent: bundler/1.11.2 ...
. I was able to confirm this with curl
(works) vs curl -A "bundler/1.11.2 ...
(doesn't work).
The administrative solution is to configure the corporate firewall to allow bundler as a User-Agent. I filed an internal case - we'll see where that goes...
The hacky interim technical solution is to patch the bundler source so it uses a more acceptable User-Agent.
bundler-hack-useragent.patch
with the following contents:diff --git a/fetcher.rb b/fetcher.rb
index aaf4679..e4738f4 100644
--- a/fetcher.rb
+++ b/fetcher.rb
@@ -238,7 +238,8 @@ module Bundler
end
con.read_timeout = Fetcher.api_timeout
- con.override_headers["User-Agent"] = user_agent
+# con.override_headers["User-Agent"] = user_agent
+ con.override_headers["User-Agent"] = 'curl/7.19.7'
con.override_headers["X-Gemfile-Source"] = @remote.original_uri.to_s if @remote.original_uri
con
end
sudo patch --directory /usr/lib/ruby/vendor_ruby/bundler < bundler-hack-useragent.patch
This will hardcode curl as the User-Agent in /usr/lib/ruby/vendor_ruby/bundler/fetcher.rb
. curl works with my corporate firewall, though you may have to pick something else.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments