@@ -111,20 +111,51 @@ export default class pioarduinoCoreStage extends BaseStage {
111111 // Check if .platformio/penv directory exists
112112 await fs . access ( penvDir ) ;
113113
114- // Check if we have the builtin core directory
114+ // Try to find pio executable in different locations
115+ const pioExecutablePaths = [
116+ path . join ( penvDir , 'bin' , 'pio' ) , // Unix/macOS
117+ path . join ( penvDir , 'Scripts' , 'pio.exe' ) , // Windows
118+ path . join ( penvDir , 'bin' , 'platformio' ) , // Alternative Unix name
119+ path . join ( penvDir , 'Scripts' , 'platformio.exe' ) , // Alternative Windows name
120+ ] ;
121+
122+ let foundExecutable = false ;
123+ for ( const execPath of pioExecutablePaths ) {
124+ try {
125+ await fs . access ( execPath ) ;
126+ foundExecutable = true ;
127+ console . info ( 'Found pioarduino executable at:' , execPath ) ;
128+ break ;
129+ } catch ( err ) {
130+ // Continue checking other paths
131+ }
132+ }
133+
134+ if ( ! foundExecutable ) {
135+ console . warn ( 'pioarduino penv directory exists but no executable found' ) ;
136+ return false ;
137+ }
138+
139+ // For builtin core, also check core directory (but don't fail if missing)
115140 if ( this . params . useBuiltinPIOCore ) {
116- await fs . access ( core . getEnvBinDir ( ) ) ;
141+ try {
142+ await fs . access ( core . getEnvBinDir ( ) ) ;
143+ console . info ( 'Builtin core directory also found:' , core . getEnvBinDir ( ) ) ;
144+ } catch ( err ) {
145+ console . info ( 'Builtin core not found, but global installation is sufficient' ) ;
146+ }
117147 }
118148
119149 console . info ( 'Local pioarduino installation found:' , {
120150 pioarduinoDir,
121151 penvDir,
122- coreDir : this . params . useBuiltinPIOCore ? core . getEnvBinDir ( ) : 'global'
152+ hasExecutable : foundExecutable ,
153+ useBuiltinCore : this . params . useBuiltinPIOCore
123154 } ) ;
124155
125156 return true ;
126157 } catch ( err ) {
127- // Silent fail for local check
158+ // console.debug('Local pioarduino check failed:', err.message);
128159 return false ;
129160 }
130161 }
0 commit comments