关于 stf 的介绍, 我就不多说了, 懂的人自然懂.
之前实践过在 centos7 上安装 stf, 踩了不少坑, 最近换了在 Mac 上安装也踩了几个小坑, 记录一下. 赠人玫瑰, 手留余香. 希望能够帮到有同样坑的人.
安装
参照 GitHub 上的教程 https://github.com/openstf/stf , 总体分两步, 说起来很容易
首先检查一下基本的环境
- node -v
- NPM -v
- java -version
- adb version
如果以上四点均 OK 了, 那么可以开始下面
第一步
brew install RethinkDB graphicsmagick zeromq protobuf yasm pkg-config
第二步
NPM install -g stf
至此, 理想情况下 stf 就应该安装成功了.
但是总会遇到一些坑.
踩坑
node 版本问题
一般安装 node, 都是直接 brew 安装的
brew install node
这边默认安装的版本比较高, 而 stf 对 node 的最新版本没有做到完美兼容, 所以我们需要安装旧版本的 node, 以 8.x 为佳
在 GitHub 上看, 很多人题给作者的问题, 作者也会回复了, 建议使用 8.x
node version.PNG
至于怎么按准过老版本的 node, 建议使用 nvm
具体怎么用, 我参考的是这篇文章
报错 bufferutil@1.3.0 install: node-gyp rebuild
我在安装过程中主要是遇到这个问题, 报错如下:
- gyp ERR! configure error
- gyp ERR! stack Error: gyp failed with exit code: 1
- gyp ERR! stack at ChildProcess.onCpExit (/Users/dongshichao/.nvm/versions/node/v8.11.0/lib/node_modules/NPM/node_modules/node-gyp/lib/configure.JS:336:16)
- gyp ERR! stack at emitTwo (events.JS:126:13)
- gyp ERR! stack at ChildProcess.emit (events.JS:214:7)
- gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.JS:198:12)
- gyp ERR! System Darwin 17.5.0
- gyp ERR! command "/Users/dongshichao/.nvm/versions/node/v8.11.0/bin/node" "/Users/dongshichao/.nvm/versions/node/v8.11.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
- gyp ERR! cwd /Users/dongshichao/.nvm/versions/node/v8.11.0/lib/node_modules/stf/node_modules/bufferutil
- gyp ERR! node -v v8.11.0
- gyp ERR! node-gyp -v v3.6.2
- gyp ERR! not ok
- NPM ERR! code ELIFECYCLE
- NPM ERR! errno 1
- NPM ERR! bufferutil@1.3.0 install: node-gyp rebuild
- NPM ERR! Exit status 1
- NPM ERR!
- NPM ERR! Failed at the bufferutil@1.3.0 install script.
- NPM ERR! This is probably not a problem with NPM. There is likely additional logging output above.
- NPM ERR! A complete log of this run can be found in:
- NPM ERR! /Users/dongshichao/.NPM/_logs/2018-12-17T15_00_38_264Z-debug.log
我一开始 node 版本是 10.x, 后来安装报上面的错
后来我在 GitHub 上看到作者给别人的回复, 建议使用 8.x, 我刚换 8.11 后问题依然存在.
后来又安装 8.14, 使用 8.14 安装成功
最终, 我的版本是
- dongshichaodeMacBook-Pro:~ dongshichao$ node -v
- v8.14.0
- dongshichaodeMacBook-Pro:~ dongshichao$ NPM -v
- 6.4.1
踩完这两个坑, 输入
stf doctor
无报错, 则说明安装成功
stfdoctor.PNG
运行
安装成功后, 启动 stf
- RethinkDB
- stf local
本地浏览器输入
localhost:7100
登录后出现如下界面
devices.PNG
至此, stf 在 Mac 上安装算是完成.
来源: http://www.jianshu.com/p/0d6b5dffb046