@@ -50,8 +50,8 @@ async function main() {
5050 }
5151
5252 console . log ( '\n⚙️ Running database setup (generating JWT secret, configuring services)...' ) ;
53- // Let setup.ts run normally and ask all questions
54- runCommand ( 'pnpm tsx setup.ts' ) ;
53+ // Let setup.ts run normally and ask all questions (pnpm doesn't need sudo)
54+ execSync ( 'pnpm tsx setup.ts' , { stdio : 'inherit' , cwd : ROOT_DIR , env : process . env } ) ;
5555
5656 console . log ( '\n🔄 Adjusting .env for local machine access...' ) ;
5757 // NOW read the .env file that setup.ts just created
@@ -100,11 +100,11 @@ async function main() {
100100 console . log ( '✅ .env updated: Database services point to localhost' ) ;
101101
102102 console . log ( '\n📦 Installing DevContainer CLI...' ) ;
103- // Install with sudo so it's accessible system-wide for docker operations
103+ // Install with sudo -E to preserve PATH so npm and node can be found
104104 if ( needsSudoForDocker ( ) ) {
105- // Use full path to npm since sudo doesn't have user's PATH
106- const npmPath = execSync ( 'which npm' , { encoding : 'utf-8' } ) . trim ( ) ;
107- runCommand ( `sudo ${ npmPath } install -g @devcontainers/cli` ) ;
105+ // Use sudo -E to preserve environment variables ( PATH)
106+ const command = 'sudo -E npm install -g @devcontainers/cli' ;
107+ execSync ( command , { stdio : 'inherit' , cwd : ROOT_DIR , env : process . env } ) ;
108108 } else {
109109 runCommand ( 'pnpm install -g @devcontainers/cli' ) ;
110110 }
@@ -113,7 +113,7 @@ async function main() {
113113 if ( process . platform === 'linux' && needsSudoForDocker ( ) ) {
114114 console . log ( '\n🔧 Adding user to docker group...' ) ;
115115 const username = process . env . USER || process . env . USERNAME || 'ubuntu' ;
116- runCommand ( `sudo usermod -a -G docker ${ username } ` ) ;
116+ execSync ( `sudo usermod -a -G docker ${ username } ` , { stdio : 'inherit' } ) ;
117117 console . log ( 'ℹ️ You may need to log out and back in for docker group changes to take effect' ) ;
118118 }
119119
@@ -144,7 +144,7 @@ async function main() {
144144 }
145145
146146 console . log ( '\n📊 Applying database migrations...' ) ;
147- runCommand ( 'pnpm run apply_drizzle_migrations' ) ;
147+ execSync ( 'pnpm run apply_drizzle_migrations' , { stdio : 'inherit' , cwd : ROOT_DIR , env : process . env } ) ;
148148
149149 // Sample Data
150150 const dataAnswer = await inquirer . prompt ( [
@@ -159,7 +159,7 @@ async function main() {
159159 if ( dataAnswer . addSampleData ) {
160160 console . log ( '\n🌱 Seeding Sample Data...' ) ;
161161 try {
162- runCommand ( 'pnpm run add:sample_data' , false ) ;
162+ execSync ( 'pnpm run add:sample_data' , { stdio : 'inherit' , cwd : ROOT_DIR , env : process . env } ) ;
163163 console . log ( '✅ Sample data seeded successfully' ) ;
164164 } catch ( error ) {
165165 console . log ( '⚠️ Sample data seeding failed, but you can run it manually later:' ) ;
@@ -180,7 +180,7 @@ async function main() {
180180 // We use stdio: 'inherit' so the user interacts with the server directly
181181 try {
182182 // This works because the script context ALREADY has the correct PATH
183- execSync ( 'pnpm run start_development_server' , { stdio : 'inherit' } ) ;
183+ execSync ( 'pnpm run start_development_server' , { stdio : 'inherit' , cwd : ROOT_DIR , env : process . env } ) ;
184184 } catch ( e ) {
185185 // This catch block handles when the user presses Ctrl+C to stop the server
186186 console . log ( '\nServer stopped.' ) ;
0 commit comments