我已经在装有Ubuntu 16.04 LTS的笔记本电脑上安装了VS Code。我尝试了多种安装方法,但结果却完全相同。最近,我在这里遵循了Cactux的“新”说明。我尝试过两种方法打开应用程序,均无效。
- 当我从“应用程序”中打开程序时,该图标在启动器中显示约15秒钟,然后消失。没有错误弹出。
- 当我打开终端并键入时
code
,该命令不执行任何操作,并且在不到一秒钟的时间内出现了新提示。
由于我是Linux的新手,所以我一直在尝试什么。
which code
yields /usr/bin/code
,这是一个bash脚本。这是我超越深度的地方。
脚本内容
/usr/bin$ cat 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.
# If root, ensure that --user-data-dir or --file-write is specified
if [ "$(id -u)" = "0" ]; then
for i in $@
do
if [[ $i == --user-data-dir || $i == --user-data-dir=* || $i == --file-write ]]; then
CAN_LAUNCH_AS_ROOT=1
fi
done
if [ -z $CAN_LAUNCH_AS_ROOT ]; then
echo "You are trying to start vscode as a super user which is not recommended. If you really want to, you must specify an alternate user data directory using the --user-data-dir argument." 1>&2
exit 1
fi
fi
if [ ! -L $0 ]; then
# if path is not a symlink, find relatively
VSCODE_PATH="$(dirname $0)/.."
else
if which readlink >/dev/null; then
# if readlink exists, follow the symlink and find relatively
VSCODE_PATH="$(dirname $(readlink -f $0))/.."
else
# else use the standard install location
VSCODE_PATH="/usr/share/code"
fi
fi
ELECTRON="$VSCODE_PATH/code"
CLI="$VSCODE_PATH/resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?
调试输出(来自不同目录)
~$ bash -x code
++ id -u
+ '[' 1000 = 0 ']'
+ '[' '!' -L code ']'
++ dirname code
+ VSCODE_PATH=./..
+ ELECTRON=./../code
+ CLI=./../resources/app/out/cli.js
+ ELECTRON_RUN_AS_NODE=1
+ ./../code ./../resources/app/out/cli.js
/usr/bin/code: line 35: ./../code: No such file or directory
+ exit 127
/usr/bin$ bash -x code
++ id -u
+ '[' 1000 = 0 ']'
+ '[' '!' -L code ']'
+ which readlink
+++ readlink -f code
++ dirname /usr/share/code/bin/code
+ VSCODE_PATH=/usr/share/code/bin/..
+ ELECTRON=/usr/share/code/bin/../code
+ CLI=/usr/share/code/bin/../resources/app/out/cli.js
+ ELECTRON_RUN_AS_NODE=1
+ /usr/share/code/bin/../code /usr/share/code/bin/../resources/app/out/cli.js
+ exit 0
PATH的内容
~$ $PATH
bash: /home/adam/anaconda3/bin:/home/adam/anaconda3/bin:/home/adam/bin:/home/adam/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory
任何帮助或建议,表示赞赏。
sudo apt update
2)sudo apt upgrade
。如果遇到任何错误,请解决错误。然后尝试从终端运行apt并检查错误。