Skip to content

Commit

Permalink
Let util_path return nil on failure
Browse files Browse the repository at this point in the history
Array#each returns the [array] object it was invoked upon, so in case `util_path` doesn't find the executable, it would return the array `['/usr/local/bin', '/usr/bin']`, despite the rest of the code relies on it returning nil in case of failure.
  • Loading branch information
crishoj committed Jun 11, 2015
1 parent 5006d8f commit fe359a6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/vagrant-parallels/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def util_path(bin)
path = File.join(folder, bin)
return path if File.file?(path)
end
nil
end

end
Expand Down

1 comment on commit fe359a6

@crishoj
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error before patch:

christian@Christians-MacBook-Pro ~/P/v/tmp> vagrant up
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/subprocess.rb:29:in `block in initialize': undefined method `encode' for ["/usr/local/bin", "/usr/bin"]:Array (NoMethodError)
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/subprocess.rb:29:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/subprocess.rb:29:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/subprocess.rb:22:in `new'

Please # to comment.