A problem occurred starting process ‘command ‘bash‘‘

Android React Native 异常处理

异常信息

bash 复制代码
> Task :react-native-audio-api:downloadPrebuiltBinaries FAILED

> Task :posthog-react-native-session-replay:generateCodegenSchemaFromJavaScript                                                                                                                                                     
No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.                                     

[Incubating] Problems report is available at: file:///D:/Git/Tencent/odin-client/android/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-audio-api:downloadPrebuiltBinaries'.
> A problem occurred starting process 'command 'bash''

处理过程

根本原因:这个下载任务是通过一个脚本来执行的,而这个脚本需要 bash 这个命令行工具来运行。你的 Windows 系统默认没有 bash,所以 Gradle 尝试调用 bash 时,系统告诉它"找不到这个命令",于是整个任务就失败了

通常需要在 Unix-like 环境(如 Linux, macOS, 或者 Windows 上的 Git Bash)中通过 bash 来执行

1.安装 Git for Windows (如果你还没装)

如果你已经安装了,请跳到第二步

如果没有,请从下载并安装,在安装过程中,务必在 "Adjusting your PATH environment" 这一步,选择 "Git from the command line and also from 3rd-party software" 这个选项会将 bash.exe 所在的目录(默认是 C:\Program Files\Git\bin)添加到系统的 Path 环境变量中

2.验证 Path 环境变量

打开 Windows 搜索,输入 "环境变量",选择 "编辑系统环境变量",点击 "环境变量..." 按钮

在 "系统变量" 区域,找到 Path 变量,双击它,在弹出的列表中,仔细检查是否存在类似

C:\Program Files\Git\bin 或 C:\Program Files\Git\usr\bin 的条目

如果没有,你需要手动添加它

点击"新建",然后把你的 Git 安装目录下的 bin 文件夹路径粘贴进去

如果有,那么配置本身是正确的

如何验证?Windows 下打开 CMD 执行如下命令

bash 复制代码
Microsoft Windows [版本 10.0.26100.7462]
(c) Microsoft Corporation。保留所有权利。

C:\Users\Engineer-jsp>bash --version
GNU bash, version 5.2.26(1)-release (x86_64-pc-msys)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

3.重启,让环境变量生效(最关键)

环境变量的修改不会影响已经打开的终端窗口

请完全关闭你所有的终端、PowerShell、CMD 窗口

请完全退出并重新打开你的代码编辑器(VS Code)

4.在新终端中验证

打开一个全新的 PowerShell 或 CMD 窗口

输入以下命令并回车: bash --version或者,对于 Windows CMD/PowerShell,可以使用 where 命令来查找 bash 的位置: where bash3.检查输出

如果 bash --version 成功打印出版本号,或者 where bash 成功打印出路径(如 C:\Program Files\Git\bin\bash.exe),那么恭喜你,你的环境已经准备好了!

如果 仍然提示"不是内部或外部命令",说明 Path 环境变量没有设置正确或没有生效,请回到第二、三步仔细检查

如:

bash 复制代码
C:\Users\Engineer-jsp>bash --version                                                                                    
GNU bash, version 5.2.26(1)-release (x86_64-pc-msys)                                                                    
Copyright (C) 2022 Free Software Foundation, Inc.                                                                       
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>                                           
                                                                                                                        
This is free software; you are free to change and redistribute it.                                                      
There is NO WARRANTY, to the extent permitted by law.                                                                   
                                                                                                                        
C:\Users\Engineer-jsp>where bash                                                                                        
D:\Git\Git\usr\bin\bash.exe 

5.清理并重新构建

在确认 bash 环境可用后,为了保险起见,进行一次清理

进入 android 目录并执行 clean 任务: cd android;./gradlew clean; cd .../

重新运行构建命令: bun run android

相关推荐
EnCi Zheng1 分钟前
P2G-Python字符串方法完全指南-split、join、strip、replace的Python编程利器
开发语言·python
爱学习的小囧3 分钟前
VCF 9 实验室网络部署全攻略:从硬件连接到配置实操
开发语言·网络·php
liliangcsdn14 分钟前
LLM如何与mcp server交互示例
linux·开发语言·python
军军君0121 分钟前
Three.js基础功能学习十五:智能黑板实现实例二
开发语言·前端·javascript·vue.js·3d·threejs·三维
维齐洛波奇特利(male)24 分钟前
@Pointcut(“execution(* com.hdzx..*(..))“)切入点与aop 导致无限循环
java·开发语言
来日可期131433 分钟前
C/C++ 反常识记录(1)—— 那些容易踩坑的语法细节
c语言·开发语言·c++
实心儿儿41 分钟前
C++ —— C++11(2)
开发语言·c++
立莹Sir1 小时前
云原生全解析:从概念到实践,Java技术栈如何拥抱云原生时代
java·开发语言·云原生
geovindu1 小时前
go: Factory Method Pattern
开发语言·后端·golang
前进的李工1 小时前
智能Agent实战指南:从入门到精通(工具)
开发语言·人工智能·架构·langchain·agent·tool·agentexecutor