如果您遇到以下錯誤
args: ["c:/WINDOWS/System32/drivers/etc/hosts",1]
format: "inet_parse:~p:~p: erroneous line, SKIPPED~n"
label: {error_logger,info_msg}
inet_parse:"c:/WINDOWS/System32/drivers/etc/hosts":1: erroneous line, SKIPPED
問題描述及解決辦法
你遇到的問題是由於Erlang的inet_parse
函數在解析hosts
文件時遇到了非ASCII編碼的行,從而導致了錯誤。這通常發生在其他應用程序(如Docker)訪問並修改了hosts
文件,將其編碼從ASCII更改爲UTF-8時。雖然這對日常使用通常沒有影響,但Erlang的inet_parse
函數對此並不兼容。
爲了解決這個問題,你需要將hosts
文件的編碼更改回ASCII。這可以通過執行PowerShell命令來實現。請按照以下步驟操作:
-
以管理員身份打開PowerShell窗口:在開始菜單中搜索“PowerShell”,然後右鍵點擊“Windows PowerShell”並選擇“以管理員身份運行”。
-
執行PowerShell命令:在打開的PowerShell窗口中,輸入以下命令並按Enter鍵執行:
Get-Content -Path "C:\Windows\System32\drivers\etc\hosts" | Out-File -FilePath "C:\Windows\System32\drivers\etc\hosts" -Encoding ascii
這應該可以解決上述問題。如果這對您沒有幫助,請確保您的主機文件沒有以任何其他方式損壞。