compiled artifact can't find deno.json
I'm using github actions to build and publish a binary like so
After downloading and unzipping the binary I noticed I have to add
chmod +x web
which is fine, but then I see
even if I'm running in a directory with a deno.json file.
I'm running deno 1.37.0
Thanks in advance!4 Replies
Based on the documentation, when you run a Deno command, Deno will try to find a configuration file (
deno.json
or deno.jsonc
) by checking the current working directory and its parent directories in order. If none of the paths exist, Deno will run without applying any configuration.
However, when you compile a Deno program into a standalone binary using deno compile
, the binary does not retain the original file structure or the original working directory. Therefore, it cannot find the deno.json
file in the current directory or any parent directory at runtime, even if it exists there.
As a workaround, you might consider including all necessary configurations in your code before compiling it, or using environment variables to pass configuration at runtime. Please note that this information is not explicitly stated in the documentation, so it's a general advice.
If you're still having issues, it might be helpful to provide more information about your deno.json
file and how you're using it in your code. This could help identify any potential issues or misunderstandings. 🦕Following up on the above, my
deno.json
file looks like this
I don't think this is at issue because for whatever reason it's not able to find the deno.json
file despite the file being there in the folder in which the binary is being run.You can strace it to see where it's searching
If you can embed the JSON into the executable, you can try to
--include
the deno.json
: https://docs.deno.com/runtime/manual/tools/compiler#dynamic-importsCompiling Executables | Deno Docs
deno compile [--output ] will compile the script into a