From 8c1320d787c3e2725a018e6d83134cd1c802cb76 Mon Sep 17 00:00:00 2001 From: yeetfield <79176764+yeetfield@users.noreply.github.com> Date: Fri, 10 Feb 2023 14:57:39 -0600 Subject: [PATCH] Ensure the path contains the Ozy bin directory when running anything through Ozy (#55) --- rozy/src/app.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rozy/src/app.rs b/rozy/src/app.rs index 54ab0ef..e38cf1d 100644 --- a/rozy/src/app.rs +++ b/rozy/src/app.rs @@ -2,7 +2,7 @@ use anyhow::{anyhow, Context, Error, Result}; use file_lock::{FileLock, FileOptions}; use crate::config::{apply_overrides, load_config, resolve}; -use crate::files::{delete_if_exists, get_ozy_cache_dir}; +use crate::files::{check_path, delete_if_exists, get_ozy_bin_dir, get_ozy_cache_dir}; use crate::installers::conda::Conda; use crate::installers::file::File; use crate::installers::installer::Installer; @@ -139,6 +139,12 @@ impl App { return Ok(()); } + let ozy_bin_dir = get_ozy_bin_dir()?; + if !check_path(&ozy_bin_dir)? { + let updated_path = format!("{}:{}", ozy_bin_dir.display(), std::env::var("PATH")?); + std::env::set_var("PATH", updated_path); + } + let install_dir = self.get_install_path()?; std::fs::create_dir_all(install_dir.parent().unwrap()) .context("While creating parent directory of install directory")?;