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”等操作,這點非常坑,徹底的解決辦法就是重裝系統。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章