-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ark --install
on Linux
#712
base: main
Are you sure you want to change the base?
Conversation
And fix `--connection_file` error
"--install" => { | ||
install_kernel_spec()?; | ||
has_action = true; | ||
return Ok(()); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow it was trying to start ark when you --install
?
let r_home: String = r_home_setup().to_string_lossy().to_string(); | ||
|
||
let output = r_command(|command| { | ||
let output = r_command_from_path(|command| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is best to call r_command()
here because you called r_home_setup()
right above this, which sets you up to be able to call r_command()
with the same R_HOME
that r_home_setup()
found.
pub(crate) fn r_home_setup() -> PathBuf { | ||
match std::env::var("R_HOME") { | ||
Ok(home) => { | ||
// Get `R_HOME` from env var, typically set by Positron / CI / kernel specification | ||
PathBuf::from(home) | ||
}, | ||
Err(_) => { | ||
// Get `R_HOME` from `PATH`, via `R` | ||
let Ok(result) = r_command_from_path(|command| { | ||
command.arg("RHOME"); | ||
}) else { | ||
panic!("Can't find R or `R_HOME`"); | ||
}; | ||
|
||
let r_home = String::from_utf8(result.stdout).unwrap(); | ||
let r_home = r_home.trim(); | ||
|
||
// Now set `R_HOME`. From now on, `r_command()` can be used to | ||
// run exactly the same R as is running in Ark. | ||
unsafe { std::env::set_var("R_HOME", r_home) }; | ||
PathBuf::from(r_home) | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind moving this to command.rs
in harp instead? It is extremely related to r_command()
, as you can see from this comment just above
// Now set `R_HOME`. From now on, `r_command()` can be used to
// run exactly the same R as is running in Ark.
So i think it makes sense to move it there and add a doc comment like
/// Use this before calling `r_command()` to ensure that `R_HOME` is set consistently
And fix
--connection_file
error.Closes #648.