Get rid of nil dereference error when reading version [GH-658]

This commit is contained in:
Mitchell Hashimoto 2012-01-19 17:34:06 -08:00
parent 3f3476f323
commit 0d455fcf73
2 changed files with 10 additions and 3 deletions

View File

@ -4,6 +4,8 @@
- Fix issue causing custom guest implementations to not load properly.
- Filter clear screen character out of output on SSH.
- Log output now goes on `stderr`, since it is utility information.
- Get rid of case where a `NoMethodError` could be raised while
determining VirtualBox version. [GH-658]
## 0.9.1 (January 18, 2012)

View File

@ -33,7 +33,7 @@ module Vagrant
# Read and assign the version of VirtualBox we know which
# specific driver to instantiate.
begin
@version = read_version
@version = read_version || ""
rescue Subprocess::LaunchError
# This means that VirtualBox was not found, so we raise this
# error here.
@ -113,8 +113,13 @@ module Vagrant
# * 4.1.8r1234_OSE
# * 4.1.8_MacPortsr1234
#
# Below accounts for all of these:
execute("--version").split("_")[0].split("r")[0]
# Below accounts for all of these.
# Note: We split this into multiple lines because apparently "".split("_")
# is [], so we have to check for an empty array in between.
parts = execute("--version").split("_")
return nil if parts.empty?
parts[0].split("r")[0]
end
end
end