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

Get Error .../kernel_require.rb:54:in `require': cannot load such file -- nokogiri (LoadError) after update Vagrant 1.9.4 -> 1.9.5 #8593

Closed
mediaessenz opened this issue May 16, 2017 · 11 comments

Comments

@mediaessenz
Copy link

mediaessenz commented May 16, 2017

Vagrant version

1.9.5

Host operating system

macOS 10.12.5 with latest Parallels Desktop 12.2.0 (41591) Pro and installed vagrant-parallels (1.7.4) Plugin

Guest operating system

ubuntu 16.04

Vagrantfile

Comes from here: https://github.com/webdevops/vagrant-docker-vm

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = 2

########################
## Customization
########################

VAGRANT_CUSTOMIZATION = Proc.new {|config|
    ## Port forwardings

    # Public HTTP server
    # config.vm.network "forwarded_port", guest: 80, host: 80, auto_correct: true
    # config.vm.network "forwarded_port", guest: 443, host: 443, auto_correct: true

    # MySQL (local only)
    # config.vm.network "forwarded_port", guest: 13306, host: 3306, host_ip: '127.0.0.1', auto_correct: true

    # Docker port (local only)
    # config.vm.network "forwarded_port", guest: 2375, host: 2375, host_ip: '127.0.0.1', auto_correct: true

    ## Networks

    # Public network
    #  |WARNING| This can be a big security issue and an attacker could
    #  |WARNING| gain access also to host (because of shares or services)!
    #  |WARNING| Only use if you're sure about the risks!
    #  |WARNING| If you need access to services use the port forwarding features!
    # config.vm.network "public_network"
}

###############################################################################
## YAML configuration loader
###############################################################################

require 'yaml'

path = "#{File.dirname(__FILE__)}"

# Get machine configuration
configuration = {}
if File.exist?(path + '/vm.yml')
	configuration = YAML::load(File.read(path + '/vm.yml')) || {}
end

## Defaults

if !configuration['VM'].has_key?('sharedFolder') or !configuration['VM']['sharedFolder']
    configuration['VM']['sharedFolder'] = {}
end

if !configuration['VM'].has_key?('portForwarding') or !configuration['VM']['portForwarding']
    configuration['VM']['portForwarding'] = {}
end

if !configuration['VM']['network'].has_key?('bridged') or !configuration['VM']['network']['bridged']
    configuration['VM']['network']['bridged'] = {}
end


###############################################################################
## --- Do not edit below ---
###############################################################################

###############################################################################
## --- OS detection ---
###############################################################################

module OS
    def OS.windows?
        (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
    end

    def OS.mac?
        (/darwin/ =~ RUBY_PLATFORM) != nil
    end

    def OS.unix?
        !OS.windows?
    end

    def OS.linux?
        OS.unix? and not OS.mac?
    end
end

###############################################################################
## --- Ressource detection ---
###############################################################################

if configuration['VM']['cpu'] =~ /auto/
  if OS.mac?
    configuration['VM']['cpu'] = `sysctl -n hw.ncpu`.to_i
  elsif OS.linux?
    configuration['VM']['cpu'] = `nproc`.to_i
  else
    configuration['VM']['cpu'] = 2
  end
end

if configuration['VM']['memory'] =~ /auto/
  if OS.mac?
    configuration['VM']['memory'] = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
  elsif OS.linux?
    configuration['VM']['memory'] = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
  else
    configuration['VM']['memory'] = 2048
  end

  # at least 1 GB
  if configuration['VM']['memory'].to_i < 1024
    configuration['VM']['memory'] = 1024
  end
end

###############################################################################
## --- Disc setup ---
###############################################################################

require 'shellwords'
VAGRANT_ROOT = File.dirname(File.expand_path(__FILE__))
DiskVmData = File.join(VAGRANT_ROOT, '/disks/vm-data.vdi')

###############################################################################
## --- Vagrant setup ---
###############################################################################

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = configuration['VM']['image']
    config.vm.box_check_update = true

    #################
    # Provider: Parallels
    #################

    # Parallels
    config.vm.provider :parallels do |v|
        v.name   = configuration['VM']['name']
        v.memory = configuration['VM']['memory']
        v.cpus   = configuration['VM']['cpu']
        v.update_guest_tools = true

        # Used linked base images, save disk space (Parallels >= 11)
        # see https://parallels.github.io/vagrant-parallels/docs/configuration.html
        v.linked_clone = true

        if configuration['VM']['gui']
            v.customize ["set", :id, "--startup-view", "window"]
            v.customize ["set", :id, "--on-window-close", "suspend"]
        else
            v.customize ["set", :id, "--startup-view", "headless"]
        end

        v.customize(
            "post-import", [
                "set", :id,
                 "--device-add", "hdd",
                 "--image", "#{VAGRANT_ROOT}/disks/parallels-disk",
                 "--type", "expand",
                 "--size", configuration['VM']['data']['size'] * 1024,
            ]
        )

        v.customize "pre-boot", [
          "set", :id,
          "--device-bootorder", "hdd0 hdd1"
        ]
    end

    #################
    # Provider: VMware
    #################

    # VMware Fusion and Workstation
    [:vmware_fusion, :vmware_workstation].each do |provider|
        config.vm.provider provider do |v|
            v.gui = configuration['VM']['gui']
            v.vmx["memsize"]  = configuration['VM']['memory']
            v.vmx["numvcpus"] = configuration['VM']['cpu']

            v.vmx['scsi0:1.filename'] = "#{VAGRANT_ROOT}/disks/data"
            v.vmx['scsi0:1.present']  = 'TRUE'
            v.vmx['scsi0:1.redo']     = ''
        end
    end

    #################
    # Provider: VirtualBox
    #################

    # VirtualBox
    config.vm.provider :virtualbox do |v|
        v.gui = configuration['VM']['gui']
        v.customize ["modifyvm", :id, "--name",                configuration['VM']['name']]
        v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
        v.customize ["modifyvm", :id, "--memory",              configuration['VM']['memory']]
        v.customize ["modifyvm", :id, "--cpus",                configuration['VM']['cpu']]
        v.customize ["modifyvm", :id, "--chipset",             "ich9"]
        v.customize ["modifyvm", :id, "--ioapic",              "on"]
        v.customize ["modifyvm", :id, "--rtcuseutc",           "on"]
        v.customize ["modifyvm", :id, "--pae",                 "on"]
        v.customize ["modifyvm", :id, "--hwvirtex",            "on"]
        v.customize ["modifyvm", :id, "--nestedpaging",        "on"]

        v.customize ["modifyvm", :id, "--natdnsproxy1",        "on"]
        v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]

        # GFX settings
        v.customize ["modifyvm", :id, "--vram",               configuration['VM']['vram']]
        v.customize ["modifyvm", :id, "--graphicscontroller", "vboxvga"]
        v.customize ["modifyvm", :id, "--accelerate2dvideo",  "on"]
        v.customize ["modifyvm", :id, "--accelerate3d",       "on"]

        # second disk
        unless File.exist?(DiskVmData)
            v.customize ['createhd', '--filename', DiskVmData, '--size', configuration['VM']['data']['size'] * 1024]
            # v.customize ['modifyhd', DiskVmData, '--type', 'multiattach']
        end
        v.customize ['storageattach', :id, '--storagectl', configuration['VM']['virtualbox']['diskController'], '--port', 1, '--device', 0, '--type', 'hdd', '--medium', DiskVmData]

        # network
        v.customize ["modifyvm", :id, "--nictype1", "virtio"]
        v.customize ["modifyvm", :id, "--nictype2", "virtio"]
    end

    #################
    # Networking :: private
    #################
    config.vm.network "private_network",
        ip: configuration['VM']['network']['private']['address']


    #################
    # Networking :: public
    #################

    if configuration['VM']['network']['bridged'] && configuration['VM']['network']['bridged']['address'] != "false"
        if configuration['VM']['network']['bridged']['address'] == "auto"
            #################
            # auto bridged (dhcp)
            #################
            if configuration['VM']['network']['bridged']['bridge'] && configuration['VM']['network']['bridged']['bridge'] != ""
                config.vm.network "public_network",
                    bridge: configuration['VM']['network']['bridged']['bridge']
            else
                config.vm.network "public_network"
            end
        elsif configuration['VM']['network']['bridged']['address'] && configuration['VM']['network']['bridged']['address'] != ""
            #################
            # auto bridged (dhcp)
            #################
            config.vm.network "public_network",
                ip: "#{configuration['VM']['network']['bridged']['address']}",
                bridge: configuration['VM']['network']['bridged']['bridge']
      end
    end

    #################
    # Port forwarding
    #################

    configuration['VM']['portForwarding'].each do |port|
        if !port.has_key?('guestIP')
            port['guestIp'] = ''
        end

        if !port.has_key?('hostIp')
            port['guestIp'] = ''
        end

        if !port.has_key?('protocol')
            port['protocol'] = 'tcp'
        end

        config.vm.network :forwarded_port,
            guest: "#{port['guest']}",
            guest_ip: "#{port['guestIP']}",
            host: "#{port['host']}",
            host_ip: "#{port['hostIp']}",
            protocol: "#{port['protocol']}"
    end

    #################
    # Shared folders
    #################

    # Ensure proper permissions for nfs mounts
    config.nfs.map_uid = Process.uid
    config.nfs.map_gid = Process.gid

    configuration['VM']['sharedFolder'].each do |mount|
        if !mount.has_key?('type')
            mount['type'] = 'vm'
        end

        if mount['type'] =~ /home/
            #################
            # Home (only unix)
            #################
            if OS.unix?
                config.vm.synced_folder "#{ENV['HOME']}",
                    "#{ENV['HOME']}",
                    :nfs => { :mount_options => [ "dmode=775", "fmode=774" ] }
            end

        elsif mount['type'] =~ /nfs/
            #################
            # NFS
            #################
            config.vm.synced_folder "#{mount['src']}",
                "#{mount['target']}",
                :nfs => { :mount_options => [ "dmode=775", "fmode=774" ] }

        elsif mount['type'] =~ /smb/
            #################
            # CIFS/SMB
            #################
            config.vm.synced_folder "#{mount['src']}",
                "#{mount['target']}",
                type: "smb"

        else
            #################
            # VM (built-in)
            #################
            config.vm.synced_folder "#{mount['src']}",
                "#{mount['target']}"
        end
    end

    #################
    # Workarounds
    #################
    #config.ssh.host = configuration['VM']['network']['private']['address']
    if configuration['VM']['workaround']['useSshPasswordAuth']
        # Fallback ssh connection (https://github.com/mitchellh/vagrant/issues/5186)
        # -> Authentication issues? Workaround:
        config.ssh.username = 'vagrant'
        config.ssh.password = 'vagrant'
    end


    #################
    # Provisioning
    #################

    # Workaround: shell is not a tty
    config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

    # Bootstrap (only first time)
    config.vm.provision "bootstrap", type: "shell" do |s|
        s.inline = "sudo bash /vagrant/provision/bootstrap.sh"
    end

    # Maintenance (run always)
    config.vm.provision "maintenance", run: "always", type: "shell" do |s|
        s.inline = "sudo bash /vagrant/provision/maintenance.sh"
    end

    #################
    # Customization
    #################

    VAGRANT_CUSTOMIZATION.call(config)

end

Debug output

/opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- nokogiri (LoadError)
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/alex/.vagrant.d/gems/2.2.5/gems/vagrant-parallels-1.7.4/lib/vagrant-parallels/driver/base.rb:2:in `<top (required)>'
    from /Users/alex/.vagrant.d/gems/2.2.5/gems/vagrant-parallels-1.7.4/lib/vagrant-parallels/driver/meta.rb:4:in `require_relative'
    from /Users/alex/.vagrant.d/gems/2.2.5/gems/vagrant-parallels-1.7.4/lib/vagrant-parallels/driver/meta.rb:4:in `<top (required)>'
    from /Users/alex/.vagrant.d/gems/2.2.5/gems/vagrant-parallels-1.7.4/lib/vagrant-parallels/provider.rb:16:in `usable?'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:138:in `machine_config'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:45:in `machine'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:669:in `machine'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:177:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:201:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:201:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:183:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:183:in `with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/up/command.rb:131:in `install_providers'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/up/command.rb:85:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/cli.rb:42:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:308:in `cli'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/bin/vagrant:138:in `<main>'

Expected behavior

A ubuntu system to handle docker container should startup

Actual behavior

See error above

Steps to reproduce

vagrant up

References

No

@chrisroberts
Copy link
Member

Please try re-installing the plugin:

$ vagrant plugin install vagrant-parallels

If that does not resolve the error, please feel free to re-open the issue. Cheers!

@mediaessenz
Copy link
Author

mediaessenz commented May 17, 2017

I already tried this, but it did not workout (vagrant plugin update and now your suggest)

There is no newer version than 1.7.4 available at the moment.

How can I reopen this issue?

@legal90
Copy link
Contributor

legal90 commented May 18, 2017

@chrisroberts Has nokogiri been removed from Vagrant in v1.9.5 release?
Parallels/vagrant-parallels#297 (comment)


@mediaessenz Have you tried to re-install the plugin?

vagrant plugin uninstall vagrant-parallels
vagrant plugin install vagrant-parallels

@mediaessenz
Copy link
Author

If have tried it, but the problem still exists

@ghost
Copy link

ghost commented May 25, 2017

I'm experiencing the same problem

@mediaessenz
Copy link
Author

mediaessenz commented May 31, 2017

Could somebody reopen this issue please, due the problem is not solved

@legal90
Copy link
Contributor

legal90 commented May 31, 2017

Hi all! This is how it could be worked around for vagrant-parallels under Vagrant v1.9.5:

vagrant plugin uninstall vagrant-parallels
NOKOGIRI_USE_SYSTEM_LIBRARIES=true vagrant plugin install vagrant-parallels

@mediaessenz
Copy link
Author

If I do vagrant plugin uninstall vagrant-parallels I get this error:

Uninstalling the 'vagrant-parallels' plugin...
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:

Unable to resolve dependency: user requested 'vagrant-share (= 1.1.7)'

@mediaessenz
Copy link
Author

After uninstall vagrant-share first and vagrant-parallels after, it works.

But now I get this error, when execute NOKOGIRI_USE_SYSTEM_LIBRARIES=true vagrant plugin install vagrant-parallels:

Installing the 'vagrant-parallels' plugin. This can take a few minutes...
Fetching: mini_portile2-2.1.0.gem (100%)
Fetching: nokogiri-1.7.2.gem (100%)
Building native extensions.  This could take a while...
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:

ERROR: Failed to build gem native extension.

    /opt/vagrant/embedded/bin/ruby -r ./siteconf20170531-32366-hv0lux.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using system libraries.
ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/opt/vagrant/embedded/bin/$(RUBY_BASE_NAME)
	--help
	--clean
	--use-system-libraries=true
	--with-zlib-dir
	--without-zlib-dir
	--with-zlib-include
	--without-zlib-include=${zlib-dir}/include
	--with-zlib-lib
	--without-zlib-lib=${zlib-dir}/lib
	--with-xml2-dir
	--without-xml2-dir
	--with-xml2-include
	--without-xml2-include=${xml2-dir}/include
	--with-xml2-lib
	--without-xml2-lib=${xml2-dir}/lib
	--with-libxml-2.0-config
	--without-libxml-2.0-config
	--with-pkg-config
	--without-pkg-config
	--with-xslt-dir
	--without-xslt-dir
	--with-xslt-include
	--without-xslt-include=${xslt-dir}/include
	--with-xslt-lib
	--without-xslt-lib=${xslt-dir}/lib
	--with-libxslt-config
	--without-libxslt-config
	--with-exslt-dir
	--without-exslt-dir
	--with-exslt-include
	--without-exslt-include=${exslt-dir}/include
	--with-exslt-lib
	--without-exslt-lib=${exslt-dir}/lib
	--with-libexslt-config
	--without-libexslt-config

extconf failed, exit code 1

Gem files will remain installed in /Users/alex/.vagrant.d/gems/2.2.5/gems/nokogiri-1.7.2 for inspection.
Results logged to /Users/alex/.vagrant.d/gems/2.2.5/extensions/x86_64-darwin-13/2.2.0/nokogiri-1.7.2/gem_make.out

@mediaessenz
Copy link
Author

I fixed my problem with xcode-select --install

@ghost
Copy link

ghost commented Apr 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 2, 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

3 participants