// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use env;

/// Default Binlink Dir
#[cfg(target_os = "windows")]
pub const DEFAULT_BINLINK_DIR: &'static str = "/hab/bin";
#[cfg(target_os = "linux")]
pub const DEFAULT_BINLINK_DIR: &'static str = "/bin";
#[cfg(target_os = "macos")]
pub const DEFAULT_BINLINK_DIR: &'static str = "/usr/local/bin";

/// Binlink Dir Environment variable
pub const BINLINK_DIR_ENVVAR: &'static str = "HAB_BINLINK_DIR";

pub fn default_binlink_dir() -> String {
    match env::var(BINLINK_DIR_ENVVAR) {
        Ok(val) => val,
        Err(_) => DEFAULT_BINLINK_DIR.to_string(),
    }
}

// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use env;

/// Default Binlink Dir
#[cfg(target_os = "windows")]
pub const DEFAULT_BINLINK_DIR: &'static str = "/hab/bin";
#[cfg(not(target_os = "windows"))]
pub const DEFAULT_BINLINK_DIR: &'static str = "/bin";

/// Binlink Dir Environment variable
pub const BINLINK_DIR_ENVVAR: &'static str = "HAB_BINLINK_DIR";

pub fn default_binlink_dir() -> String {
    match env::var(BINLINK_DIR_ENVVAR) {
        Ok(val) => val,
        Err(_) => DEFAULT_BINLINK_DIR.to_string(),
    }
}

--- 
+++ 
@@ -17,8 +17,10 @@
 /// Default Binlink Dir
 #[cfg(target_os = "windows")]
 pub const DEFAULT_BINLINK_DIR: &'static str = "/hab/bin";
-#[cfg(not(target_os = "windows"))]
+#[cfg(target_os = "linux")]
 pub const DEFAULT_BINLINK_DIR: &'static str = "/bin";
+#[cfg(target_os = "macos")]
+pub const DEFAULT_BINLINK_DIR: &'static str = "/usr/local/bin";
 
 /// Binlink Dir Environment variable
 pub const BINLINK_DIR_ENVVAR: &'static str = "HAB_BINLINK_DIR";
Use /usr/local/bin as default bin link dir

On newish macs /bin is a protected driectory this change
makes binlinks go into /usr/local/bin.

Signed-off-by: Jon Morrow <464b701a872e97467242b8318ff1f8e7672cc0e8@chef.io>
