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

Compile without console #13107

Closed
JasperVanEsveld opened this issue Dec 16, 2021 · 10 comments
Closed

Compile without console #13107

JasperVanEsveld opened this issue Dec 16, 2021 · 10 comments
Labels

Comments

@JasperVanEsveld
Copy link
Contributor

This was mentioned in a comment before
It would be nice to have given that webview_deno will (hopefully) be updated soon after deno#12828 was merged
Which would allow for electron like applications

One way to do this could be with a command like deno compile --no-console
That downloads a deno binary that doesn't use the console, similar to how --target works

Compiling deno without a console can be done by adding:
#![windows_subsystem = "windows"]
To the top of cli/main.rs
Or by passing arguments to rustc

@crowlKats
Copy link
Member

Ref #12941

@JasperVanEsveld
Copy link
Contributor Author

That may be a better solution, as you don't need 2 windows binaries
Though it does feel hacky

@stale
Copy link

stale bot commented Feb 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 16, 2022
@stale stale bot closed this as completed Feb 23, 2022
@joao678
Copy link

joao678 commented Mar 29, 2023

I've managed to solve this with a little workaround: take the .exe generated by deno and somehow change the Subsystem flag in the optional headers of the executable, there is a lot of ways to do this, the most pratical for me is using a python script that does this automatically like so

import os
import os.path
import pefile

print('Modifying generated executable subsystem...')
binary = pefile.PE(os.getcwd()+"\\deno_test.exe", fast_load=True)
binary.OPTIONAL_HEADER.Subsystem = 2
binary.write(filename="deno_test.mod.exe")
binary.close()

os.remove("deno_test.exe")
os.rename("deno_test.mod.exe", "deno_test.exe")

You can also use a program like PE Bear to then open the executable in the program, find the optional headers section and change the subsystem manually

@svefro
Copy link

svefro commented Oct 25, 2024

this needs to be resolved for us that want to use deno to make small gui apps. like using webUI on windows.

tested python script but got no gui at all then.

@bartlomieju
Copy link
Member

You can use --no-console flag with deno compile

@svefro
Copy link

svefro commented Oct 26, 2024

You can use --no-console flag with deno compile
"unexpected argument '--no-console' found"

The parameter is called "--no-terminal" and does not work as intended.
No gui is shown at all on windows.
and application exits right away

@svefro
Copy link

svefro commented Dec 6, 2024

could not get --no-terminal to work so i made this https://jsr.io/@svefro/win-console-window-state

@Reububble
Copy link

Reububble commented Jan 17, 2025

I've been annoyed by this issue recently and decided to look into what's going wrong. I'm able to get stderr from my compiled exe (using start /b test.exe 2> stderr) and that tells me

thread 'main' panicked at runtime\worker.rs:696:7:
Bootstrap exception: ReferenceError: null or invalid handle
    at guessHandleType (ext:deno_node/internal_binding/util.ts:38:16)
    at _guessStdinType (ext:deno_node/_process/streams.mjs:137:10)
    at initStdin (ext:deno_node/_process/streams.mjs:162:38)
    at Object.internals.__bootstrapNodeProcess (node:process:683:22)
    at initialize (ext:deno_node/02_init.js:34:15)
    at bootstrapMainRuntime (ext:runtime_main/js/99_main.js:892:7)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at C:\a\deno\deno\runtime\tokio_util.rs:111:36:
called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(1), ...)

Without being familiar with the backend of deno, I interpret this as an issue regressed when adding node support. It's also clear that it's an issue getting stdin. So I've tried my program again, providing a file for stdin, stdout and stderr, and everything works.
start /b test.exe < stdin > stdout 2> stderr.
Removing any input/output file results in a failure.

The only reason I was able to debug this at all was because I happened to try start /b which I had used in the past to run a no console app while capturing stdout and stderr.

@Reububble
Copy link

I've found #21091 which seems like the right issue

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

No branches or pull requests

6 participants