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

Launch and Attach commands should respect the cwd parameter #24

Merged
merged 3 commits into from
Mar 24, 2022

Conversation

TikiTDO
Copy link
Contributor

@TikiTDO TikiTDO commented Mar 13, 2022

Both the launch and attach commands currently ignores the cwd parameter, which causes the debugger to fail in monorepos that have the Gemfile in a sub-directory. This PR ensures that the cwd parameter is applied everywhere it's necessary on launch.

Example:

If my rails server is in ${workspaceFolder}/backend, with my Gemfile in ${workspaceFolder}/backend/Gemfile, then I would like to run bundle exec rdbg in ${workspaceFolder}/backend as opposed to ${workspaceFolder}

@TikiTDO TikiTDO changed the title Launch command should respect the cwd parameter Launch and Attach commands should respect the cwd parameter Mar 13, 2022
@TikiTDO
Copy link
Contributor Author

TikiTDO commented Mar 19, 2022

@ko1 Any chance you could take a look at this PR? I'd really like to use this extension for my project, but it will not work without these changes.

if (config.cwd) {
// Ensure we are in the requested working directory
const cd_command = "cd " + config.cwd;
outputTerminal.sendText(cd_command);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it work correctly if cwd is relative path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would need to be a relative path from the workspace root.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it safe to start repeatedly?

Copy link
Collaborator

@ko1 ko1 Mar 22, 2022

Choose a reason for hiding this comment

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

I tried with cwd: "foo" (there is ${workspaceFolder}/foo directory) and it doesn't work on line get_sock_list() (ENOENT), so my question "Does it work correctly if cwd is relative path?" is "NO" and my real question "does it work on repeated launch with relative path cwd" is YES because this code is not reachable with a relative path.

(FYI: "cwd": "${workspaceFolder}/foo" works fine)

For better solution maybe we need to use File.expand_path() in Ruby to solve the relative path to absolute path, but I'm not sure how to do it on nodejs.

I'm okay to merge this commit. Do you want to care about this File.expand_path issue or can I merge it without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will fix it today. Just stuck in meetings for a few hours. Will get to it by the end of the day my time.

Copy link
Collaborator

@ko1 ko1 Mar 23, 2022

Choose a reason for hiding this comment

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

In other words, can I merge this PR and close it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this PR can be merged and closed.

I wanted to see if you're interested in documenting the above behavior. If you are then I can open another PR for that.

Copy link
Collaborator

@ko1 ko1 Mar 24, 2022

Choose a reason for hiding this comment

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

Thank you. I can't understand your point yet. To use with rvm this debugger needs wrapper script, you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I just want to know if you would like me to make a PR describing how I did this in the README.md.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Before adding it to the doc, I want to know why this wrapper is needed for rvm.
But this discussion should be done in other issue/PR, maybe.

@@ -44,7 +44,7 @@ function export_breakpoints(context: vscode.ExtensionContext) {
// outputChannel.appendLine(JSON.stringify(bp));
const start_line = bp.location.range.start.line;
const path = bp.location.uri.path;
bp_lines = bp_lines + "break " + path + ":" + start_line + "\n"
bp_lines = bp_lines + "break " + path + ":" + start_line + "\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

; is needed? (I'm TS newbe)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not strictly needed, but the rest of the code had it so my formatter added it in. I can change my formatter to remove all ;

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also don't care about it.

Copy link
Contributor Author

@TikiTDO TikiTDO Mar 22, 2022

Choose a reason for hiding this comment

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

If you'd like you can create a config file called .prettierrc.js with the following options:

module.exports = {
  semi: false,
}

Then you can install this plugin: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

It works a lot like rubocop, formatting your code to idiomatic typescript.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: You would also need to change this eslint rule: "@typescript-eslint/semi": "warn", -> "@typescript-eslint/semi": "off",

@ko1
Copy link
Collaborator

ko1 commented Mar 21, 2022

Thank you I'll merge it when the question is solved.

@ko1 ko1 merged commit b707ae7 into ruby:master Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants