$OpenBSD: patch-src_tools_cargo_src_cargo_util_config_rs,v 1.1 2017/07/31 13:38:58 danj Exp $
fallback to LOCALBASE as default path for cargo binary.
Index: src/tools/cargo/src/cargo/util/config.rs
--- src/tools/cargo/src/cargo/util/config.rs.orig
+++ src/tools/cargo/src/cargo/util/config.rs
@@ -121,7 +121,13 @@ impl Config {
 
     pub fn cargo_exe(&self) -> CargoResult<&Path> {
         self.cargo_exe.get_or_try_init(||
-            env::current_exe().and_then(|path| path.canonicalize())
+            match env::current_exe() {
+                Ok(path) => Ok(path),
+                Err(_) => match option_env!("LOCALBASE") {
+                    Some(dir) => Ok(PathBuf::from(dir).join("bin").join("cargo")),
+                    None => panic!("invalid configuration at compile-time: undefined LOCALBASE"),
+                },
+            }.and_then(|path| path.canonicalize())
             .chain_err(|| "couldn't get the path to cargo executable")
         ).map(AsRef::as_ref)
     }
