From 84bc52264f4e40238e6985e1c15dba9dd5f58823 Mon Sep 17 00:00:00 2001 From: Crimson341 <150315417+Crimson341@users.noreply.github.com> Date: Tue, 6 Jan 2026 07:11:50 -0500 Subject: [PATCH] fix(setup): auto-create .env from .env.example during backend install (#713) * fix(setup): auto-create .env from .env.example during backend installation - Fixes 'exit code 127' error when .env is missing - Automatically copies .env.example to .env if it doesn't exist - Provides clear instructions for users to configure credentials Signed-off-by: thuggys <150315417+thuggys@users.noreply.github.com> * Update scripts/install-backend.js Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Signed-off-by: thuggys <150315417+thuggys@users.noreply.github.com> Co-authored-by: thuggys <150315417+thuggys@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Andy <119136210+AndyMik90@users.noreply.github.com> Co-authored-by: Alex <63423455+AlexMadera@users.noreply.github.com> --- scripts/install-backend.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/install-backend.js b/scripts/install-backend.js index 78548f2b..40d3a4fc 100644 --- a/scripts/install-backend.js +++ b/scripts/install-backend.js @@ -103,6 +103,29 @@ async function main() { process.exit(1); } + // Create .env file from .env.example if it doesn't exist + const envPath = path.join(backendDir, '.env'); + const envExamplePath = path.join(backendDir, '.env.example'); + + if (fs.existsSync(envPath)) { + console.log('\nāœ“ .env file already exists'); + } else if (fs.existsSync(envExamplePath)) { + console.log('\nCreating .env file from .env.example...'); + try { + fs.copyFileSync(envExamplePath, envPath); + console.log('āœ“ Created .env file'); + console.log(' Please configure it with your credentials:'); + console.log(` - Run: claude setup-token`); + console.log(` - Or edit: ${envPath}`); + } catch (error) { + console.warn('Warning: Could not create .env file:', error.message); + console.warn('You will need to manually copy .env.example to .env'); + } + } else { + console.warn('\nWarning: .env.example not found. Cannot auto-create .env file.'); + console.warn('Please create a .env file manually if your configuration requires it.'); + } + console.log('\nBackend installation complete!'); console.log(`Virtual environment: ${venvDir}`); }