@@ -25,6 +25,7 @@ use node_runtime::{NodeRuntime, VersionStrategy};
2525use parking_lot:: Mutex ;
2626use project:: DisableAiSettings ;
2727use request:: StatusNotification ;
28+ use semver:: Version ;
2829use serde_json:: json;
2930use settings:: Settings ;
3031use settings:: SettingsStore ;
@@ -485,6 +486,8 @@ impl Copilot {
485486 let start_language_server = async {
486487 let server_path = get_copilot_lsp ( fs, node_runtime. clone ( ) ) . await ?;
487488 let node_path = node_runtime. binary_path ( ) . await ?;
489+ ensure_node_version_for_copilot ( & node_path) . await ?;
490+
488491 let arguments: Vec < OsString > = vec ! [ server_path. into( ) , "--stdio" . into( ) ] ;
489492 let binary = LanguageServerBinary {
490493 path : node_path,
@@ -1161,6 +1164,44 @@ async fn clear_copilot_config_dir() {
11611164 remove_matching ( copilot_chat:: copilot_chat_config_dir ( ) , |_| true ) . await
11621165}
11631166
1167+ async fn ensure_node_version_for_copilot ( node_path : & Path ) -> anyhow:: Result < ( ) > {
1168+ const MIN_COPILOT_NODE_VERSION : Version = Version :: new ( 20 , 8 , 0 ) ;
1169+
1170+ log:: info!( "Checking Node.js version for Copilot at: {:?}" , node_path) ;
1171+
1172+ let output = util:: command:: new_smol_command ( node_path)
1173+ . arg ( "--version" )
1174+ . output ( )
1175+ . await
1176+ . with_context ( || format ! ( "checking Node.js version at {:?}" , node_path) ) ?;
1177+
1178+ if !output. status . success ( ) {
1179+ anyhow:: bail!(
1180+ "failed to run node --version for Copilot. stdout: {}, stderr: {}" ,
1181+ String :: from_utf8_lossy( & output. stdout) ,
1182+ String :: from_utf8_lossy( & output. stderr) ,
1183+ ) ;
1184+ }
1185+
1186+ let version_str = String :: from_utf8_lossy ( & output. stdout ) ;
1187+ let version = Version :: parse ( version_str. trim ( ) . trim_start_matches ( 'v' ) )
1188+ . with_context ( || format ! ( "parsing Node.js version from '{}'" , version_str. trim( ) ) ) ?;
1189+
1190+ if version < MIN_COPILOT_NODE_VERSION {
1191+ anyhow:: bail!(
1192+ "GitHub Copilot language server requires Node.js {MIN_COPILOT_NODE_VERSION} or later, but found {version}. \
1193+ Please update your Node.js version or configure a different Node.js path in settings."
1194+ ) ;
1195+ }
1196+
1197+ log:: info!(
1198+ "Node.js version {} meets Copilot requirements (>= {})" ,
1199+ version,
1200+ MIN_COPILOT_NODE_VERSION
1201+ ) ;
1202+ Ok ( ( ) )
1203+ }
1204+
11641205async fn get_copilot_lsp ( fs : Arc < dyn Fs > , node_runtime : NodeRuntime ) -> anyhow:: Result < PathBuf > {
11651206 const PACKAGE_NAME : & str = "@github/copilot-language-server" ;
11661207 const SERVER_PATH : & str =
0 commit comments