fix(code-tools): support Chinese paths and validate directory existence (#11489)
- Add `chcp 65001` to Windows batch file to switch CMD.exe to UTF-8 code page, fixing CLI tool launch failure when working directory contains Chinese or other non-ASCII characters - Add directory existence validation before launching terminal to provide immediate error feedback instead of delayed failure Closes #11483 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -548,6 +548,17 @@ class CodeToolsService {
|
||||
logger.debug(`Environment variables:`, Object.keys(env))
|
||||
logger.debug(`Options:`, options)
|
||||
|
||||
// Validate directory exists before proceeding
|
||||
if (!directory || !fs.existsSync(directory)) {
|
||||
const errorMessage = `Directory does not exist: ${directory}`
|
||||
logger.error(errorMessage)
|
||||
return {
|
||||
success: false,
|
||||
message: errorMessage,
|
||||
command: ''
|
||||
}
|
||||
}
|
||||
|
||||
const packageName = await this.getPackageName(cliTool)
|
||||
const bunPath = await this.getBunPath()
|
||||
const executableName = await this.getCliExecutableName(cliTool)
|
||||
@@ -709,6 +720,7 @@ class CodeToolsService {
|
||||
// Build bat file content, including debug information
|
||||
const batContent = [
|
||||
'@echo off',
|
||||
'chcp 65001 >nul 2>&1', // Switch to UTF-8 code page for international path support
|
||||
`title ${cliTool} - Cherry Studio`, // Set window title in bat file
|
||||
'echo ================================================',
|
||||
'echo Cherry Studio CLI Tool Launcher',
|
||||
|
||||
Reference in New Issue
Block a user