Skip to content

Commit ca5a38b

Browse files
authored
Ensure cwd actually has a default (#127)
Turns out, the default cwd was getting set on the JSON config after we had already deserialized it into a RubyDebugConfig. This meant there was not in fact a default cwd, so if a config failed to specify, the launch would fail with a cryptic: >process exited before debugger could connect This is because bundle/rdbg would immediately exit, as it was being run from the home directory, not the project's directory. closes #126
1 parent 97b120f commit ca5a38b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ruby.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ impl zed::Extension for RubyExtension {
166166
let mut connection = resolve_tcp_template(tcp_connection)?;
167167
let mut configuration: serde_json::Value = serde_json::from_str(&config.config)
168168
.map_err(|e| format!("`config` is not a valid JSON: {e}"))?;
169+
if let Some(configuration) = configuration.as_object_mut() {
170+
configuration
171+
.entry("cwd")
172+
.or_insert_with(|| worktree.root_path().into());
173+
}
169174

170175
let ruby_config: RubyDebugConfig = serde_json::from_value(configuration.clone())
171176
.map_err(|e| format!("`config` is not a valid rdbg config: {e}"))?;
@@ -213,11 +218,6 @@ impl zed::Extension for RubyExtension {
213218
}
214219
}
215220

216-
if let Some(configuration) = configuration.as_object_mut() {
217-
configuration
218-
.entry("cwd")
219-
.or_insert_with(|| worktree.root_path().into());
220-
}
221221
arguments.extend(ruby_config.args);
222222

223223
if use_bundler {

0 commit comments

Comments
 (0)