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

Debugging does not work #23

Closed
sebakerckhof opened this issue Jan 16, 2017 · 9 comments
Closed

Debugging does not work #23

sebakerckhof opened this issue Jan 16, 2017 · 9 comments

Comments

@sebakerckhof
Copy link

@sebakerckhof sebakerckhof commented Jan 16, 2017

Using normal electron-prebuilt I can debug apps using the way described here:
https://github.com/electron/electron/blob/master/docs/tutorial/debugging-main-process.md

So like electron --debug-brk=5858 test/index.js

If I replace electron prebuilt with electron-prebuilt-compile, the same command gives me:

/home/seke/dev/purple/app/node_modules/.bin/electron --debug-brk=5858 --nolazy test/index.js 
App threw an error during load
Error: Cannot find module '/home/seke/dev/purple/app/--debug-brk=5858'
    at Module._resolveFilename (module.js:455:15)
    at Function.Module._resolveFilename (/home/seke/dev/purple/app/node_modules/electron/dist/resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at init (/home/seke/dev/purple/app/node_modules/electron-compile/lib/config-parser.js:279:16)
    at main (/home/seke/dev/purple/app/node_modules/electron-prebuilt-compile/lib/es6-init.js:38:29)
    at Object.<anonymous> (/home/seke/dev/purple/app/node_modules/electron-prebuilt-compile/lib/es6-init.js:41:1)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
@soitech

This comment has been minimized.

Copy link

@soitech soitech commented Feb 28, 2017

+1 using electron-forge with my project broke debugging in Webstorm.

@anaisbetts

This comment has been minimized.

Copy link
Contributor

@anaisbetts anaisbetts commented Mar 4, 2017

We probably have to special-case those paths, hm

@jacobq

This comment has been minimized.

Copy link

@jacobq jacobq commented Mar 15, 2017

I'm trying to figure out adopted-ember-addons/ember-electron#175 which seems to be related to this as well (ember-electron is transitioning to using electron-forge, which uses electron-prebuilt-compile).

It looks to me like what's breaking some of my existing code is that __dirname no longer points to my app's dist folder but rather to something like <app>/node_modules/electron-prebuilt-compile/node_modules/electron/dist/resources/electron.asar/renderer. reset-search-paths.js causes the node module search algorithm to only walk up directories from <app>/node_modules/electron-prebuilt-compile/node_modules/electron/dist/resources/electron.asar/renderer/init.js and to stop when it hits the resources directory. Since the node_modules I want to access are in <app>/node_modules, attempting to require them without specifying an explicit path causes a Cannot find module error to occur.

One can work around this by specifying paths to modules, but this gets rather messy quickly. As a quick & dirty work-around, I ended up defeating the search path protection by putting entries back into globalPaths, but I feel like there should be a way to get these modules without "cheating" like that.

Could anyone help me understand the way this was intended to be done?

@Hum4n01d

This comment has been minimized.

Copy link

@Hum4n01d Hum4n01d commented Apr 13, 2017

Wow. I finally figured out that this was the problem behind my app not debugging in neither VSCode nor PyCharm!! Please fix this! @paulcbetts

@anaisbetts

This comment has been minimized.

Copy link
Contributor

@anaisbetts anaisbetts commented Apr 13, 2017

@jacobq reset-search-paths is part of Electron proper, not part of prebuilt-compile

@jacobq

This comment has been minimized.

Copy link

@jacobq jacobq commented Apr 13, 2017

@paulcbetts Right, but I believe it gets a different "starting point" (root module? forgive my ignorance of the proper term) when running with electron-prebuilt-compile for some reason. The problem I was having has been solved now though, so I haven't given this further thought.

@Hum4n01d

This comment has been minimized.

Copy link

@Hum4n01d Hum4n01d commented Apr 13, 2017

The problem is here: https://github.com/electron-userland/electron-prebuilt-compile/blob/master/src/cli.js#L6. The cli arguments aren't being interpreted properly. This is causing electron-prebuilt-compile to try and run the app /path/to/electron/app/--debug-brk=5858 which is not a valid directory let alone an electron app.

Flags need to be parsed separately from arguments

@MarshallOfSound

This comment has been minimized.

Copy link
Member

@MarshallOfSound MarshallOfSound commented Apr 16, 2017

Of note to people in this issue, there's a PR up to expose an entrypoint in forge for super easy debugging through VSCode

electron-userland/electron-forge#198

@anaisbetts

This comment has been minimized.

Copy link
Contributor

@anaisbetts anaisbetts commented Apr 16, 2017

electron-forge is a good place to fix this, closing here

@anaisbetts anaisbetts closed this Apr 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.