Failing to install ruby gems required by vagrant plugin install vagrant-proxyconf

Digital Trauma

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:

enter image description here

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.

TL;DR

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?

Digital Trauma

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.

  1. Create the file 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
  1. Apply the patch:
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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Vagrant plugin install failing

From Dev

Vagrant plugin and nokogiri install issue

From Dev

vagrant-proxyconf "`split': bad URI" error on installing plugin for Vagrant

From Dev

Unable to install vagrant-hostupdater plugin during Vagrant up with VVV

From Dev

Unable to install vagrant-hostupdater plugin during Vagrant up with VVV

From Dev

Can't uninstall ruby gem Vagrant to install Vagrant via RPM

From Dev

Is it possible to install a Vagrant plugin per project?

From Dev

Can't install any vagrant plugin

From Dev

Cannot install bcrypt-ruby on vagrant machine

From Dev

Not able to install vagrant and vm

From Dev

Failure to install ruby gems with rbenv

From Dev

Ruby gems bundle install failure

From Dev

Does vagrant automatically install puppet?

From Dev

Install Apache from Puppetlabs on Vagrant

From Dev

Vagrant and NPM install on shared folder

From Dev

Vagrant: install git using Chef

From Dev

npm install within Vagrant box

From Dev

How to install and run elasticsearch in Vagrant?

From Dev

Install Apache from Puppetlabs on Vagrant

From Dev

Try to install the vagrant-hostmanager

From Dev

How to install drush for a vagrant project?

From Dev

How to install the latest version of Vagrant

From Dev

How to use Vagrant-proxyconf in multiple environments

From Dev

Getting "msg: Failed to find required executable easy_install" when trying to bring up a vagrant instance with ansible

From Dev

Getting "msg: Failed to find required executable easy_install" when trying to bring up a vagrant instance with ansible

From Dev

Does 'bundle install' install all the required gems on my computer permanently?

From Dev

I can't install one of the gems in ruby

From Dev

Ruby gems install error openssl with package installed

From Dev

Why am I Getting "Error Copying Gems" in Rubymine while setting "Ruby SDK and Gems" to use Vagrant

Related Related

  1. 1

    Vagrant plugin install failing

  2. 2

    Vagrant plugin and nokogiri install issue

  3. 3

    vagrant-proxyconf "`split': bad URI" error on installing plugin for Vagrant

  4. 4

    Unable to install vagrant-hostupdater plugin during Vagrant up with VVV

  5. 5

    Unable to install vagrant-hostupdater plugin during Vagrant up with VVV

  6. 6

    Can't uninstall ruby gem Vagrant to install Vagrant via RPM

  7. 7

    Is it possible to install a Vagrant plugin per project?

  8. 8

    Can't install any vagrant plugin

  9. 9

    Cannot install bcrypt-ruby on vagrant machine

  10. 10

    Not able to install vagrant and vm

  11. 11

    Failure to install ruby gems with rbenv

  12. 12

    Ruby gems bundle install failure

  13. 13

    Does vagrant automatically install puppet?

  14. 14

    Install Apache from Puppetlabs on Vagrant

  15. 15

    Vagrant and NPM install on shared folder

  16. 16

    Vagrant: install git using Chef

  17. 17

    npm install within Vagrant box

  18. 18

    How to install and run elasticsearch in Vagrant?

  19. 19

    Install Apache from Puppetlabs on Vagrant

  20. 20

    Try to install the vagrant-hostmanager

  21. 21

    How to install drush for a vagrant project?

  22. 22

    How to install the latest version of Vagrant

  23. 23

    How to use Vagrant-proxyconf in multiple environments

  24. 24

    Getting "msg: Failed to find required executable easy_install" when trying to bring up a vagrant instance with ansible

  25. 25

    Getting "msg: Failed to find required executable easy_install" when trying to bring up a vagrant instance with ansible

  26. 26

    Does 'bundle install' install all the required gems on my computer permanently?

  27. 27

    I can't install one of the gems in ruby

  28. 28

    Ruby gems install error openssl with package installed

  29. 29

    Why am I Getting "Error Copying Gems" in Rubymine while setting "Ruby SDK and Gems" to use Vagrant

HotTag

Archive