diff --git a/crates/rome_cli/src/commands/help.rs b/crates/rome_cli/src/commands/help.rs
index 3ae3b3f1be8..463133191f5 100644
--- a/crates/rome_cli/src/commands/help.rs
+++ b/crates/rome_cli/src/commands/help.rs
@@ -37,6 +37,7 @@ const CHECK: Markup = markup! {
""--apply"" Apply safe fixes
""--apply-unsafe"" Apply safe and unsafe fixes
""--max-diagnostics"" Cap the amount of diagnostics displayed (default: 20)
+ ""--config"" Set the filesystem path to the directory of the rome.json configuration file
""--verbose"" Print additional verbose advices on diagnostics
"
};
@@ -65,6 +66,7 @@ const CI: Markup = markup! {
""--formatter-enabled"" Allow to enable or disable the formatter check. (default: true)
""--linter-enabled"" Allow to enable or disable the linter check. (default: true)
""--max-diagnostics"" Cap the amount of diagnostics displayed (default: 50)
+ ""--config"" Set the filesystem path to the directory of the rome.json configuration file
""--verbose"" Print additional verbose advices on diagnostics"
{FORMAT_OPTIONS}
};
@@ -81,6 +83,7 @@ const FORMAT: Markup = markup! {
""--write"" Edit the files in place (beware!) instead of printing the diff to the console
""--skip-errors"" Skip over files containing syntax errors instead of emitting an error diagnostic.
""--max-diagnostics"" Cap the amount of diagnostics displayed (default: 50)
+ ""--config"" Set the filesystem path to the directory of the rome.json configuration file
""--verbose"" Print additional verbose advices on diagnostics"
{FORMAT_OPTIONS}
"""--stdin-file-path "" A file name with its extension to pass when reading from standard in, e.g. echo 'let a;' | rome format --stdin-file-path file.js
diff --git a/crates/rome_cli/src/commands/rage.rs b/crates/rome_cli/src/commands/rage.rs
index 57bbf870881..23a15082941 100644
--- a/crates/rome_cli/src/commands/rage.rs
+++ b/crates/rome_cli/src/commands/rage.rs
@@ -163,7 +163,7 @@ impl Display for RageConfiguration<'_, '_> {
fn fmt(&self, fmt: &mut Formatter) -> io::Result<()> {
Section("Rome Configuration").fmt(fmt)?;
- match load_config(self.0, None) {
+ match load_config(self.0, None, false) {
Ok(None) => KeyValuePair("Status", markup!("unset")).fmt(fmt)?,
Ok(Some(configuration)) => {
markup! (
diff --git a/crates/rome_cli/src/configuration.rs b/crates/rome_cli/src/configuration.rs
index 3c9c6c06578..5c50e7f22f4 100644
--- a/crates/rome_cli/src/configuration.rs
+++ b/crates/rome_cli/src/configuration.rs
@@ -1,3 +1,5 @@
+use std::path::PathBuf;
+
use rome_service::{load_config, Configuration};
use crate::{CliDiagnostic, CliSession};
@@ -5,7 +7,14 @@ use crate::{CliDiagnostic, CliSession};
/// Load the configuration for this session of the CLI, merging the content of
/// the `rome.json` file if it exists on disk with common command line options
pub(crate) fn load_configuration(session: &mut CliSession) -> Result {
- let mut configuration = load_config(&session.app.fs, None)?.unwrap_or_default();
+ let config_path: Option = session
+ .args
+ .opt_value_from_str("--config")
+ .map_err(|source| CliDiagnostic::parse_error("--config", source))?;
+
+ let is_config_path = config_path.is_some();
+
+ let mut config = load_config(&session.app.fs, config_path, is_config_path)?.unwrap_or_default();
let files_max_size = session
.args
@@ -13,9 +22,9 @@ pub(crate) fn load_configuration(session: &mut CliSession) -> Result
+```
+
+
diff --git a/crates/rome_cli/tests/snapshots/main_commands_format/invalid_config_file_path.snap b/crates/rome_cli/tests/snapshots/main_commands_format/invalid_config_file_path.snap
new file mode 100644
index 00000000000..7b483ff15e9
--- /dev/null
+++ b/crates/rome_cli/tests/snapshots/main_commands_format/invalid_config_file_path.snap
@@ -0,0 +1,23 @@
+---
+source: crates/rome_cli/tests/snap_test.rs
+assertion_line: 335
+expression: content
+---
+## `file.js`
+
+```js
+content
+```
+
+# Termination Message
+
+```block
+/test/rome.json internalError/fs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ × Rome couldn't read the following file, maybe for permissions reasons or it doesn't exists: /test/rome.json
+
+
+
+```
+
+
diff --git a/crates/rome_lsp/src/session.rs b/crates/rome_lsp/src/session.rs
index 548cf2d9b86..35b6ecf8e0a 100644
--- a/crates/rome_lsp/src/session.rs
+++ b/crates/rome_lsp/src/session.rs
@@ -366,7 +366,7 @@ impl Session {
pub(crate) async fn load_workspace_settings(&self) {
let base_path = self.base_path();
- let status = match load_config(&self.fs, base_path) {
+ let status = match load_config(&self.fs, base_path, false) {
Ok(Some(configuration)) => {
info!("Loaded workspace settings: {configuration:#?}");
diff --git a/crates/rome_service/src/configuration/mod.rs b/crates/rome_service/src/configuration/mod.rs
index 713ad9666aa..8c9a2a2ca49 100644
--- a/crates/rome_service/src/configuration/mod.rs
+++ b/crates/rome_service/src/configuration/mod.rs
@@ -128,50 +128,51 @@ impl FilesConfiguration {
pub fn load_config(
file_system: &DynRef,
base_path: Option,
+ show_error: bool,
) -> Result