首页 > 解决方案 > 当我得到`./MacOS/Electron: No such file or directory`时,如何从终端启动VS Code?

问题描述

当我code在终端中运行时,出现以下错误:

$ code .                                                                                                                                           

/Users/manuphatak/.pyenv/shims/python: line 21: /usr/local/Cellar/pyenv/1.2.21/libexec/pyenv: No such file or directory
/usr/local/bin/code: line 10: ./MacOS/Electron: No such file or directory

这里有一个相关的问题:https ://github.com/microsoft/vscode/issues/89037 。

对于问题中的用户,问题神奇地自行解决了,但我该如何解决呢?

我可以直接通过应用程序打开 VS Code。我试过重新安装code命令。

诊断

$ cat "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"                                                                         

#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

function realpath() { python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; }
CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?
$ cat /Users/manuphatak/.pyenv/shims/python                                                                                                          

#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x

program="${0##*/}"
if [[ "$program" = "python"* ]]; then
  for arg; do
    case "$arg" in
    -c* | -- ) break ;;
    */* )
      if [ -f "$arg" ]; then
        export PYENV_FILE_ARG="$arg"
        break
      fi
      ;;
    esac
  done
fi

export PYENV_ROOT="/Users/manuphatak/.pyenv"
exec "/usr/local/Cellar/pyenv/1.2.21/libexec/pyenv" exec "$program" "$@"
$ cat /usr/local/Cellar/pyenv/1.2.21/libexec/pyenv

cat: /usr/local/Cellar/pyenv/1.2.21/libexec/pyenv: No such file or directory
$ pyenv --version

pyenv 1.2.22

标签: bashvisual-studio-code

解决方案


pyenv已更新并指向不再存在的可执行文件。

这可以通过使用解决

pyenv rehash

推荐阅读