Warn the user when in a path that contains special characters #4966

Closed
sethvargo opened this Issue Dec 13, 2014 · 6 comments

Comments

Projects
None yet
5 participants
@sethvargo
Contributor

sethvargo commented Dec 13, 2014

There are a number of things, namely on Windows, where any non-UTF-8 character (and sometimes even non-alpnum characters) cause things to fail.

For gem installations that require compiling native extensions, any non-alphnum character will cause the build to fail - that means paths with spaces (like C:\My User) or parenthesis (like Program Files (x86)) will cause the installation to fail.

Similarly, there are known issues in VirtualBox where non-UTF-8 characters in paths cause strange things to happen (#2113).

Given the breadth, span, and nature of these issues, I do not think it is possible to "fix" Vagrant. Instead, I propose we add a function early in Vagrant's initialization stage that sanity checks important paths and prints a helpful warning message (perhaps linking to more verbose documentation) when those paths contain "invalid" characters. Namely:

  • VAGRANT_HOME
  • GEM_HOME
  • GEM_PATH
  • GEM_ROOT
  • PWD
@koseki

This comment has been minimized.

Show comment
Hide comment
@koseki

koseki Jan 17, 2015

I think VBOX_USER_HOME is also required to be checked.

In my environment, non-ASCII home (C:\Users\健吾\VirtualBox VMs) causes error.

Command: ["import", "C:/vagrant/boxes/chef-VAGRANTSLASH-centos-6.5/1.0.0/virtualbox/box.ovf", "--vsys", "0", "--vmname", "packer-centos-6.5-x86_64_1421281388083_71845", "--vsys", "0", "--unit", "7", "--disk", "C:\\Users\\\u5065\u543E\\VirtualBox VMs\\packer-centos-6.5-x86_64_1421281388083_71845\\packer-centos-6.5-x86_64-disk1.vmdk"]

Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting C:\vagrant\boxes\chef-VAGRANTSLASH-centos-6.5\1.0.0\virtualbox\box.ovf...
OK.
0%...
Progress state: VBOX_E_IPRT_ERROR
VBoxManage.exe: error: Appliance import failed
VBoxManage.exe: error: Could not create the directory 'C:\Users\蛛・蜷セ\VirtualBox VMs\packer-centos-6.5-x86_64_1421281388083_71845' (VERR_ACCESS_DENIED)
                                                                ^^^^^ garbled
VBoxManage.exe: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component Appliance, interface IAppliance
VBoxManage.exe: error: Context: "int __cdecl handleImportAppliance(struct HandlerArg *)" at line 779 of file VBoxManageAppliance.cpp

I added

disk_params.last.encode!('Shift_JIS')

to here, and it worked. 😩

May be relevant to current code page.

C:\>chcp
現在のコード ページ: 932
  • Windows 8.1
  • Vagrant 1.7.2
  • VirtualBox 4.3.20

koseki commented Jan 17, 2015

I think VBOX_USER_HOME is also required to be checked.

In my environment, non-ASCII home (C:\Users\健吾\VirtualBox VMs) causes error.

Command: ["import", "C:/vagrant/boxes/chef-VAGRANTSLASH-centos-6.5/1.0.0/virtualbox/box.ovf", "--vsys", "0", "--vmname", "packer-centos-6.5-x86_64_1421281388083_71845", "--vsys", "0", "--unit", "7", "--disk", "C:\\Users\\\u5065\u543E\\VirtualBox VMs\\packer-centos-6.5-x86_64_1421281388083_71845\\packer-centos-6.5-x86_64-disk1.vmdk"]

Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting C:\vagrant\boxes\chef-VAGRANTSLASH-centos-6.5\1.0.0\virtualbox\box.ovf...
OK.
0%...
Progress state: VBOX_E_IPRT_ERROR
VBoxManage.exe: error: Appliance import failed
VBoxManage.exe: error: Could not create the directory 'C:\Users\蛛・蜷セ\VirtualBox VMs\packer-centos-6.5-x86_64_1421281388083_71845' (VERR_ACCESS_DENIED)
                                                                ^^^^^ garbled
VBoxManage.exe: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component Appliance, interface IAppliance
VBoxManage.exe: error: Context: "int __cdecl handleImportAppliance(struct HandlerArg *)" at line 779 of file VBoxManageAppliance.cpp

I added

disk_params.last.encode!('Shift_JIS')

to here, and it worked. 😩

May be relevant to current code page.

C:\>chcp
現在のコード ページ: 932
  • Windows 8.1
  • Vagrant 1.7.2
  • VirtualBox 4.3.20
@koseki

This comment has been minimized.

Show comment
Hide comment
@koseki

koseki Jan 19, 2015

Ah, I was getting confused between VBOX_USER_HOME and machinefolder. I mean machinefolder.

The default machinefolder in C:\Users\健吾\.VirtualBox\VirtualBox.xml is like below. Vagrant doesn't work with this configuration.

  <SystemProperties defaultMachineFolder="C:\Users\&#x5065;&#x543E;\VirtualBox VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>

This works.

  <SystemProperties defaultMachineFolder="C:\VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>

koseki commented Jan 19, 2015

Ah, I was getting confused between VBOX_USER_HOME and machinefolder. I mean machinefolder.

The default machinefolder in C:\Users\健吾\.VirtualBox\VirtualBox.xml is like below. Vagrant doesn't work with this configuration.

  <SystemProperties defaultMachineFolder="C:\Users\&#x5065;&#x543E;\VirtualBox VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>

This works.

  <SystemProperties defaultMachineFolder="C:\VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>
@neichen

This comment has been minimized.

Show comment
Hide comment
@neichen

neichen Apr 28, 2015

vagrant version 1.7.2

I discovered a method to "solve" this problem if someone doesn't want to change the real path to VAGRANT_HOME like I do.
The answer is to create a soft link ( which called junction in windows ) to the non-ASCII directory, then use the link instead of it.
I used to use a shortcut to do this but failed, and a junction did it! To use it, just type the falling command in cmd ( not in powershell, will cause an error, don't know why )

MKLINK /J Link Target

Take this for an example:

MKLINK /J C:\Devs\links\i C:\Users\宁

You can place the link wherever you like ( a path that does not contain non-ASCII encoding characters ), then add VAGRANT_HOME's new directory in the User Environment. If you vagrant init in a non-ASCII directory too, cd it in the link instead, everything will be fine.
The VirtualBox defaultMachineFolder can also benefit from it.

What's more, I think vagrant can also use this method to solve the problem as you can mklink when user vagrant init in a non-ASCII directory automatically. ( Don't know whether it's a good or bad idea. )

Hope this will help 😃

neichen commented Apr 28, 2015

vagrant version 1.7.2

I discovered a method to "solve" this problem if someone doesn't want to change the real path to VAGRANT_HOME like I do.
The answer is to create a soft link ( which called junction in windows ) to the non-ASCII directory, then use the link instead of it.
I used to use a shortcut to do this but failed, and a junction did it! To use it, just type the falling command in cmd ( not in powershell, will cause an error, don't know why )

MKLINK /J Link Target

Take this for an example:

MKLINK /J C:\Devs\links\i C:\Users\宁

You can place the link wherever you like ( a path that does not contain non-ASCII encoding characters ), then add VAGRANT_HOME's new directory in the User Environment. If you vagrant init in a non-ASCII directory too, cd it in the link instead, everything will be fine.
The VirtualBox defaultMachineFolder can also benefit from it.

What's more, I think vagrant can also use this method to solve the problem as you can mklink when user vagrant init in a non-ASCII directory automatically. ( Don't know whether it's a good or bad idea. )

Hope this will help 😃

@sethvargo

This comment has been minimized.

Show comment
Hide comment
@sethvargo

sethvargo Jun 7, 2016

Contributor

We are going to fix the paths instead.

Contributor

sethvargo commented Jun 7, 2016

We are going to fix the paths instead.

@atorstling

This comment has been minimized.

Show comment
Hide comment
@atorstling

atorstling Mar 26, 2018

@sethvargo Have you discussed this further? I ran into the user folder with special chars problems with 2.0.3...

@sethvargo Have you discussed this further? I ran into the user folder with special chars problems with 2.0.3...

@briancain

This comment has been minimized.

Show comment
Hide comment
@briancain

briancain Mar 26, 2018

Member

@atorstling - Please open a new issue. Thanks!

Member

briancain commented Mar 26, 2018

@atorstling - Please open a new issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment