Appium 菜鸟提问:appium 运行时出现“error: Failed to start an Appium session, err was: Error: Could not ex from ps output. PIDS: [], Procs: ["/system/bin/sh: grep: not found"]”

小鱼儿 · 2013年12月10日 · 最后由 恒温 回复于 2013年12月11日 · 2459 次阅读

运行 Appium 出现如下错误求解:
debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s emulator-55
54 push "E:\AppiumForWindows-0.12.0\Appium\node_modules\appium\build\andro
id_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
debug: Pushing unlock helper app to device...
debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s emulator-55
54 install E:\AppiumForWindows-0.12.0\Appium\node_modules\appium\build\unlock_ap
k\unlock_apk-debug.apk
info: Attempting to kill all 'uiautomator' processes
info: Getting all processes with 'uiautomator'
debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s emulator-55
54 shell "ps | grep 'uiautomator'"
info: Stopping logcat capture
info: Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: Cleaning up android objects
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not extract PIDs
from ps output. PIDS: [], Procs: ["/system/bin/sh: grep: not found"]
info: Responding to client with error: {"status":33,"value":{"message":"A new se
ssion could not be created. (Original error: Could not extract PIDs from ps outp
ut. PIDS: [], Procs: [\"/system/bin/sh: grep: not found\"])","origValue":"Could
not extract PIDs from ps output. PIDS: [], Procs: [\"/system/bin/sh: grep: not f
ound\"]"},"sessionId":null}
POST /wd/hub/session 500 13907ms - 336b

共收到 12 条回复 时间 点赞
  • 启动模拟器
  • 在命令行输入 adb shell
  • 在输入 grep

➜ ~ adb shell
root@generic:/ # busybox
/system/bin/sh: busybox: not found
127|root@generic:/ # busybox
/system/bin/sh: busybox: not found
127|root@generic:/ # grep
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[pattern] [file ...]

#1 楼 @lihuazhang 我也遇到了这个问题,手机上有 busybox,但是还是无法直接使用 grep,每次使用必须 busybox grep 这样,google 后在官网发现 jlipps 在 11 号修复了这个问题,删除了对 grep 的依赖,但是下载新版本后发现没有还是没有改变,只能下载源码中的 adb.js 替代,下图是针对 grep 的修改部分

#2 楼 @felix 赞. 这个分析很好, 之前有人提了 issue, 并提交了修复, 估计下个版本就会解决.

@seveniruby @zxp20034 请问这个 issue 解决了吗?我也碰到这个问题了现在 API 是 4.1 的真机设备.

@seveniruby 这样, 我自己在老版本 adb.js 里面修改了一下去掉对 grep 的依赖
this.shell("ps '" + name + "'", function(err, stdout) {
if (err) return cb(err);
stdout = stdout.trim();
if (! stdout) {
logger.info("No matching processes found");
return cb(null, []);
}
var procs = stdout.split("\n");
procs.shift();

我的 appium 是 2013-12-12 的最新版本,还是有这个问题。
按照 6 楼进行修改后,还是报错。API 是 4.03 的虚拟设备。
怎么办?

这是错误信息:
info: Attempting to kill all 'uiautomator' processes
info: Getting all processes with 'uiautomator'
debug: executing: "D:\Program Files\Android\android-sdk\platform-tools\adb.exe"
-s emulator-5554 shell "ps 'uiautomator'"
info: Stopping logcat capture
info: Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: Cleaning up android objects
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not extract PIDs
from ps output. PIDS: [], Procs: ["USER PID PPID VSIZE RSS WCHAN
PC NAME"]
info: Responding to client with error: {"status":33,"value":{"message":"A new se
ssion could not be created. (Original error: Could not extract PIDs from ps outp
ut. PIDS: [], Procs: [\"USER PID PPID VSIZE RSS WCHAN PC
NAME\"])","origValue":"Could not extract PIDs from ps output. PIDS: [], Procs: [
\"USER PID PPID VSIZE RSS WCHAN PC NAME\"]"},"sessionId":
null}
POST /wd/hub/session 500 25906ms - 394b

#8 楼 @wliym 你先用官方的版本吧, 看看错误是什么, 先不要自己修改

我最开始用的就是官方版本。下面是用官版本出现的错误信息。
debug: executing: "D:\Program Files\Android\android-sdk\platform-tools\adb.exe"
-s emulator-5554 push "E:\Eclipseworkspace\AndroidContactsTest\apps\ContactM
anager\ContactManager.apk" /data/local/tmp/4621b5c217c790d3e00fe3a441331c76.apk

debug: executing: "D:\Program Files\Android\android-sdk\platform-tools\adb.exe"
-s emulator-5554 shell "pm install -r /data/local/tmp/4621b5c217c790d3e00fe3a441
331c76.apk"
info: [ADB] Forwarding system:4724 to device:4724
debug: executing: "D:\Program Files\Android\android-sdk\platform-tools\adb.exe"
-s emulator-5554 forward tcp:4724 tcp:4724
debug: Pushing appium bootstrap to device...
debug: executing: "D:\Program Files\Android\android-sdk\platform-tools\adb.exe"
-s emulator-5554 push "F:\selenium\Appium\Appium\node_modules\appium\build
\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
debug: Pushing unlock helper app to device...
debug: executing: "D:\Program Files\Android\android-sdk\platform-tools\adb.exe"
-s emulator-5554 install F:\selenium\Appium\Appium\node_modules\appium\build\unl
ock_apk\unlock_apk-debug.apk
info: Attempting to kill all 'uiautomator' processes
info: Getting all processes with 'uiautomator'
debug: executing: "D:\Program Files\Android\android-sdk\platform-tools\adb.exe"
-s emulator-5554 shell "ps | grep 'uiautomator'"
info: Stopping logcat capture
info: Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: Cleaning up android objects
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not extract PIDs
from ps output. PIDS: [], Procs: ["grep: not found"]
info: Responding to client with error: {"status":33,"value":{"message":"A new se
ssion could not be created. (Original error: Could not extract PIDs from ps outp
ut. PIDS: [], Procs: [\"grep: not found\"])","origValue":"Could not extract PIDs
from ps output. PIDS: [], Procs: [\"grep: not found\"]"},"sessionId":null}
POST /wd/hub/session 500 31629ms - 304b

11楼 已删除

@lihuazhang
我在https://bitbucket.org/appium/appium.app/downloads/看到最新的是
“0.12.3”,给个 0.13 的下载链接吧!谢谢

#12 楼 @wliym 哦 就是 0.12.3 我错了。。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册