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

[windows] Electron application does not start after installing it #754

Closed
kittaakos opened this issue Oct 27, 2017 · 14 comments · Fixed by #761
Closed

[windows] Electron application does not start after installing it #754

kittaakos opened this issue Oct 27, 2017 · 14 comments · Fixed by #761
Assignees
Labels
electron issues related to the electron target

Comments

@kittaakos
Copy link
Contributor

After #738 I get this when I start the electron application after the installation

Failed to start the backend application.
Error: %1 is not a valid Win32 application.
\\?\C:\Users\kittaakos\AppData\Local\Programs\theia-electron-app-example\resources\app\node_modules\node-pty\build\Release\pty.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\kittaakos\AppData\Local\Programs\theia-electron-app-example\resources\app\node_modules\node-pty\lib\windowsPtyAgent.js:9:11)
    at Object.<anonymous> (C:\Users\kittaakos\AppData\Local\Programs\theia-electron-app-example\resources\app\node_modules\node-pty\lib\windowsPtyAgent.js:160:3)
C:\Users\kittaakos\AppData\Local\Programs\theia-electron-app-example\resources\app\node_modules\@theia\core\lib\node\cluster\main.js:41
    throw reason;
    ^

Error: %1 is not a valid Win32 application.
\\?\C:\Users\kittaakos\AppData\Local\Programs\theia-electron-app-example\resources\app\node_modules\node-pty\build\Release\pty.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\kittaakos\AppData\Local\Programs\theia-electron-app-example\resources\app\node_modules\node-pty\lib\windowsPtyAgent.js:9:11)
    at Object.<anonymous> (C:\Users\kittaakos\AppData\Local\Programs\theia-electron-app-example\resources\app\node_modules\node-pty\lib\windowsPtyAgent.js:160:3)
The express server worker 1 has been disconnected.
The express server worker 1 has been stopped.
@kittaakos kittaakos added the electron issues related to the electron target label Oct 27, 2017
@kittaakos
Copy link
Contributor Author

As a workaround, one can build it on Windows and then it starts. Later, it fails with something else.

@kittaakos
Copy link
Contributor Author

For some reason, editor.main module is not included:

loader.js:7 Loading "vs/editor/editor.main" failed
function.r.onError.r.onError @ loader.js:7
r.onError @ loader.js:7
s._onLoadError @ loader.js:7
s @ loader.js:7
(anonymous) @ loader.js:7
e.triggerErrorback @ loader.js:7
(anonymous) @ loader.js:7
(anonymous) @ loader.js:7
readFileAfterOpen @ fs.js:359
loader.js:7 Detail:  Error: ENOENT: no such file or directory, open 'c:\Users\kittaakos\dev\theia-electron-app-example\dist\win-unpacked\c%3A\Users\kittaakos\dev\theia-electron-app-example\dist\win-unpacked\resources\app\lib\vs\editor\editor.main.js'
function.r.onError.r.onError @ loader.js:7
r.onError @ loader.js:7
s._onLoadError @ loader.js:7
s @ loader.js:7
(anonymous) @ loader.js:7
e.triggerErrorback @ loader.js:7
(anonymous) @ loader.js:7
(anonymous) @ loader.js:7
readFileAfterOpen @ fs.js:359
loader.js:7 Error: ENOENT: no such file or directory, open 'c:\Users\kittaakos\dev\theia-electron-app-example\dist\win-unpacked\c%3A\Users\kittaakos\dev\theia-electron-app-example\dist\win-unpacked\resources\app\lib\vs\editor\editor.main.js'
function.r.onError.r.onError @ loader.js:7
r.onError @ loader.js:7
s._onLoadError @ loader.js:7
s @ loader.js:7
(anonymous) @ loader.js:7
e.triggerErrorback @ loader.js:7
(anonymous) @ loader.js:7
(anonymous) @ loader.js:7
readFileAfterOpen @ fs.js:359
loader.js:7 Here are the modules that depend on it:
function.r.onError.r.onError @ loader.js:7
r.onError @ loader.js:7
s._onLoadError @ loader.js:7
s @ loader.js:7
(anonymous) @ loader.js:7
e.triggerErrorback @ loader.js:7
(anonymous) @ loader.js:7
(anonymous) @ loader.js:7
readFileAfterOpen @ fs.js:359
loader.js:7 ["===anonymous1==="]0: "===anonymous1==="length: 1__proto__: Array(0)
function.r.onError.r.onError @ loader.js:7
r.onError @ loader.js:7
s._onLoadError @ loader.js:7
s @ loader.js:7
(anonymous) @ loader.js:7
e.triggerErrorback @ loader.js:7
(anonymous) @ loader.js:7
(anonymous) @ loader.js:7
readFileAfterOpen @ fs.js:359

@marcdumais-work
Copy link
Contributor

@kittaakos I get the same error on my Windows 10 installation, using latest master.

@marcdumais-work
Copy link
Contributor

/C:/Users/Marc/theia/examples/electron/lib/vs/loader.js:7 Detail:  Error: ENOENT: no such file or directory, open 'C:\Users\Marc\theia\examples\electron\c%3A\Users\Marc\theia\examples\electron\lib\vs\editor\editor.main.js'
function.r.onError.r.onError @ /C:/Users/Marc/theia/examples/electron/lib/vs/loader.js:7
/C:/Users/Marc/theia/examples/electron/lib/vs/loader.js:7 Error: ENOENT: no such file or directory, open 'C:\Users\Marc\theia\examples\electron\c%3A\Users\Marc\theia\examples\electron\lib\vs\editor\editor.main.js'
function.r.onError.r.onError @ /C:/Users/Marc/theia/examples/electron/lib/vs/loader.js:7
/C:/Users/Marc/theia/examples/electron/lib/vs/loader.js:7 Here are the modules that depend on it:
function.r.onError.r.onError @ /C:/Users/Marc/theia/examples/electron/lib/vs/loader.js:7
/C:/Users/Marc/theia/examples/electron/lib/vs/loader.js:7 Array(1)
function.r.onError.r.onError @ /C:/Users/Marc/theia/examples/electron/lib/vs/loader.js:7

@UdoW
Copy link

UdoW commented Oct 30, 2017

For me it gives me the follwoing error:

no such file or directory, open 'M:\projects\theia_20171030\theia\examples\electron\m%3A\projects\theia_20171030\theia\examples\electron\lib\vs\editor\editor.main.js'

Somehow the path is twice: first in with "M:.." then in the middle with "\m%3A..." again. I suppose building the absolute path or the sub path comparison is not working correctly.

@kittaakos
Copy link
Contributor Author

Still just a blind guess, but I think the problem is here: https://github.com/theia-ide/theia/blob/116222a7551917c59107a9288991a1e7e7cbe403/packages/monaco/src/electron-browser/monaco-electron-module.ts#L18

We cannot just convert the URI to string and load it as a module.

@kittaakos
Copy link
Contributor Author

The editor folder folder seems to be missing from vs:

OS X:
screen shot 2017-10-30 at 13 26 27

Windows:
screen shot 2017-10-30 at 13 26 13

@kittaakos
Copy link
Contributor Author

The problem is in the AMDLoader.Utilities.fileUriToFilePath. It will convert the file:///c%3A/Users/kittaakos/dev/theia-electron-app-example/lib/vs/editor/editor.main.js URI into a c%3A/Users/kittaakos/dev/theia-electron-app-example/lib/vs/editor/editor.main.js FS path.

@kittaakos
Copy link
Contributor Author

The decoreURI leaves the file:///c%3A/Users/kittaakos/dev/theia-electron-app-example/lib/vs/editor/editor.main.js as is.

@kittaakos
Copy link
Contributor Author

OK, so I believe this is a bug, VSCode's AMD loader cannot decode URIs with file scheme, so the FS path is incorrect. The module loading fails. Here is a very simple script that demonstrates the problem on Windows:

const Uri = require('vscode-uri').default;
const os = require('os');
const fs = require('fs');

const homeUri = Uri.parse(os.homedir());
console.log(homeUri.toString());
console.log(decodeURI(homeUri.toString()));
console.log('exists', fs.existsSync(decodeURI(homeUri.toString())));

const homeFileUri = Uri.file(os.homedir());
console.log(homeFileUri.toString());
console.log(decodeURI(homeFileUri.toString()));
console.log('exists', fs.existsSync(decodeURI(homeFileUri.toString())));
C:%5CUsers%5Ckittaakos
C:\Users\kittaakos
exists true
file:///c%3A/Users/kittaakos
file:///c%3A/Users/kittaakos
exists false

CC: @akosyakov

@akosyakov
Copy link
Member

baseUrl seems to be a path, could you try const baseUrl = __dirname;.

Decoding/encoding is encapsulated by vscode-uri, one should not do it again.

@kittaakos
Copy link
Contributor Author

It works with the approach from the very first commit: https://github.com/theia-ide/theia/blob/f0b1896f1b926839533a5874619d1442e6515cad/examples/browser/src/electron/index.html.

I try with the FS path too.

@kittaakos
Copy link
Contributor Author

const baseUrl = __dirname;.

It does not work, it expects a URI.

kittaakos added a commit that referenced this issue Oct 30, 2017
The `decodeURI` cannot handle the `file:///c%3A/foo` URIs (C:\foo)
inside the AMD loader. It will be converted into an incorrect
`c%3A/foo` path which obviously does not exist on Windows.

This should fix the broken electron application on Windows.

Closes #754.

Signed-off-by: Akos Kitta <kittaakos@gmail.com>
@kittaakos
Copy link
Contributor Author

PR: #761

@kittaakos kittaakos self-assigned this Oct 30, 2017
kittaakos added a commit that referenced this issue Nov 1, 2017
The `decodeURI` cannot handle the `file:///c%3A/foo` URIs (C:\foo)
inside the AMD loader. It will be converted into an incorrect
`c%3A/foo` path which obviously does not exist on Windows.

This should fix the broken electron application on Windows.

Closes #754.

Signed-off-by: Akos Kitta <kittaakos@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron issues related to the electron target
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants