Properly resolve cygwin paths in Cygwin environments [GH-1366]

This commit is contained in:
Mitchell Hashimoto 2013-03-13 21:50:41 -07:00
parent 57a5edbc39
commit c8b829c4d2
7 changed files with 30 additions and 7 deletions

View File

@ -40,6 +40,8 @@ FEATURES:
IMPROVEMENTS / BUG FIXES: IMPROVEMENTS / BUG FIXES:
- Vagrant works much better in Cygwin environments on Windows by
properly resolving Cygwin paths. [GH-1366]
- Improve the SSH "ready?" check by more gracefully handling timeouts. [GH-841] - Improve the SSH "ready?" check by more gracefully handling timeouts. [GH-841]
- Human friendly error if connection times out for HTTP downloads. [GH-849] - Human friendly error if connection times out for HTTP downloads. [GH-849]
- Detect when the VirtualBox installation is incomplete and error. [GH-846] - Detect when the VirtualBox installation is incomplete and error. [GH-846]

View File

@ -1,6 +1,8 @@
require 'rbconfig' require 'rbconfig'
require 'tempfile' require 'tempfile'
require "vagrant/util/subprocess"
module Vagrant module Vagrant
module Util module Util
# This class just contains some platform checking code. # This class just contains some platform checking code.
@ -48,6 +50,19 @@ module Vagrant
!bit64? !bit64?
end end
# This takes as input a path as a string and converts it into
# a platform-friendly version of the path. This is most important
# when using the path in shell environments with Cygwin.
#
# @param [String] path
# @return [String]
def platform_path(path)
return path if !cygwin?
process = Subprocess.execute("cygpath", "-u", path.to_s)
process.stdout.chomp
end
# Returns a boolean noting whether the terminal supports color. # Returns a boolean noting whether the terminal supports color.
# output. # output.
def terminal_supports_colors? def terminal_supports_colors?

View File

@ -12,9 +12,6 @@ module VagrantPlugins
# Import the virtual machine # Import the virtual machine
ovf_file = env[:machine].box.directory.join("box.ovf").to_s ovf_file = env[:machine].box.directory.join("box.ovf").to_s
if Vagrant::Util::Platform.cygwin?
ovf_file = `cygpath -m '#{ovf_file}'`.chomp
end
env[:machine].id = env[:machine].provider.driver.import(ovf_file) do |progress| env[:machine].id = env[:machine].provider.driver.import(ovf_file) do |progress|
env[:ui].clear_line env[:ui].clear_line
env[:ui].report_progress(progress, 100, false) env[:ui].report_progress(progress, 100, false)

View File

@ -33,9 +33,6 @@ module VagrantPlugins
if ENV.has_key?("VBOX_INSTALL_PATH") if ENV.has_key?("VBOX_INSTALL_PATH")
# Get the path. # Get the path.
path = ENV["VBOX_INSTALL_PATH"] path = ENV["VBOX_INSTALL_PATH"]
if Vagrant::Util::Platform.cygwin?
path = `cygpath -u '#{path}'`.chomp
end
@logger.debug("VBOX_INSTALL_PATH value: #{path}") @logger.debug("VBOX_INSTALL_PATH value: #{path}")
# There can actually be multiple paths in here, so we need to # There can actually be multiple paths in here, so we need to
@ -48,7 +45,7 @@ module VagrantPlugins
# and break out # and break out
vboxmanage = "#{path}VBoxManage.exe" vboxmanage = "#{path}VBoxManage.exe"
if File.file?(vboxmanage) if File.file?(vboxmanage)
@vboxmanage_path = vboxmanage @vboxmanage_path = Vagrant::Util::Platform.platform_path(vboxmanage)
break break
end end
end end

View File

@ -1,5 +1,7 @@
require 'log4r' require 'log4r'
require "vagrant/util/platform"
require File.expand_path("../base", __FILE__) require File.expand_path("../base", __FILE__)
module VagrantPlugins module VagrantPlugins
@ -157,6 +159,8 @@ module VagrantPlugins
end end
def import(ovf) def import(ovf)
ovf = Vagrant::Util::Platform.platform_path(ovf)
output = "" output = ""
total = "" total = ""
last = 0 last = 0

View File

@ -1,5 +1,7 @@
require 'log4r' require 'log4r'
require "vagrant/util/platform"
require File.expand_path("../base", __FILE__) require File.expand_path("../base", __FILE__)
module VagrantPlugins module VagrantPlugins
@ -157,6 +159,8 @@ module VagrantPlugins
end end
def import(ovf) def import(ovf)
ovf = Vagrant::Util::Platform.platform_path(ovf)
output = "" output = ""
total = "" total = ""
last = 0 last = 0

View File

@ -1,5 +1,7 @@
require 'log4r' require 'log4r'
require "vagrant/util/platform"
require File.expand_path("../base", __FILE__) require File.expand_path("../base", __FILE__)
module VagrantPlugins module VagrantPlugins
@ -155,6 +157,8 @@ module VagrantPlugins
end end
def import(ovf) def import(ovf)
ovf = Vagrant::Util::Platform.platform_path(ovf)
output = "" output = ""
total = "" total = ""
last = 0 last = 0