diff --git a/crates/red_knot_project/Cargo.toml b/crates/red_knot_project/Cargo.toml index 43e1b2d190d8b..ea31f99f79a36 100644 --- a/crates/red_knot_project/Cargo.toml +++ b/crates/red_knot_project/Cargo.toml @@ -13,7 +13,7 @@ license.workspace = true [dependencies] ruff_cache = { workspace = true } -ruff_db = { workspace = true, features = ["os", "cache", "serde"] } +ruff_db = { workspace = true, features = ["cache", "serde"] } ruff_macros = { workspace = true } ruff_python_ast = { workspace = true, features = ["serde"] } ruff_text_size = { workspace = true } diff --git a/crates/red_knot_python_semantic/Cargo.toml b/crates/red_knot_python_semantic/Cargo.toml index cafd00e9c050b..47847e8307cc8 100644 --- a/crates/red_knot_python_semantic/Cargo.toml +++ b/crates/red_knot_python_semantic/Cargo.toml @@ -44,7 +44,7 @@ test-case = { workspace = true } memchr = { workspace = true } [dev-dependencies] -ruff_db = { workspace = true, features = ["os", "testing"] } +ruff_db = { workspace = true, features = ["testing"] } ruff_python_parser = { workspace = true } red_knot_test = { workspace = true } red_knot_vendored = { workspace = true } diff --git a/crates/red_knot_server/Cargo.toml b/crates/red_knot_server/Cargo.toml index 87e8126b8cd03..f14aa19350910 100644 --- a/crates/red_knot_server/Cargo.toml +++ b/crates/red_knot_server/Cargo.toml @@ -12,7 +12,7 @@ license = { workspace = true } [dependencies] red_knot_project = { workspace = true } -ruff_db = { workspace = true } +ruff_db = { workspace = true, features = ["os"] } ruff_notebook = { workspace = true } ruff_python_ast = { workspace = true } ruff_source_file = { workspace = true } diff --git a/crates/red_knot_wasm/Cargo.toml b/crates/red_knot_wasm/Cargo.toml index d6363f144695c..7cf08388348a2 100644 --- a/crates/red_knot_wasm/Cargo.toml +++ b/crates/red_knot_wasm/Cargo.toml @@ -22,7 +22,7 @@ default = ["console_error_panic_hook"] red_knot_python_semantic = { workspace = true } red_knot_project = { workspace = true, default-features = false, features = ["deflate"] } -ruff_db = { workspace = true, features = [] } +ruff_db = { workspace = true, default-features = false, features = [] } ruff_notebook = { workspace = true } console_error_panic_hook = { workspace = true, optional = true } diff --git a/crates/ruff_db/Cargo.toml b/crates/ruff_db/Cargo.toml index ec39450bc9f79..d771fd8a8a7c1 100644 --- a/crates/ruff_db/Cargo.toml +++ b/crates/ruff_db/Cargo.toml @@ -25,7 +25,6 @@ colored = { workspace = true } countme = { workspace = true } dashmap = { workspace = true } dunce = { workspace = true } -etcetera = { workspace = true, optional = true } filetime = { workspace = true } glob = { workspace = true } ignore = { workspace = true, optional = true } @@ -44,14 +43,16 @@ zip = { workspace = true } [target.'cfg(target_arch="wasm32")'.dependencies] web-time = { version = "1.1.0" } +[target.'cfg(not(target_arch="wasm32"))'.dependencies] +etcetera = { workspace = true, optional = true } + [dev-dependencies] insta = { workspace = true } tempfile = { workspace = true } [features] -default = ["os"] cache = ["ruff_cache"] -os = ["ignore", "etcetera"] +os = ["ignore", "dep:etcetera"] serde = ["dep:serde", "camino/serde1"] # Exposes testing utilities. testing = ["tracing-subscriber", "tracing-tree"] diff --git a/crates/ruff_db/src/system/os.rs b/crates/ruff_db/src/system/os.rs index c3370515c65c5..df752d85a1f45 100644 --- a/crates/ruff_db/src/system/os.rs +++ b/crates/ruff_db/src/system/os.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use std::{any::Any, path::PathBuf}; -use etcetera::BaseStrategy as _; use filetime::FileTime; use ruff_notebook::{Notebook, NotebookError}; @@ -99,11 +98,21 @@ impl System for OsSystem { &self.inner.cwd } + #[cfg(not(target_arch = "wasm32"))] fn user_config_directory(&self) -> Option { + use etcetera::BaseStrategy as _; + let strategy = etcetera::base_strategy::choose_base_strategy().ok()?; SystemPathBuf::from_path_buf(strategy.config_dir()).ok() } + // TODO: Remove this feature gating once `ruff_wasm` no longer depends on `ruff_db` with the + // Os feature enabled. + #[cfg(target_arch = "wasm32")] + fn user_config_directory(&self) -> Option { + None + } + /// Creates a builder to recursively walk `path`. /// /// The walker ignores files according to [`ignore::WalkBuilder::standard_filters`] diff --git a/crates/ruff_db/src/system/test.rs b/crates/ruff_db/src/system/test.rs index 1a79d01679312..14f7f2d0b09c1 100644 --- a/crates/ruff_db/src/system/test.rs +++ b/crates/ruff_db/src/system/test.rs @@ -26,7 +26,7 @@ pub struct TestSystem { } impl TestSystem { - /// Returns the [`InMemorySystem`]. + /// Returns the `InMemorySystem`. /// /// ## Panics /// If this test db isn't the in memory system. @@ -35,7 +35,7 @@ impl TestSystem { .expect("The test db is not using a memory file system") } - /// Returns the [`InMemorySystem`] or `None` if the test system is using an other underlying system. + /// Returns the `InMemorySystem` or `None` if the test system is using an other underlying system. pub fn as_in_memory(&self) -> Option<&InMemorySystem> { self.system().as_any().downcast_ref::() }