Ebiko
Ebiko2mo ago

could not find "deno.json" after compile

I tried to use deno compile to create a binary with mixed results. Using
deno compile -A main.ts
deno compile -A main.ts
creates a windows binary. (I have also tried with the target flag for Linux, same error) Error Transfering this binary to another host and trying to execute it, does not work, as it will throw an error: Could not find a deno.json file in the current directory or any parent directory. Details * executing this binary on the compiling host works (even without a deno.json in the folder) * executing this (or the linux) binary on another host does not work (even when the deno.json is inside the same folder as the executable) What am I missing here ? Repo for References: https://github.com/b3-business/secretshare/releases/tag/0.1 Thanks
GitHub
Release secretshare 0.1 demo · b3-business/secretshare
Demo Release 0.1 for secretshare
11 Replies
Deno AI Helper
Deno AI Helper2mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, it seems like the binary is looking for a deno.json configuration file and not finding it where it expects. One thing to consider is that when you compile a Deno project into a single executable, the resulting binary should be self-contained and not require external files like deno.json to run, as the configuration should be baked into the binary at compile time. This is assuming that you are not dynamically loading the deno.json file in your code. If you are certain that your code or any dependencies do not explicitly require deno.json at runtime, this behavior might be unexpected. Make sure that your main.ts or any other part of your code does not try to load the deno.json file dynamically. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. If the issue persists, it might be helpful to reach out to the Deno community or check the GitHub issues for similar problems reported by other users.
Ebiko
Ebiko2mo ago
Even if I use deno compile --include deno.json -A main.ts the binary still is unable to find the deno.json file. I have no idea what is happening here.
raunioroo
raunioroo2mo ago
I'm guessing AI is correct in that something in your code or dependencies is trying to access deno.json directly. And Fresh seems to be a likely culprit here. I don't use fresh so can't help you much further sry
raunioroo
raunioroo2mo ago
https://github.com/denoland/fresh/pull/1208/files here's a relevant looking part in fresh src
GitHub
feat: remove hardcoded deno.json path by iceghost · Pull Request ...
Fixes #961 I needed to put my fresh project inside a subdirectory and this was getting in the way. I fixed it
Ebiko
Ebiko2mo ago
even if I literally place the executable inside the cloned repository, it still wont find the file.
Ebiko
Ebiko2mo ago
No description
Ebiko
Ebiko2mo ago
Not a single result referencing deno.json
No description
Ebiko
Ebiko2mo ago
@CodeMonument
raunioroo
raunioroo2mo ago
Well, Fresh appears to use some kind of build step where deno.json location is resolved on build time and the path then gets hardcoded to the built file. So it makes sense the path would work on the original host. I don't use Fresh so I'm a bit hesitant to advice further. But I'm guessing Fresh is not really designed to be compiled into a standalone binary (I may be wrong, might be a good idea to ask over at https://discord.com/channels/684898665143206084/991511118524715139 )
No description
Ebiko
Ebiko2mo ago
I do appreciate your thoughts, really thanks for that. I just assumed it to work effortlessly, as it does with bun. Interestingly, if I launch the executable on the system which built the executable, i can place the executable anywhere on the system, and it works. So you may be right, and fresh does hard code the deno.json path into the binary for some reason Going to ask over at fresh. Thanks.
Ebiko
Ebiko2mo ago
for reference: created a Issue ticket in the deno fresh github https://github.com/denoland/fresh/issues/2402
GitHub
[bug] deno compile binary does not work on other machines · Issue #...
As I wanted to run my deno fresh app in a blacksite, with no internet access at all, I tried to use deno compile. Issue Starting the compiled binary on another host, than the compiling one will alw...