11use crate :: {
2- command_executor:: execute_command, idf_config:: { IdfConfig , IdfInstallation } , idf_tools:: { self , read_and_parse_tools_file} , replace_unescaped_spaces_win, settings:: Settings , single_version_post_install, version_manager:: get_default_config_path
2+ command_executor:: execute_command, idf_config:: { IdfConfig , IdfInstallation } , idf_tools:: { self , read_and_parse_tools_file} , replace_unescaped_spaces_win, settings:: { self , Settings } , single_version_post_install, version_manager:: get_default_config_path
33} ;
44use anyhow:: { anyhow, Result , Error } ;
55use git2:: Repository ;
@@ -389,8 +389,6 @@ pub fn parse_tool_set_config(config_path: &str) -> Result<()> {
389389 . unwrap ( )
390390 . to_string ( ) ;
391391 let new_export_paths = vec ! [ tool_set. env_vars. get( "PATH" ) . unwrap( ) . to_string( ) ] ;
392- let tmp = PathBuf :: from ( tool_set. idf_location . clone ( ) ) ;
393- let version_path = tmp. parent ( ) . unwrap ( ) ;
394392 let settings = crate :: settings:: Settings :: default ( ) ;
395393 let activation_script_path = settings. esp_idf_json_path . clone ( ) . unwrap_or_default ( ) ;
396394 single_version_post_install (
@@ -405,11 +403,11 @@ pub fn parse_tool_set_config(config_path: &str) -> Result<()> {
405403 let new_activation_script = match std:: env:: consts:: OS {
406404 "windows" => format ! (
407405 "{}\\ Microsoft.PowerShell_profile.ps1" ,
408- version_path . to_str ( ) . unwrap ( )
406+ activation_script_path
409407 ) ,
410408 _ => format ! (
411409 "{}/activate_idf_{}.sh" ,
412- version_path . to_str ( ) . unwrap ( ) ,
410+ activation_script_path ,
413411 tool_set. idf_version
414412 ) ,
415413 } ;
@@ -437,7 +435,7 @@ pub fn parse_tool_set_config(config_path: &str) -> Result<()> {
437435 None => {
438436 debug ! ( "Adding new IDF installation to config" ) ;
439437 current_config. idf_installed . push ( installation) ;
440- match current_config. to_file ( config_path, true , false ) {
438+ match current_config. to_file ( config_path, true , true ) {
441439 Ok ( _) => {
442440 debug ! ( "Updated config file with new tool set" ) ;
443441 return Ok ( ( ) ) ;
@@ -492,11 +490,12 @@ pub fn parse_esp_idf_json(idf_json_path: &str) -> Result<()> {
492490 let idf_path = value. path ;
493491 let python = value. python ;
494492 let tools_path = config. idf_tools_path . clone ( ) ;
495- let path_for_activation_script = idf_json_path. parent ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
493+ let settings = crate :: settings:: Settings :: default ( ) ;
494+ let path_for_activation_script = settings. esp_idf_json_path . clone ( ) . unwrap_or_default ( ) ;
496495
497496 println ! ( "IDF tools path: {}" , tools_path) ;
498497 println ! ( "IDF version: {}" , idf_version) ;
499- println ! ( "activation script path: {}" , path_for_activation_script) ;
498+ println ! ( "activation script path: {}" , & path_for_activation_script) ;
500499 println ! ( "Python path: {}" , python) ;
501500 // export paths
502501 let tools_json_file = find_by_name_and_extension ( Path :: new ( & idf_path) , "tools" , "json" ) ;
@@ -528,7 +527,7 @@ pub fn parse_esp_idf_json(idf_json_path: &str) -> Result<()> {
528527 . collect ( ) ;
529528 export_paths. push ( config. git_path . clone ( ) ) ;
530529 match import_single_version (
531- path_for_activation_script,
530+ & path_for_activation_script,
532531 & idf_path,
533532 & idf_version,
534533 & tools_path,
@@ -674,7 +673,7 @@ pub fn import_single_version(path_to_create_activation_script: &str,idf_location
674673 ) ,
675674 _ => format ! (
676675 "{}/activate_idf_{}.sh" ,
677- PathBuf :: from ( path_to_create_activation_script) . parent ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ,
676+ path_to_create_activation_script,
678677 idf_version
679678 ) ,
680679 } ;
0 commit comments