Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin installation on Windows fails due to binary JSON gem dependency. #1571

Closed
jamiebegin opened this issue Apr 10, 2013 · 9 comments
Closed

Comments

@jamiebegin
Copy link

I originally raised this issue with vmware-archive/salty-vagrant#60, but it appears to be a problem more related to Vagrant in general since it's popping up on other Vagrant plugins as well: RiotGames/berkshelf-vagrant#15

I'm not much of a Ruby guy, but it looks like there's a dependency on a JSON gem somewhere. This particular gem includes C extension that needs to be compiled, which causes the build to bomb on Windows:

C:\temp\vagtest>vagrant plugin install vagrant-salt
Installing the 'vagrant-salt' plugin. This can take a few minutes...
C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:556:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        C:/vagrant/vagrant/embedded/bin/ruby.exe extconf.rb
creating Makefile

make
generating generator-i386-mingw32.def
compiling generator.c
make: gcc: Command not found
make: *** [generator.o] Error 127


Gem files will remain installed in C:/Users/jjbegin/.vagrant.d/gems/gems/json-1.7.7 for inspection.
Results logged to C:/Users/jjbegin/.vagrant.d/gems/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:534:in `block in build_extensions'
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:509:in `each'
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:509:in `build_extensions'
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `install'
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:297:in `block in install'
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each'
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each_with_index'
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:270:in `install'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-.1.2/plugins/commands/plugin/action/install_gem.rb:27:in `block in call'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/plugins/commands/plugin/gem_helper.rb:42:in `block in with_environment'
        from C:/vagrant/vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/user_interaction.rb:40:in `use_ui'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/plugins/commands/plugin/gem_helper.rb:41:in `with_environment'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-.1.2/plugins/commands/plugin/action/install_gem.rb:23:in `call'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/lib/vagrant/action/warden.rb:34:in `call'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-.1.2/plugins/commands/plugin/action/bundler_check.rb:20:in `call'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/lib/vagrant/action/warden.rb:34:in `call'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/lib/vagrant/action/builder.rb:109:in `call'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/lib/vagrant/action/runner.rb:61:in `block in run'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/lib/vagrant/action/runner.rb:61:in `run'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/plugins/commands/plugin/command/base.rb:17:in `action'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-.1.2/plugins/commands/plugin/command/install.rb:28:in `execute'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/plugins/commands/plugin/command/root.rb:47:in `execute'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/lib/vagrant/cli.rb:46:in `execute'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/lib/vagrant/environment.rb:406:in `cli'
        from C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.2/bin/vagrant:60:in `<top (required)>'
        from C:/vagrant/vagrant/bin//../embedded/../embedded/gems/bin/vagrant:23:in `load'
        from C:/vagrant/vagrant/bin//../embedded/../embedded/gems/bin/vagrant:23:in `<main>'

C:\temp\vagtest>

Is there any way "json_pure" can be used to eliminate the need for the C extension?

@webcoyote
Copy link
Contributor

Quick fix: I'm having this problem too and discovered the fix: you need to activate the Ruby DevKit that is bundled with Vagrant. See #1619.

Important note: you'll also need to ensure that the path where Vagrant is installed does not contain parentheses -- "Program Files (x86)" causes the install to choke.

So do what I did and move your Vagrant installation to C:\bin\vagrant (or similar) after installation so that won't happen.

@mitchellh
Copy link
Contributor

Ah hah. This is still a bug with the installers then that the DevKit isn't properly activated. I'll try to get to that...

@gitfool
Copy link

gitfool commented Apr 19, 2013

You shouldn't have to run the batch file every time. Based on my limited experience with RubyInstaller for Windows and their instructions for installing the DevKit (https://github.com/oneclick/rubyinstaller/wiki/Development-Kit), I permanently updated the Vagrant embedded Ruby DevKit as follows:

  • Add C:\Program Files (x86)\HashiCorp\Vagrant\embedded\bin to PATH (after C:\Program Files (x86)\HashiCorp\Vagrant\bin)
  • Start an [elevated] command prompt in C:\Program Files (x86)\HashiCorp\Vagrant\embedded
  • Run ruby dk.rb init
  • Edit config.yml (which doesn't seem to detect the Vagrant embedded Ruby) to add the following after ---:
    - C:/Program Files (x86)/HashiCorp/Vagrant/embedded
  • Run ruby dk.rb install --force

Verify the DevKit has been hooked into Vagrant embedded Ruby:

  • Check path references to DevKit were updated in:
    • C:\Program Files (x86)\HashiCorp\Vagrant\embedded\lib\ruby\site_ruby\devkit.rb
    • C:\Program Files (x86)\HashiCorp\Vagrant\embedded\lib\ruby\site_ruby\1.9.1\rubygems\defaults\operating_system.rb

Of course this still has the problems due to being located in Program Files (x86), especially on Windows Vista or newer which requires elevation. Why not do what Opscode do with Chef on Windows and default install to C: root, so C:\HashiCorp\Vagrant?

Note Opscode also add their embedded\bin to PATH at install time - although I'm not convinced that's a good idea, especially when multiple embedded Rubies are being installed now.

@mitchellh
Copy link
Contributor

@gitfool I agree I don't think adding the whole embedded\bin to the PATH is a good idea. I won't do this.

The main bug is that the "operating_system.rb" doesn't point to the correct path for the installer. I need to modify the installer generation process to modify this file and point ito the proper place.

@gitfool
Copy link

gitfool commented Apr 19, 2013

@mitchellh Sounds good. Without rvm on Windows, we're left manipulating the PATH for each embedded Ruby, which works best when none of the Rubies manipulate the PATH themselves, if you follow me. ;)

Please seriously consider moving the default install directory to C:\HashiCorp\Vagrant or similar - outside of Program Files (x86) - especially because one needs to update files in the install directory, for example when using gem commands!

This will require an elevated prompt on newer Windows (which I'll use as shorthand for Vista or newer, when they introduced sudo like behaviour), otherwise you'll get access denied errors, or worse you won't get an error and will be virtualized instead!

So on newer Windows, an installed program should not be writing to it's installation directory, that's what ProgramData (per machine) is for. But splitting your program and data doesn't make sense for these embedded Ruby environments, so move it out of Program Files (x86) instead.

@mitchellh
Copy link
Contributor

@gitfool Actually, Vagrant already installs all gems with vagrant plugin into program data directories. :) This is so that Vagrant can be updated without cloberring your plugins.

@gitfool
Copy link

gitfool commented Apr 19, 2013

@mitchellh Nice, that does the trick then; although slightly messy as the first thing I did was add some gems into the Vagrant embedded Ruby, as I did with Chef embedded Ruby, and the RubyInstaller for Windows Ruby. So in this case I'd prefer if all the gems were in the same place so I can easily peruse them etc.

@gitfool
Copy link

gitfool commented Apr 19, 2013

@mitchellh So I just double checked, and yes I can run vagrant plugin install <plugin> from a standard user prompt, but then when I try gem install <gem> I get access denied. Try again from an elevated prompt and it works. Messy.

Also, it looks like you're installing data per user, i.e. in C:\Users\<User>\.vagrant.d. Is that your intention?

@mitchellh
Copy link
Contributor

This is fixed now.

Also, yes, installing per user is my intention, so that you can reinstall Vagrant and have things continue to work.

@ghost ghost locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants