4
2

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.

VSCode で大きいファイルを開いたら vscode が起動しなくなりはまったので、対処法メモ

Last updated at Posted at 2022-05-04

はじめに

環境:Mackbook air(M1 2020)
バージョン:バージョン: 1.66.2

vscode で大きいファイル(数 GB)を開いて動いていたけど、突然エラーが発生して起動しなくなる現象が発生した時の対処方法です。

要約
大きいファイルは参照のみであれば利用できますが、更新するとエラー終了することがあるようです。参照のみで利用するようにしましょう。

原因調査

以下より、何らかのキャッシュ情報を見ており、そのキャッシュが悪さをしている。
キャッシュクリア方法を探したけど、vscode が起動した状態でのキャッシュクリア方法のみであったため、キャッシュを直接クリアする必要がある。

キャッシュに行き着くまでに調べたこと

  • OS の再起動で改善せず
  • 他のワークスペースでは普通に起動
  • 特定のワークスペース(大容量ファイルを開いたワークスペース)で以下のエラーが発生
    ウィンドウがクラッシュしました (理由: 'crashed'、コード: '5')
  • 元のファイル名をmvで変更して小さいサイズにしても現象は改善せず
  • 拡張機能を起動しないようにして立ち上げたが、現象は改善せず
      code --desable-extensions
  • ログレベルをtraceにして起動するも、めぼしい情報は記録されていない
      code --desable-extensions --log trace

対処方法

暫定的に以下の方法で回避できました。元のファイルは不要になると思いますが念のために退避しておいてください。
※今回は参照のみしていたファイルが対象でしたが、更新は破棄されると思います。
参照のみと思っていましたが、継続調査から何らかの操作で大容量ファイルを更新していたと思われます。
大容量ファイルを更新してキャッシュから復元しようとして起動失敗になったように見えました。

  1. キャッシュを持っている場所
    ~/Library/Application Support/Code/Backups/[ワークスペースのIDっぽいもの]/file/[数値]
  2. ファイルの中身を確認する head ファイル名
  3. ファイルを退避しておく mv ファイル名 dummy.old
  4. ファイルを小さくする echo "dummy" >ファイル名
  5. vscode を起動すると起動できるので、対象のファイルを閉じる(色々誤認識するけど、対象のファイル名のウィンドウを全て閉じる)
  6. vscode を終了して再起動して起動することを確認

補足 動作仕様

調査した範囲の動作仕様を残しておきます。

  • ファイルを更新すると以下に一時ファイルが作成される。
    • ~/Library/Application Support/Code/Backups/[16進]/file
      -[16進の8桁] 2つ目以降は[16進の8桁]となるっぽい
      例:
      ~/Library/Application Support/Code/Backups/111A222B333C444/file/-1a2b34cd
  • vscodeを終了すると16進のフォルダごと消える。ファイルを保存しないまま強制終了すると、残っている(普通に終了すると保存するか聞いてくる)。
  • どのファイルを開いているかは別で持っている模様(今度調べてみようと思います)

VSCode のコマンドラインメモ

今回は役に立たなかったのですが、vscodeのコマンド引数はちょくちょく調べることがあった為、メモとして残しておきます。

Visual Studio Code 1.66.2

Usage: code [options][paths...]

Options

カテゴリ ショート ロング表記オプション 引数 内容 内容(日本語)
Options -d --diff <file> <file> Compare two files with each other. 2 つのファイルを相互に比較します。
-a --add <folder> Add folder(s) to the last active window. 最後のアクティブなウィンドウにフォルダを追加します。
-g --goto <file:line[:character]> Open a file at the path on the specified line and character position. 指定された行と文字位置のパスでファイルを開きます。
-n --new-window Force to open a new window. 新しいウィンドウを強制的に開きます。
-r --reuse-window Force to open a file or folder in an already opened window. すでに開いているウィンドウでファイルまたはフォルダを強制的に開きます。
-w --wait Wait for the files to be closed before returning. ファイルが閉じられるのを待ってから戻ります。
--locale <locale> The locale to use (e.g. en-US or zh-TW). 使用するロケール(例:en-US または zh-TW)。
--user-data-dir <dir> Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code. ユーザーデータが保持されるディレクトリを指定します。コードの複数の個別のインスタンスを開くために使用できます。
-h --help Print usage. 使用法を表示します。
Extensions Management --extensions-dir `   Set the root path for extensions. 拡張機能のルートパスを設定します。
--list-extensions List the installed extensions. インストールされている拡張機能を一覧表示します。
--show-versions Show versions of installed extensions, when using --list-extensions. --list-extensions を使用する場合、インストールされている拡張機能のバージョンを表示します。
--category <category> Filters installed extensions by provided category, when using --list-extensions. --list-extensions を使用する場合、インストールされている拡張機能を提供されたカテゴリでフィルタリングします。
--install-extension <ext-id | path> Installs or updates an extension. The argument is either an extension id or a path to a VSIX. The identifier of an extension is '${publisher}.${name}'. Use '--force' argument to update to latest version. To install a specific version provide '@${version}'. For example: 'vscode.csharp@1.2.3'. 拡張機能をインストールまたは更新します。 引数は、拡張 ID または VSIX へのパスのいずれかです。 拡張機能の識別子は「${publisher}。${name}」です。 '--force'引数を使用して、最新バージョンに更新します。 特定のバージョンをインストールするには、「@${version}」を指定します。 例:'vscode.csharp@1.2.3'。
--pre-release Installs the pre-release version of the extension, when using --install-extension --install-extension を使用する場合、拡張機能のプレリリースバージョンをインストールします
--uninstall-extension ` Uninstalls an extension. 拡張機能をアンインストールします。
--enable-proposed-api <ext-id> Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually. 拡張機能の提案された API 機能を有効にします。 1 つ以上の拡張 ID を受信して ​​、個別に有効にすることができます。
Troubleshooting -v --version Print version. バージョンを表示。
--verbose Print verbose output (implies --wait). 詳細出力を出力します(--wait を意味します)。
--log <level> Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'. 使用するログレベル。デフォルトは「info」です。許可される値は、 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.
-s --status Print process usage and diagnostics information. プロセスの使用状況と診断情報を出力します。
--prof-startup Run CPU profiler during startup. 起動時に CPU プロファイラーを実行します。
--disable-extensions Disable all installed extensions. インストールされているすべての拡張機能を無効にします。
--disable-extension <ext-id> Disable an extension. 拡張機能を無効にします。
--sync <on | off> Turn sync on or off. 同期をオンまたはオフにします。
--inspect-extensions <port> Allow debugging and profiling of extensions. Check the developer tools for the connection URI. 拡張機能のデバッグとプロファイリングを許可します。開発者ツールで接続 URI を確認してください。
--inspect-brk-extensions <port> Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI. 起動後に拡張機能ホストを一時停止して、拡張機能のデバッグとプロファイリングを許可します。 開発者ツールで接続 URI を確認してください。
--disable-gpu Disable GPU hardware acceleration. ハードウェアアクセラレーションを無効にします。
--max-memory <memory> Max memory size for a window (in Mbytes). ウィンドウの最大メモリサイズ(MB 単位)。
--telemetry Shows all telemetry events which VS code collects. VSCode が収集するすべてのテレメトリイベントを表示します。
4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?