Visual Studio Code をcode
コマンドから実行可能にするとPATH
にVisual Studio Codeの空白スペースが含まれてしまうことが原因でこのエラーが発生する。
具体的にはVisual Studio Ccode のPATHが以下のように登録されてしまっている。
PATH = PATH:/Applications/Applications/Visual Studio Code.app/Contents/Resources/app/bin
自分が遭遇したエラーは、環境変数を参照する make コマンドで
make test
env: Studio: No such file or directory
というエラーが出てくるようになり、make task が実行できなくなってしまった。
原因として自分の場合は、brew でVSCodeをインストールしなおしたら、このエラーが出てくるようになった。
対処方法
公式ページに書いてあるとおりの方式1でパスを通せば解決する。 具体的に解説すると
- VS Codeを起動
- コマンドパレット(Cmd+Shift+P)を開いて、
shell command
と打ち込み、Shell Command: Install 'code' command in PATH
を選択して実行
でこのエラーが出てこなくなる。
もしくは、ダブルクォーテーションでPATH
を登録すればこの問題は回避可能
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
Launching from the command line
You can also run VS Code from the terminal by typing ‘code’ after adding it to the path:
- Launch VS Code.
- Open the Command Palette (Cmd+Shift+P) and type ‘shell command’ to find the Shell Command: Install ‘code’ command in PATH command.