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

fix: Update VS Code debugger script #1370

Closed
wants to merge 1 commit into from

Conversation

liamdawson
Copy link

Fix the debugger script to fix #1369, while still supporting the fix for #535.

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

Given the environment in #1369, this change supports running the debugger script, without breaking changes for users relying on the previous path structure. (Assuming it worked previously?)

Fix the debugger script to fix electron#1369, while still supporting the fix for electron#535.
@liamdawson liamdawson changed the title Update VS Code debugger script fix: Update VS Code debugger script Dec 24, 2019
@chetbox
Copy link
Contributor

chetbox commented Apr 29, 2020

The current documentation is incorrect because the script is expected to be run from a different location. This change means the script can be run from either location, which is great!

For those wondering, for now, you can debug the main (and renderer!) process with this configuration:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Electron: Main",
      "runtimeExecutable": "${workspaceFolder}/node_modules/@electron-forge/cli/script/vscode.sh",
      "windows": {
        "runtimeExecutable": "${workspaceFolder}/node_modules/@electron-forge/cli/script/vscode.cmd"
      },
      "runtimeArgs": ["--remote-debugging-port=9223"],
      "cwd": "${workspaceFolder}",
      "timeout": 60000
    },
    {
      "name": "Electron: Renderer: App",
      "type": "chrome",
      "request": "attach",
      "port": 9223,
      "webRoot": "${workspaceFolder}",
      "timeout": 120000,
      "url": "http://localhost:3000/app"
    }
  ],
  "compounds": [
    {
      "name": "Electron: All",
      "configurations": ["Electron: Main", "Electron: Renderer: App"]
    }
  ]
}

Edit: Tested on macOS only.

As an aside, how does one contribute a change to the electron-forge documentation? I think this is one for @MarshallOfSound.

@zachcowell
Copy link

@chetbox , I was seeking a solution to have the VS Code debugger working for both main and renderer processes and was able to get it working by modifying your config. I am using electron-forge with the webpack template

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Electron: Main",
      "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-nix",
      "windows": {
        "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-win.cmd"
      },
      "runtimeArgs": ["--remote-debugging-port=9223"],
      "cwd": "${workspaceFolder}"
    },
    {
      "name": "Electron: Renderer: App",
      "type": "chrome",
      "request": "attach",
      "port": 9223,
      "webRoot": "${workspaceFolder}",
      "timeout": 120000,
      "url": "http://localhost:3000/main_window"
    }
  ],
  "compounds": [
    {
      "name": "Electron: All",
      "configurations": ["Electron: Main", "Electron: Renderer: App"]
    }
  ]
}

@stephendpmurphy
Copy link

Can confirm that the temporary solution by @chetbox worked for me on Linux 👍

Copy link

@arsinclair arsinclair left a comment

Choose a reason for hiding this comment

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

Looks good to me, as it handles both the old and new way. I think it can be merged.

@arsinclair
Copy link

As an aside, how does one contribute a change to the electron-forge documentation?

@chetbox, it is in the electron-forge-docs repo, and there's already a PR to update the docs: electron-forge/electron-forge-docs#4.

@taylorhadden
Copy link

What's the holdup for this being merged in? Debugging on Mac is currently broken…

@liamdawson liamdawson closed this Jul 30, 2021
@gaziqbal
Copy link

Should this issue be closed? I ended up with the following workaround in my launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Electron: Main",
            "runtimeExecutable": "node",
            // LTS version - as installed via NVM
            "runtimeVersion": "18.15.0",
            "runtimeArgs": [
                "node_modules/@electron-forge/cli/dist/electron-forge-start",
                "--enable-logging",
                "--vscode",
                "--",
                // Delimited by ~ as expected by the electron-forge-start script.
                "~--remote-debugging-port=9223~"
            ],
            "cwd": "${workspaceFolder}"
        },
        {
            "name": "Electron: Renderer",
            "type": "chrome",
            "request": "attach",
            "port": 9223,
            "webRoot": "${workspaceFolder}",
            "timeout": 30000,
            "url": "http://localhost:3000/main_window"
        },
    ],
    "compounds": [
        {
            "name": "Electron: All",
            "configurations": [
                "Electron: Main",
                "Electron: Renderer"
            ]
        }
    ]
}

@arsinclair
Copy link

Why was this closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vscode-nix script cannot find the other executables
7 participants