0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Electron Build Tools でバイナリビルドしようとして goma_ctl.py で文字コードエラーが出る場合の解決法

Last updated at Posted at 2022-06-18

Windows の日本語環境で Electron のバイナリ本体を Electron Build Tools でビルドしようとしたら、goma_ctl.py で以下のようなエラーが出た。

Traceback (most recent call last):
(省略)
  File "~\.electron_build_tools\third_party\goma\goma_ctl.py", line 133, in _DecodeBytesOnPython3
    return data.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8f in position 0: invalid start byte

解決法

エラーが出た goma_ctl.py の _DecodeBytesOnPython3 関数内にある行を以下のように書き換える。

goma_ctl.py
def _DecodeBytesOnPython3(data):
  """This function decodes bytes type on python3."""
  if isinstance(data, bytes) and sys.version_info.major == 3:
-   return data.decode('utf-8')
+   return data.decode('shift-jis')
  return data

今回のエラーの発端であるバイト 0x8f は SJIS では有効なものなので、Windows のマルチバイト文字が SJIS 設定になっているのが今回の原因だと推測。Windows の設定で UTF-8 を使用するように変更しても解決しそう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?