Skip to content

Commit

Permalink
VWRfirstrun() more accurate script to define path to the default mini…
Browse files Browse the repository at this point in the history
…conda path, accounting for OS
  • Loading branch information
chabld committed Dec 10, 2024
1 parent d49804b commit 4d9d5a5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions R/VWRfirstrun.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,17 @@ VWRfirstrun=function(requirement="any", n_vert=0, promptless=FALSE)
if (prompt==1) #Install Miniconda
{

#define default path
defaultpath=reticulate::miniconda_path()
#define default path (will differ across OS)
defaultpath <- tryCatch({
tmpfile <- tempfile()
con <- file(tmpfile, open = "wt")
sink(con, type = "message")
on.exit({
sink(type = "message");
close(con); file.remove(tmpfile)}, add = TRUE)
reticulate::py_discover_config()$python
}, error = function(e) {NULL})


#give the choices to specify path
choice = utils::menu(c("Default", "Custom"),
Expand Down Expand Up @@ -112,8 +121,10 @@ VWRfirstrun=function(requirement="any", n_vert=0, promptless=FALSE)
# Write to the .Renviron file
cat(paste(env_vars, "\n", collapse = "\n"),
file = renviron_path, sep = "\n", append = TRUE)
#now everytime VWRfirstrun() is called, the .Renviron file

#now everytime VWRfirstrun() is called, the .Renviron file
#is read and the custom path accessed:
readRenviron(renviron_path)

}
else { #Install Miniconda within custom path

Expand Down

0 comments on commit 4d9d5a5

Please sign in to comment.