fix: Handle chmod/mkdir permission errors on mounted volumes

Wrap chmod and mkdir with mode operations in try-catch blocks to
prevent EPERM errors when running in containers with mounted volumes.

macOS and some container runtimes don't allow chmod operations on
mounted directories, causing the app to crash on startup.
This commit is contained in:
2025-12-29 18:41:37 -08:00
parent 13164b89aa
commit 6cd5f0fa81
+13 -2
View File
@@ -23,7 +23,13 @@ program
function initalizeConfig() {
if (!fs.existsSync(Config.getConfigPath())) {
fs.mkdirSync(Config.getHomePath(), {recursive: true});
fs.chmodSync(Config.getHomePath(), "0700");
try {
fs.chmodSync(Config.getHomePath(), "0700");
} catch (e) {
// Ignore chmod errors (e.g., on mounted volumes)
}
fs.copyFileSync(
path.resolve(path.join(__dirname, "..", "..", "defaults", "config.js")),
Config.getConfigPath()
@@ -31,7 +37,12 @@ function initalizeConfig() {
log.info(`Configuration file created at ${colors.green(Config.getConfigPath())}.`);
}
fs.mkdirSync(Config.getUsersPath(), {recursive: true, mode: 0o700});
try {
fs.mkdirSync(Config.getUsersPath(), {recursive: true, mode: 0o700});
} catch (e) {
// Ignore permission errors on mounted volumes
fs.mkdirSync(Config.getUsersPath(), {recursive: true});
}
}
export default program;