vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

Windows unable to create directory for boxes with derived long name

Open swquinn opened this issue 11 years ago • 8 comments

On a Windows environment, Vagrant fails to create a directory for a box that is downloaded from the internet, e.g. https://github.com/extesla/ubuntu-server-cloudimg-amd64-vagrant/releases/download/v14.10/ubuntu-utopic-cloudimg-amd64-vagrant.box, whose name translates into the long directory name:

https-VAGRANTCOLON--VAGRANTSLASH--VAGRANTSLASH-github.com-VAGRANTSLASH-extesla-VAGRANTSLASH-ubuntu-server-cloudimg-amd64-vagrant-VAGRANTSLASH-releases-VAGRANTSLASH-download-VAGRANTSLASH-v14.10-VAGRANTSLASH-ubuntu-utopic-cloudimg-amd64-vagrant.box

With the error:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'https://github.com/extesla/ubuntu-server-cloudimg-amd64-vagrant/releases/download/v14.10/ubuntu-utopic-cloudimg-amd64-vagrant.box' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Adding box 'https://github.com/extesla/ubuntu-server-cloudimg-amd64-vagrant/releases/download/v14.10/ubuntu-utopic-cloudimg-amd64-vagrant.box' (v0) for provider: virtualbox
    default: Downloading: https://github.com/extesla/ubuntu-server-cloudimg-amd64-vagrant/releases/download/v14.10/ubuntu-utopic-cloudimg-amd64-vagrant.box
    default: Progress: 100% (Rate: 4800k/s, Estimated time remaining: --:--:--)
C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': No such file or directory - C:/Users/Sean.Quinn/.vagrant.d/boxes/https-VAGRANTCOLON--VAGRANTSLASH--VAGRANTSLASH-github.com-VAGRANTSLASH-extesla-VAGRANTSLASH-ubuntu-server-cloudimg-amd64-vagrant-VAGRANTSLASH-releases-VAGRANTSLASH-download-VAGRANTSLASH-v14.10-VAGRANTSLASH-ubuntu-utopic-cloudimg-amd64-vagrant.box (Errno::ENOENT)
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/fileutils.rb:245:in `fu_mkdir'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/fileutils.rb:219:in `block (2 levels) in mkdir_p'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/fileutils.rb:217:in `reverse_each'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/fileutils.rb:217:in `block in mkdir_p'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/fileutils.rb:203:in `each'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/fileutils.rb:203:in `mkdir_p'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/pathname.rb:556:in `mkpath'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/box_collection.rb:158:in `block (3 levels) in add'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/box_collection.rb:436:in `with_temp_dir'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/box_collection.rb:131:in `block (2 levels) in add'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/box_collection.rb:436:in `with_temp_dir'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/box_collection.rb:112:in `block in add'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/box_collection.rb:423:in `block in with_collection_lock'
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/box_collection.rb:422:in `with_collection_lock'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/box_collection.rb:101:in `add'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/box_add.rb:337:in `box_add'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/box_add.rb:130:in `add_direct'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/box_add.rb:106:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/handle_box.rb:79:in `handle_box'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/handle_box.rb:42:in `block in call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/handle_box.rb:36:in `synchronize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/handle_box.rb:36:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:214:in `action_raw'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:191:in `block in action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:516:in `lock'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in `action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

This appears to be largely due to the derived name exceeding the length of characters Windows 7 (at least) allows in its directory names. The box works fine on a Linux host.

Is it possible to add something, like a box name, to the box metadata.json file that tells Vagrant what name is should place the box under?

Or is the proper solution for this to use:

config.vm.box = "extesla/utopic64"
config.vm.box_url = "https://github.com/extesla/ubuntu-server-cloudimg-amd64-vagrant/releases/download/v14.10/ubuntu-utopic-cloudimg-amd64-vagrant.box"

Thanks!

swquinn avatar Feb 07 '15 14:02 swquinn

Did setting the config.vm.box and config.vm.box_url work?

richardjortega avatar May 12 '15 18:05 richardjortega

@richardjortega the config.vm.box and config.vm.box_url seem to work together without any issue. If the box is not found by the name Vagrant downloads it based on the url and adds it under the name of the box specified. E.g.

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'extesla/gh5301' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Adding box 'extesla/gh5301' (v0) for provider: virtualbox
    ...

swquinn avatar May 13 '15 12:05 swquinn

Hi @swquinn

I believe this is a limitation of Windows paths. Would it help if we used UNC paths instead?

sethvargo avatar May 13 '15 13:05 sethvargo

@sethvargo I think you're right regarding the limitation. Right now the config.vm.box and config.vm.box_url used together is an OK work-around. Admittedly I'm not as familiar with the limits (or lack thereof?) of UNC paths, but it sounds like as good a suggestion as any to me. :)

swquinn avatar May 13 '15 14:05 swquinn

@swquinn and @sethvargo Thanks for the tip! I worked around it with just doing vagrant add box_name box_url.

richardjortega avatar May 13 '15 15:05 richardjortega

:+1: I can confirm that the workaround with config.vm.box and config.vm.box_url works

leonard84 avatar May 13 '15 15:05 leonard84

Hi all,

We recently merged support for using UNC paths almost everywhere in Windows. Unfortunately, because this is just a limitation of Windows, there isn't much Vagrant can do here. If you find a place where this is still happening, can you please open a new issue with the Vagrantfile and the output of the command in debug mode? Thanks!

sethvargo avatar Jul 10 '15 20:07 sethvargo

I am noob at this and I ran into this issue first thing I did. Where does the metadata.json file go??

SalvorinFex avatar Dec 28 '15 07:12 SalvorinFex