Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix ark --install on Linux #712

wants to merge 2 commits into from

Conversation

lionel-
Copy link
Contributor

@lionel- lionel- commented Feb 14, 2025

And fix --connection_file error.

Closes #648.

And fix `--connection_file` error
@lionel- lionel- requested a review from DavisVaughan February 14, 2025 10:10
Comment on lines 129 to 132
"--install" => {
install_kernel_spec()?;
has_action = true;
return Ok(());
},
Copy link
Contributor

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?

Comment on lines +59 to +61
let r_home: String = r_home_setup().to_string_lossy().to_string();

let output = r_command(|command| {
let output = r_command_from_path(|command| {
Copy link
Contributor

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.

Comment on lines +33 to +56
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)
},
}
}
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ark --install command panics
2 participants