From 993e430cccf5fddf9a92dffbbabe0aa5ff6001d0 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Sun, 2 Aug 2015 10:13:40 +0000 Subject: [PATCH] Use /usr/bin/env CMD instead of hardcoded paths This fixes commands that currently rely on hardcoded paths and break on systems like NixOS that don't have all binaries in /usr/bin etc. --- lib/vagrant-lxc/provider.rb | 2 +- lib/vagrant-lxc/sudo_wrapper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-lxc/provider.rb b/lib/vagrant-lxc/provider.rb index ab56279..dead6ab 100644 --- a/lib/vagrant-lxc/provider.rb +++ b/lib/vagrant-lxc/provider.rb @@ -36,7 +36,7 @@ module Vagrant def ensure_lxc_installed! begin - sudo_wrapper.run("/usr/bin/which", "lxc-create") + sudo_wrapper.run("which", "lxc-create") rescue Vagrant::LXC::Errors::ExecuteError raise Errors::LxcNotInstalled end diff --git a/lib/vagrant-lxc/sudo_wrapper.rb b/lib/vagrant-lxc/sudo_wrapper.rb index 406c0f0..f344d9f 100644 --- a/lib/vagrant-lxc/sudo_wrapper.rb +++ b/lib/vagrant-lxc/sudo_wrapper.rb @@ -14,7 +14,7 @@ module Vagrant def run(*command) options = command.last.is_a?(Hash) ? command.last : {} command.unshift @wrapper_path if @wrapper_path && !options[:no_wrapper] - execute *(['sudo'] + command) + execute *(['sudo', '/usr/bin/env'] + command) end private