Neubeki
Neubeki
DDeno
Created by Neubeki on 4/23/2025 in #help
Cannot read `include`d folder in compiled file
Hello, I am trying to compile an application and read a folder that I include with it. I am running into a problem with the output. I don't know how to read a directory inside the binary that I have included. I ran this command deno compile --include config to include the folder config in the binary, but I don't know how to read it and where to find it. This is my folder structure:
.
├── main.ts
├── deno.json
└── config/
├── .env
└── settings.json
.
├── main.ts
├── deno.json
└── config/
├── .env
└── settings.json
And running deno task dev can read the file, because everything is where it is expected. If I compile the program and run it from this folder, I can also access the directory, because the file is where it is supposed to relative to the 'config' folder. I want to have the config folder included though, so I can move the file freely around. Here's a sample program:
console.log("Attempting to read included 'config' directory...");

const configDir = "./config";
console.log(`Deno Version: ${Deno.version.deno}`);
console.log(`Attempting to access path: ${configDir}`);

try {
console.log("\nDirectory contents:");
for await (const dirEntry of Deno.readDir(configDir)) {
console.log(
`- ${dirEntry.name} (${dirEntry.isDirectory ? "dir" : "file"})`,
);
}
} catch (error) {
console.error("Error reading directory:", error);
}
console.log("Attempting to read included 'config' directory...");

const configDir = "./config";
console.log(`Deno Version: ${Deno.version.deno}`);
console.log(`Attempting to access path: ${configDir}`);

try {
console.log("\nDirectory contents:");
for await (const dirEntry of Deno.readDir(configDir)) {
console.log(
`- ${dirEntry.name} (${dirEntry.isDirectory ? "dir" : "file"})`,
);
}
} catch (error) {
console.error("Error reading directory:", error);
}
EDIT: My full example includes using deno workspaces and the file that reads the config folder is in another workspace than the one calling it. Which might introduce extra complexity
2 replies
DDeno
Created by Neubeki on 8/24/2024 in #help
Compiled app binary.rs main thread panicked
I have compiled a small test application with version 1.45.5 of Deno. The application is just a demo.
export function add(a: number, b: number): number {
return a + b
}
console.log(add(1, 2))
export function add(a: number, b: number): number {
return a + b
}
console.log(add(1, 2))
This is the error I get:
thread 'main' panicked at cli/standalone/binary.rs:243:66:
called `Result::unwrap()` on an `Err` value: Error("missing field `env_vars_from_env_file`", line: 1, column: 724)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /home/runner/work/deno/deno/runtime/tokio_util.rs:103:36:
called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(1), ...)
thread 'main' panicked at cli/standalone/binary.rs:243:66:
called `Result::unwrap()` on an `Err` value: Error("missing field `env_vars_from_env_file`", line: 1, column: 724)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /home/runner/work/deno/deno/runtime/tokio_util.rs:103:36:
called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(1), ...)
I've set the DENORT_BIN env var, which might have influenced this or not.
2 replies