Windows User Environment Variables Not Loaded in Terminal

I use a corporate laptop, and have set my HOME variable to my Documents directory (for easier backup/restore) using the User Accounts -> "change my environment variables" (User Variables) dialog box. RStudio picks this up (Sys.getenv("HOME")) gives me C:\Users\MyName\Documents, but the Terminal pane does not (it returns C:\Users\MyName). This is mostly a problem because the RStudio GUI git commit operation complains that it cannot find my user.name configuration setting, which is in fact in the git --global config file under my HOME directory and git at the standard command line can access it.

Can I get MINGW to pick up the user environment variables? If not, where would I configure the environment variables for the RStudio Terminal?

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7           magrittr_2.0.1       knitr_1.33          
 [4] hms_1.1.0            odbc_1.3.2           tidyselect_1.1.1    
 [7] bit_4.0.4            R6_2.5.0             rlang_0.4.11        
[10] fansi_0.5.0          blob_1.2.1           dplyr_1.0.7         
[13] tools_3.6.3          xfun_0.23            utf8_1.2.1          
[16] DBI_1.1.1            htmltools_0.5.1.1    ellipsis_0.3.2      
[19] assertthat_0.2.1     yaml_2.2.1           bit64_4.0.5         
[22] digest_0.6.27        tibble_3.1.2         lifecycle_1.0.0     
[25] crayon_1.4.1         dnvglsolardata_0.2.4 purrr_0.3.4         
[28] vctrs_0.3.8          bitops_1.0-7         RCurl_1.98-1.3      
[31] glue_1.4.2           evaluate_0.14        rmarkdown_2.9       
[34] pillar_1.6.1         compiler_3.6.3       generics_0.1.0      
[37] pkgconfig_2.0.3

Edit: I found Using the RStudio Terminal in the RStudio IDE – RStudio Support, and my setting is default (use Git Bash from Git for Windows) but when I independently start Git Bash the environment variables are inherited correctly. I also tried changing the Terminal to Command but the environment variables are still wrong when that setting takes effect.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.