@@ -105,32 +105,44 @@ export default class VsRocqToolchainManager implements Disposable {
105105 const config = workspace . getConfiguration ( 'vsrocq' ) . get ( 'args' ) as string [ ] ;
106106 const options = [ "-without-project-file" , "-where" ] . concat ( config ) ;
107107 const cmd = [ this . _vsrocqtopPath ] . concat ( options ) . join ( ' ' ) ;
108+ // fallback for < 2.4.0
109+ const pre240options = [ "-where" ] . concat ( config ) ;
110+ const pre240cmd = [ this . _vsrocqtopPath ] . concat ( pre240options ) . join ( ' ' ) ;
108111
109112 return new Promise ( ( resolve , reject : ( ( reason : ToolchainError ) => void ) ) => {
110- exec ( cmd , { cwd : workspace . rootPath } , ( error , stdout , stderr ) => {
111113
114+ const onSuccess = ( stdout : string ) => {
115+ this . _rocqPath = stdout ;
116+ this . rocqVersion ( ) . then (
117+ ( ) => resolve ( ) ,
118+ ( err ) => reject ( {
119+ status : ToolChainErrorCode . launchError ,
120+ message : `${ this . _vsrocqtopPath } crashed with the following message: ${ err } .
121+ This could be due to a bad Rocq installation or an incompatible Rocq version`
122+ } )
123+ ) ;
124+ } ;
125+
126+ const onError = ( stderr : string ) => {
127+ reject ( {
128+ status : ToolChainErrorCode . launchError ,
129+ message : `${ this . _vsrocqtopPath } crashed with the following message: ${ stderr }
130+ This could be due to a bad Rocq installation or an incompatible Rocq version.`
131+ } ) ;
132+ } ;
133+
134+ exec ( cmd , { cwd : workspace . rootPath } , ( error , stdout , stderr1 ) => {
112135 if ( error ) {
113- reject ( {
114- status : ToolChainErrorCode . launchError ,
115- message : `${ this . _vsrocqtopPath } crashed with the following message: ${ stderr }
116- This could be due to a bad Rocq installation or an incompatible Rocq version.`
136+ exec ( pre240cmd , { cwd : workspace . rootPath } , ( error , stdout , stderr2 ) => {
137+ if ( error ) {
138+ onError ( `${ cmd } \n${ stderr1 } \n\n${ pre240cmd } \n${ stderr2 } \n` ) ;
139+ } else {
140+ onSuccess ( stdout ) ;
141+ }
117142 } ) ;
118143 } else {
119- this . _rocqPath = stdout ;
120- this . rocqVersion ( ) . then (
121- ( ) => {
122- resolve ( ) ;
123- } ,
124- ( err ) => {
125- reject ( {
126- status : ToolChainErrorCode . launchError ,
127- message : `${ this . _vsrocqtopPath } crashed with the following message: ${ err } .
128- This could be due to a bad Rocq installation or an incompatible Rocq version`
129- } ) ;
130- }
131- ) ;
144+ onSuccess ( stdout ) ;
132145 }
133-
134146 } ) ;
135147 } ) ;
136148 } ;
0 commit comments