HBuilderX 核心插件安装提示:“插件XXX下载失败,请检查网络”问题的解决办法

前言

工欲善其事必先利其器,HBuilderX出现的问题最重要的是要使用自带的日志功能来检查,在导航上找到“帮助” => “查看运行日志”,这是非常好用的功能,记住这点,各种问题就好解决了。
用法是,先打开日志文件,“Ctrl + End”到文件尾部,然后在HX里面再重新操作,日志就会更新,然后阅读日志内容,便可以找到解决问题的线索。

提前说明一下,我使用的是Win7系统,而且这个问题主要是因为安装这个系统的人选择了比较保守的系统安全策略导致的。

分析

问题1:系统找不到指定的路径

比如我这里是需要安装HX的SVN插件,但是提升“插件SVN下载失败,请检查网络”,而我的网络完全没有问题,那么下载失败很显然不是因为网络问题,日志如下:

2020-06-29 11:34:11.157 [INFO:] Download plugin  "SVN"
2020-06-29 11:34:11.164 [INFO:] C:/Program Files/HBuilderX/plugins/node/node.exe   C:/Program Files/HBuilderX/plugins/npm/node_modules/npm/bin/npm-cli.js install [email protected] --scripts-prepend-node-path=auto --registry http://registry.npm.taobao.org
2020-06-29 11:34:11.165 [INFO:] npminstall_path "C:/Program Files/HBuilderX/update/plugins/hbuilderx-plugin-svn"
2020-06-29 11:34:11.168 [INFO:] plugin [ "hbuilderx-plugin-svn" ] install errorOccurred::: "Process failed to start: \xE7\x9B\xAE\xE5\xBD\x95\xE5\x90\x8D\xE7\xA7\xB0\xE6\x97\xA0\xE6\x95\x88\xE3\x80\x82"
2020-06-29 11:34:11.193 [WARNING:] [http request] the save file  "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp"  cannot open WriteOnly! error: "系统找不到指定的路径。"
2020-06-29 11:34:11.195 [WARNING:] Download plugin  QUrl("http://update.dcloud.net.cn/hbuilderx/alpha/win32/plugins/contents/SVN.1.0.2.2020061217.zip")  faild! , try count:  2
2020-06-29 11:34:11.210 [WARNING:] [http request] the save file  "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp"  cannot open WriteOnly! error: "系统找不到指定的路径。"
2020-06-29 11:34:11.211 [WARNING:] Download plugin  QUrl("http://update.dcloud.net.cn/hbuilderx/alpha/win32/plugins/contents/SVN.1.0.2.2020061217.zip")  faild! , try count:  3
2020-06-29 11:34:11.226 [WARNING:] [http request] the save file  "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp"  cannot open WriteOnly! error: "系统找不到指定的路径。"
2020-06-29 11:34:11.227 [WARNING:] Download plugin  QUrl("http://update.dcloud.net.cn/hbuilderx/alpha/win32/plugins/contents/SVN.1.0.2.2020061217.zip")  faild! , try count:  4
2020-06-29 11:34:11.229 [INFO:] QObject::destroyed state 4
2020-06-29 11:34:11.232 [WARNING:] QLayout: Attempting to add QLayout "" to MsgItemWidget "MsgItem", which already has a layout
2020-06-29 11:47:52.955 [WARNING:] server json is error:  "illegal value"

这里面的关键信息是:[WARNING:] [http request] the save file "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp" cannot open WriteOnly! error: "系统找不到指定的路径。"
意思是“无法打开只读文件,系统找不到指定的路径”。

解决办法

所以需要到HX的安装路径下去看一下: C:/Program Files/HBuilderX/ ,我的安装路径里面确实没有 /update/plugins/ 路径,我们只需要创建就好,其实这里面主要还是系统的权限问题导致HX没有创建成功上面的路径,下文会说明解决办法。

问题2:拒绝访问

然后重新安装,很遗憾还是失败,接着看日志:

2020-06-29 12:14:50.685 [INFO:] Download plugin  "SVN"
2020-06-29 12:14:50.691 [INFO:] C:/Program Files/HBuilderX/plugins/node/node.exe   C:/Program Files/HBuilderX/plugins/npm/node_modules/npm/bin/npm-cli.js install [email protected] --scripts-prepend-node-path=auto --registry http://registry.npm.taobao.org
2020-06-29 12:14:50.692 [INFO:] npminstall_path "C:/Program Files/HBuilderX/update/plugins/hbuilderx-plugin-svn"
2020-06-29 12:14:50.694 [INFO:] plugin [ "hbuilderx-plugin-svn" ] install errorOccurred::: "Process failed to start: \xE7\x9B\xAE\xE5\xBD\x95\xE5\x90\x8D\xE7\xA7\xB0\xE6\x97\xA0\xE6\x95\x88\xE3\x80\x82"
2020-06-29 12:14:50.711 [WARNING:] [http request] the save file  "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp"  cannot open WriteOnly! error: "拒绝访问。"
2020-06-29 12:14:50.712 [WARNING:] Download plugin  QUrl("http://update.dcloud.net.cn/hbuilderx/alpha/win32/plugins/contents/SVN.1.0.2.2020061217.zip")  faild! , try count:  2
2020-06-29 12:14:50.725 [WARNING:] [http request] the save file  "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp"  cannot open WriteOnly! error: "拒绝访问。"
2020-06-29 12:14:50.727 [WARNING:] Download plugin  QUrl("http://update.dcloud.net.cn/hbuilderx/alpha/win32/plugins/contents/SVN.1.0.2.2020061217.zip")  faild! , try count:  3
2020-06-29 12:14:50.740 [WARNING:] [http request] the save file  "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp"  cannot open WriteOnly! error: "拒绝访问。"
2020-06-29 12:14:50.741 [WARNING:] Download plugin  QUrl("http://update.dcloud.net.cn/hbuilderx/alpha/win32/plugins/contents/SVN.1.0.2.2020061217.zip")  faild! , try count:  4
2020-06-29 12:14:50.743 [INFO:] QObject::destroyed state 4
2020-06-29 12:14:50.746 [WARNING:] QLayout: Attempting to add QLayout "" to MsgItemWidget "MsgItem", which already has a layout
2020-06-29 13:55:27.618 [WARNING:] http request:  QUrl("https://ide.dcloud.net.cn/check/advert") , connect to server error, errorCode:  QNetworkReply::NetworkError(HostNotFoundError) , httpCode:  0 , httpReason:  ""
2020-06-29 13:55:27.620 [WARNING:] server json is error:  "illegal value"
2020-06-29 13:55:27.621 [WARNING:] Network connection failed, please check network status and system proxy settings

这次的关键信息是 [WARNING:] [http request] the save file "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp" cannot open WriteOnly! error: "拒绝访问。",还是无法打开只读文件,但是这次后面不同了“拒绝访问”,说明是文件权限的问题。

解决办法

关于文件夹的权限问题,基于win7系统,一般如果右键“update”文件夹,选项里面如果有“管理员取得所有权”,直接点击取得权限即可。
如果右键菜单里面没有“管理员取得所有权选项”,可以按如下方法添加该选项:

  • 用记事本或者其他编辑器创建注册表修改文件,格式后缀为 .reg
  • 复制粘贴下面的内容,然后保存关闭
  • 运行该文件,会有安全提示,一直选择“是”
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\runas]

@="管理员取得所有权"

"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\*\shell\runas\command]

@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\exefile\shell\runas2]

@="管理员取得所有权"

"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\exefile\shell\runas2\command]

@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\Directory\shell\runas]

@="管理员取得所有权"

"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]

@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

问题3:插件SVN安装失败

进行了上面的步骤,如果还是提示安装失败,继续看日志:

2020-06-29 14:14:16.221 [INFO:] Download plugin  "SVN"
2020-06-29 14:14:16.232 [INFO:] C:/Program Files/HBuilderX/plugins/node/node.exe   C:/Program Files/HBuilderX/plugins/npm/node_modules/npm/bin/npm-cli.js install [email protected] --scripts-prepend-node-path=auto --registry http://registry.npm.taobao.org
2020-06-29 14:14:16.235 [INFO:] npminstall_path "C:/Program Files/HBuilderX/update/plugins/hbuilderx-plugin-svn"
2020-06-29 14:14:18.020 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: "npm WARN enoent ENOENT: no such file or directory, open 'C:\\Program Files\\HBuilderX\\update\\plugins\\hbuilderx-plugin-svn\\package.json'"
2020-06-29 14:14:18.022 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: "npm WARN hbuilderx-plugin-svn No description"
2020-06-29 14:14:18.024 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: "npm WARN hbuilderx-plugin-svn No repository field."
2020-06-29 14:14:18.026 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: "npm WARN hbuilderx-plugin-svn No README data"
2020-06-29 14:14:18.028 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: "npm WARN hbuilderx-plugin-svn No license field."
2020-06-29 14:14:18.029 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: ""
2020-06-29 14:14:18.030 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: "npm ERR! code HPE_INVALID_HEADER_TOKEN"
2020-06-29 14:14:18.031 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: "npm ERR! errno HPE_INVALID_HEADER_TOKEN"
2020-06-29 14:14:18.032 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: "npm ERR! request to http://registry.npm.taobao.org/hbuilderx-plugin-svn/download/hbuilderx-plugin-svn-1.0.2-2020061217.tgz failed, reason: Parse Error"
2020-06-29 14:14:18.033 [WARNING:] plugin [ "hbuilderx-plugin-svn" ] install warning::: ""
2020-06-29 14:14:18.770 [INFO:] Unpack plugin  "SVN"
2020-06-29 14:14:18.984 [INFO:] try move  "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp"  to  "C:/Program Files/HBuilderX/plugins/SVN"
2020-06-29 14:14:18.986 [INFO:] move result: false
2020-06-29 14:14:18.989 [INFO:] Plugin  "SVN"  has been installed failed
2020-06-29 14:14:18.990 [INFO:] Plugin  "SVN"  has been installed failed
2020-06-29 14:14:18.994 [WARNING:] QLayout: Attempting to add QLayout "" to MsgItemWidget "MsgItem", which already has a layout
2020-06-29 14:14:19.028 [INFO:] QObject::destroyed state 4

这里面的关键信息是

  • try move "C:/Program Files/HBuilderX/update/plugins/SVN.zip.tmp" to "C:/Program Files/HBuilderX/plugins/SVN"
  • move result: false
解决办法

意思是移动解压的文件失败,其实还是系统权限的问题,需要在运行HX时右键选择“以管理员身份运行”,重新安装,然后就可以了。

结论

Win7下碰到这种问题,主要就是安装系统时选择了非常保守的安全策略导致,用户创建的文件夹全部是只读的,然后程序运行时权限也不能对文件夹做“mov”等操作,这点非常坑,彻底的解决办法就是重装系统。

你可能感兴趣的:(HBuilderX,HBuilderX,插件安装,失败,请检查网络)