我目前正在为学校构建Adblock Plus的源代码 项目,我正在使用Autoinstall插件轻松部署到我的 浏览器,但Python中提供的构建工具似乎只能工作 当我出于某种原因在Git Bash中执行它们时。
当我尝试执行命令时,这是错误消息 Windows命令行:
C:\Users\Evert\Documents\GitHub\adblockplus>python build.py autoinstall 8888
Traceback (most recent call last):
File "C:\Users\Evert\Documents\GitHub\adblockplus\ensure_dependencies.py", line 380, in <module>
resolve_deps(repo)
File "C:\Users\Evert\Documents\GitHub\adblockplus\ensure_dependencies.py", line 324, in resolve_deps
update_repo(target, vcs, rev)
File "C:\Users\Evert\Documents\GitHub\adblockplus\ensure_dependencies.py", line 272, in update_repo
resolved_revision = repo_types[type].get_revision_id(target, revision)
File "C:\Users\Evert\Documents\GitHub\adblockplus\ensure_dependencies.py", line 106, in get_revision_id
return subprocess.check_output(command, cwd=repo).strip()
File "C:\Python27\lib\subprocess.py", line 212, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Command '['C:\\Python27\\python.exe', 'C:\\Users\\Evert\\Documents\\GitHub\\adblockplus\\ensure_dependencies.py', 'C:\\Users\\Evert\\Documents\\GitHub\\adblockplus']' returned non-zero exit status 1
Failed to ensure dependencies being up-to-date!
Traceback (most recent call last):
File "build.py", line 18, in <module>
buildtools.build.processArgs(BASE_DIR, sys.argv)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\build.py", line 601, in processArgs
commands[command](baseDir, scriptName, opts, args, type)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\build.py", line 55, in __call__
return self._handler(baseDir, scriptName, opts, args, type)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\build.py", line 225, in runAutoInstall
packager.autoInstall(baseDir, type, host, port, multicompartment=multicompartment)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\packagerGecko.py", line 334, in autoInstall
createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multicompartment)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\packagerGecko.py", line 294, in createBuild
version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\packager.py", line 58, in getBuildVersion
buildNum = getBuildNum(baseDir)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\packager.py", line 46, in getBuildNum
result = subprocess.check_output(['git', 'rev-list', 'HEAD'], cwd=baseDir)
File "C:\Python27\lib\subprocess.py", line 212, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
这对我来说不是一个大问题,因为它确实构建了,但我忍不住 想知道:这两种环境之间有什么区别 这个脚本有用吗?
答案 0 :(得分:0)
问题似乎是git.exe
不在您的Windows PATH
中,它肯定是在Git Bash :)中。对于git
:
ensure_dependencies.py
第106行,执行command
。每the source,命令为['git', 'rev-parse', '--revs-only', rev + '^{commit}']
。packager.py
第46行,执行['git', 'rev-list', 'HEAD']
。这两个都缺失git
。要在运行python build.py
之前修复,请执行
path %PATH%;c:\<wherever git.exe is located>
或使用“控制面板”将git.exe
的位置添加到系统路径。
修改如果您的Git安装来自GitHub,this answer会提供有关向您的PATH
添加Git的详细信息。