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

相关推荐
aramae1 小时前
模拟实现strcmp()(C语言)
c语言·开发语言·后端
泡海椒2 小时前
PDF 表格样式优化:jquick-pdf 边框、圆角、背景色
java·开发语言·pdf
Beyond_System|系统之外3 小时前
【学编程】Python基础编程题100道(21-60)
开发语言·python·算法
景熙55233 小时前
15.Java 8 Stream 流入门到实战
java·开发语言·数据结构
Bruce_Liuxiaowei6 小时前
Python 实例赋值遮蔽类属性:一个从不报错的静默陷阱
开发语言·python·语法糖
aramae7 小时前
MySQL内置函数(7)
开发语言·笔记·后端·mysql·其他
码行山野赴时序归途10 小时前
链表家族收官篇:循环链表
c语言·开发语言·数据结构·链表
景熙552310 小时前
单体项目编写思路和落地形式
java·开发语言
计算机毕设定制辅导-无忧学长11 小时前
《基于SpringBoot的未成年人健康知识科普平台的设计与实现》
java·开发语言·vue.js·spring boot·未成年人健康知识科普平台
Ivanqhz11 小时前
Ping-Pong 双缓冲
开发语言·人工智能·python·深度学习·mlir