Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async-trait = "0.1.89"
base64 = "0.22.1"
biome_line_index = { git = "https://github.com/lionel-/biome", rev = "41d799cfa4cedd25625fc3f6bd7898532873f051" }
biome_rowan = { git = "https://github.com/lionel-/biome", rev = "41d799cfa4cedd25625fc3f6bd7898532873f051" }
biome_text_size = { git = "https://github.com/lionel-/biome", rev = "41d799cfa4cedd25625fc3f6bd7898532873f051" }
blake3 = "1.8.4"
bus = "2.4.1"
cc = "1.2.60"
Expand Down Expand Up @@ -72,7 +73,8 @@ oak_core = { path = "crates/oak_core" }
oak_fs = { path = "crates/oak_fs" }
oak_ide = { path = "crates/oak_ide" }
oak_index = { path = "crates/oak_index" }
oak_package = { path = "crates/oak_package" }
oak_index_vec = { path = "crates/oak_index_vec" }
oak_package_metadata = { path = "crates/oak_package_metadata" }
oak_r_process = { path = "crates/oak_r_process" }
oak_sources = { path = "crates/oak_sources" }
once_cell = "1.21.4"
Expand Down
5 changes: 3 additions & 2 deletions crates/ark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ notify.workspace = true
oak_core.workspace = true
oak_ide.workspace = true
oak_index.workspace = true
oak_package.workspace = true
oak_sources.workspace = true
once_cell.workspace = true
regex.workspace = true
reqwest.workspace = true
Expand Down Expand Up @@ -79,7 +79,8 @@ yaml-rust2.workspace = true
ark_test.workspace = true
assert_matches.workspace = true
insta.workspace = true
oak_package = { workspace = true, features = ["testing"] }
oak_index = { workspace = true, features = ["testing"] }
oak_package_metadata.workspace = true
stdext = { workspace = true, features = ["testing"] }
tempfile.workspace = true

Expand Down
4 changes: 3 additions & 1 deletion crates/ark/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::cell::UnsafeCell;
use std::collections::HashMap;
use std::ffi::*;
use std::os::raw::c_uchar;
use std::path::PathBuf;
use std::result::Result::Ok;
use std::sync::Arc;
use std::sync::Mutex;
Expand Down Expand Up @@ -55,7 +56,6 @@ use crossbeam::channel::bounded;
use crossbeam::channel::Receiver;
use crossbeam::channel::Sender;
use harp::command::r_command;
use harp::command::r_home_setup;
use harp::environment::r_ns_env;
use harp::environment::Environment;
use harp::environment::R_ENVS;
Expand Down Expand Up @@ -179,6 +179,8 @@ thread_local! {
}

pub(crate) struct Console {
r_home: PathBuf,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused, but I think will be nice for the DAP + PackageCache ideas


pub(crate) positron_ns: Option<RObject>,

kernel_request_rx: Receiver<KernelRequest>,
Expand Down
19 changes: 12 additions & 7 deletions crates/ark/src/console/console_repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//! This module contains `impl Console` with methods and functions related to
//! ReadConsole, WriteConsole, and R frontend callbacks.

use std::path::Path;

use super::*;
use crate::dap::dap_notebook;
use crate::data_explorer::r_data_explorer::POSITRON_DATA_EXPLORER_MIME;
Expand Down Expand Up @@ -333,6 +335,7 @@ impl Console {
/// and starts R. Does not return!
/// SAFETY: Must be called only once. Enforced with a panic.
pub(crate) fn start(
r_home: PathBuf,
r_args: Vec<String>,
startup_file: Option<String>,
comm_event_tx: Sender<CommEvent>,
Expand Down Expand Up @@ -361,6 +364,7 @@ impl Console {
let (tasks_interrupt_rx, tasks_idle_rx, tasks_idle_any_rx) = r_task::take_receivers();

CONSOLE.set(UnsafeCell::new(Console::new(
r_home,
tasks_interrupt_rx,
tasks_idle_rx,
tasks_idle_any_rx,
Expand Down Expand Up @@ -392,11 +396,6 @@ impl Console {
startup::push_ignore_user_r_profile(&mut r_args);
}

let r_home = match r_home_setup() {
Ok(r_home) => r_home,
Err(err) => panic!("Can't set up `R_HOME`: {err}"),
};

// `R_HOME` is now defined no matter what and will be used by
// `r_command()`. Let's discover the other important environment
// variables set by R's shell script frontend.
Expand Down Expand Up @@ -429,7 +428,7 @@ impl Console {
Err(err) => log::error!("Failed to discover R envvars: {err}"),
};

let libraries = RLibraries::from_r_home_path(&r_home);
let libraries = RLibraries::from_r_home_path(console.r_home());
libraries.initialize_pre_setup_r();

crate::sys::console::setup_r(&r_args);
Expand Down Expand Up @@ -515,7 +514,7 @@ impl Console {
// Now that R has started and libr and ark have fully initialized, run site and user
// level R profiles, in that order
if !ignore_site_r_profile {
startup::source_site_r_profile(&r_home);
startup::source_site_r_profile(console.r_home());
}
if !ignore_user_r_profile {
startup::source_user_r_profile();
Expand Down Expand Up @@ -608,6 +607,7 @@ impl Console {
}

fn new(
r_home: PathBuf,
tasks_interrupt_rx: Receiver<QueuedRTask>,
tasks_idle_rx: Receiver<QueuedRTask>,
tasks_idle_any_rx: Receiver<QueuedRTask>,
Expand All @@ -621,6 +621,7 @@ impl Console {
session_mode: SessionMode,
) -> Self {
Self {
r_home,
r_request_rx,
comm_event_tx,
stdin_request_tx,
Expand Down Expand Up @@ -709,6 +710,10 @@ impl Console {
thread.id() == unsafe { CONSOLE_THREAD_ID.unwrap() }
}

pub(crate) fn r_home(&self) -> &Path {
self.r_home.as_path()
}

pub(crate) fn iopub_tx(&self) -> &Sender<IOPubMessage> {
&self.iopub_tx
}
Expand Down
4 changes: 3 additions & 1 deletion crates/ark/src/lsp/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#![allow(deprecated)]

use std::path::PathBuf;
use std::sync::atomic::Ordering;
use std::sync::Arc;

Expand Down Expand Up @@ -517,6 +518,7 @@ impl Backend {
}

pub(crate) fn start_lsp(
r_home: PathBuf,
runtime: Arc<Runtime>,
server_start: ServerStartMessage,
server_started_tx: Sender<ServerStartedMessage>,
Expand Down Expand Up @@ -555,7 +557,7 @@ pub(crate) fn start_lsp(
let (shutdown_tx, mut shutdown_rx) = tokio::sync::mpsc::channel::<()>(1);

let init = |client: Client| {
let state = GlobalState::new(client, console_notification_tx);
let state = GlobalState::new(client, r_home, console_notification_tx);
let events_tx = state.events_tx();

// Start main loop and hold onto the handle that keeps it alive
Expand Down
Loading
Loading