ろきメモ【ROKI MEMO】- ろきsanの備忘録 -

ろきさんの備忘録。プログラミング学習記録や開発記録、および学んだ知識等のアウトプットとシェアを目的に書いています。たまに普通のことも書きます。

【解決(と思う)】Windowsで突然VSCodeが起動しなくなったときの対処

スポンサーリンク

ある日Windowsにて、VSCodeが起動しなくなった。
エラーが出るわけでもなく、アプリをダブルクリックしても何の反応もない。
アンイストールしてはいない、アプリは存在する。
元にプログラム一覧にあるし、Windowsのスタートメニューにもある。

同じ現象が起きている人がいないかとググる
「Windows10 VSCode 起動しない」とか。

出てきた結果はざっくり、
「ネットワークが切れているから、オフラインで起動する方法は・・・」とか、
「アップデートのときなんか失敗したのかも、一度アンイストールして再インストールだな」など。

なるほど。
ネットワークはバリ3(古い)なので、「オフラインどうのこうの」は違う。
「アップデートのとき失敗」はあり得る。ソフトウェアなんて完璧は存在しないから。

しかし、再インストールはできるだけ避けたい。
いろいろ拡張パッケージ入れたし、キーバインドとか設定もしたから、またいろいろやるのはめんどくさい。
(まぁ、キーバインド(keybindings.json)とか設定(settings.json)のファイルはバックアップしておけばコピペでいけるんだけどね)

(例)
kiybindings.jsonの場所
C:\UserArea\(user)\AppData\Roaming\Code\User

settings.jsonの場所
C:\UserArea\(user)\AppData\Local\Programs\Microsoft VS Code

ということでちょっと他の方法を探ってみる。その備忘録。


目次

スポンサーリンク



1. VSCodeをターミナル(コマンドプロンプト)で起動してみる

ウィンドウ上ではエラーメッセージなど出てこないが、ターミナル上では何かしらエラーを吐いているかもしれない。少なくともどこで止まっているかは確認できかも。

VSCodeの実行ファイルはどこにある?
起動するショートカットアイコンなどを右クリック > プロパティ を開けば、「場所」に書いてある。ぼくの場合は、

D:\UserArea\(user)\AppData\Local\Programs\Microsoft VS Code\Code.exe

とあるので、これが実行ファイル本体。
なので、この場所でコマンドプロンプトを起動する(もしくはこの場所まで移動する)。

開く方法(参考)
ahrk-izo.hatenablog.com


この場所でコマンドプロンプトを起動したら、Code.exeを起動してみる。

D:\UserArea\(user)\AppData\Local\Programs\Microsoft VS Code>Code.exe
D:\UserArea\(user)\AppData\Local\Programs\Microsoft VS Code>

 [15216:0421/104958.513:FATAL:v8_initializer.cc(176)] 
Failed to open V8 file 'D:\UserArea\(user)\AppData\Local\Programs\Microsoft VS Code\natives_blob.bin' (reason: -4)

ほう。なるほど?
natives_blob.binってファイルを開こうとして、失敗してるっぽい。
フォルダを見るとそんなファイルない。やっぱりアップデートときなんか失敗してるな。
とりあえず原因がわかったので、ちょっと前進した。


2. 「natives_blob.bin」でググる

ググると言っても、日本語でググっても冒頭にある通りかもしれないので、英語でググってみる。
vscode native_blob.bin」で検索。
トップに
Failed to open V8 file \natives_blob.bin · Issue #82382 · microsoft/vscode · GitHub
が出てきた。内容を見ると、状況は全く同じっぽい。
結論を言うと、この中のこの コメント の通りにやったらできた。

要は、

  • Code.exeがあるフォルダの中に「_」というフォルダがある。
  • その中にファイルを、上のフォルダ(Code.exeがあるフォルダ)に移動する(おそらくこれがアップデートのとき移動しきれなかったのかな?)

でOK。


3. 「_」の中身を、上のフォルダ(Code.exeがあるフォルダ)に移動する

Code.exeがあるフォルダの中に「_」というフォルダの中に、「_」フォルダを確認。
f:id:ahrk-izo:20200425104259p:plain:w400

その中身を確認。
f:id:ahrk-izo:20200425104416p:plain:w400
この中に、natives_blob.binのファイルもあるね。やはり。

上のフォルダ(Code.exeがあるフォルダ)に移動する。
f:id:ahrk-izo:20200425104533p:plain:w400

これでOKだな。

スポンサーリンク



4. VSCodeを起動してみる。

まずはターミナル(コマンドプロンプト)でやってみる。

D:\UserArea\(user)\AppData\Local\Programs\Microsoft VS Code>Code.exe
D:\UserArea\(user)\AppData\Local\Programs\Microsoft VS Code>

 [main 2020-04-21T02:18:34.833Z] update#setState idle

(node:9096) Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information

(node:9096) Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information

(node:1720) Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information

(node:1720) Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information

(node:1720) Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information

(node:1720) Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information

(node:1720) Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information

(node:1720) Electron: Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information

[main 2020-04-21T02:19:04.896Z] update#setState checking for updates

[main 2020-04-21T02:19:06.733Z] update#setState idle

起動できた!


もちろん、アプリのアイコンからも!


これが正しいやり方かはわからないが、無事起動して、問題なく起動している。
まぁ本当に何か不具合起きたら再インストールすればいいさ。


とにかく、ターミナルで起動してみて、エラーやどこで止まっているかを確認してみるのは大事だね。


以上。