Ошибка при вводе vagrant up: Gem::Requirement::BadRequirementError

Я все еще слишком зеленый на Vagrant, и я не знаю, как исправить эту ошибку, которую я получаю, когда пытаюсь выполнить "vagrant up":

/opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:89:in `parse': Illformed requirement ["puphpet/ubuntu1604-x64"] (Gem::Requirement::BadRequirementError)
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `block in initialize'
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `map!'
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:268:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:268:in `block in find'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:267:in `map'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:267:in `find'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:167:in `block in machine_config'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:200:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:200: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>'

Это Vagrantfile в этом каталоге:

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

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "base"
  config.vm.box_version = "puphpet/ubuntu1604-x64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network "myownnetwork", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "myownnetwork", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

Как вы видите, я выбрал коробку, которую я уже создал с помощью марионетки, под названием «puphpet/ubuntu1604-x64», но я также попытался использовать коробку Laravel Homestead, которую я также установил. Это список моих доступных ящиков (список бродячих ящиков):

hashicorp/precise32    (virtualbox, 1.0.0)
laravel/homestead      (virtualbox, 2.0.0)
puphpet/ubuntu1604-x64 (virtualbox, 20161102)

Единственное, что я редактировал в Vagrantfile, — это раскомментировать сетевые строки и дать сети произвольное имя. Строка блока уже была раскомментирована, потому что я сделал это:

vagrant init --box-version laravel/homestead

и позже я изменил окно laravel для puphpet/ubuntu1604-x64, просто чтобы попробовать, с той же ошибкой.

Любая помощь?


person Luis Martin    schedule 05.06.2017    source источник


Ответы (1)


Вы путаете config.vm.box и config.vm.box_version

Вы можете просто пойти с

config.vm.box = "puphpet/ubuntu1604-x64"

но если вам действительно нужно указать версию для этого поля, вы можете указать ее с помощью параметра версии. Подробнее о box_version можно прочитать в этой части документа.

config.vm.box_version = "20161102"
person Frederic Henri    schedule 05.06.2017
comment
Упс! Я был совершенно не прав, спасибо! Где взять коробочную версию? Это случайное число? - person Luis Martin; 05.06.2017
comment
нет он был указан рядом с провайдером в этой строке puphpet/ubuntu1604-x64 (virtualbox, 20161102) версию можно найти при поиске коробки в атласе - person Frederic Henri; 05.06.2017
comment
Мне также пришлось оставить имя сети таким, каким оно было изначально: config.vm.network forwarded_port, guest: 80, host: 8080 и config.vm.network private_network, ip: 192.168.33.10, потому что в противном случае возникала другая ошибка. - person Luis Martin; 05.06.2017
comment
Я не думаю, что вам нужно иметь как перенаправленный порт, так и частную_сеть, если у вас есть статический IP-адрес, вы будете напрямую обращаться к серверу с виртуальной машины, используя IP-адрес и порт от виртуальной машины, это главное преимущество, если у вас есть частная_сеть, удалите порт пересылки - person Frederic Henri; 06.06.2017