wsl ubuntu vscode 报无法验证证书

        今天在wsl ubuntu里面运行code. 的时候报下面的错误信息

root@DESKTOP-68F1OMN:/data/tencent/weda# code .
Updating VS Code Server to version 848b80aeb52026648a8ff9f7c45a9b0a80641e2e
Removing previous installation...
Installing VS Code Server for Linux x64 (848b80aeb52026648a8ff9f7c45a9b0a80641e2e)
Downloading: 100%
Failed
--2025-06-01 12:01:53--  https://update.code.visualstudio.com/commit:848b80aeb52026648a8ff9f7c45a9b0a80641e2e/server-linux-x64/stable
Resolving update.code.visualstudio.com (update.code.visualstudio.com)... 13.107.246.50, 2620:1ec:bdf::50
Connecting to update.code.visualstudio.com (update.code.visualstudio.com)|13.107.246.50|:443... connected.
ERROR: cannot verify update.code.visualstudio.com's certificate, issued by ‘CN=Microsoft Azure RSA TLS Issuing CA 08,O=Microsoft Corporation,C=US’:
  Self-signed certificate encountered.
To connect to update.code.visualstudio.com insecurely, use `--no-check-certificate'.
ERROR: Failed to download https://update.code.visualstudio.com/commit:848b80aeb52026648a8ff9f7c45a9b0a80641e2e/server-linux-x64/stable to /root/.vscode-server/bin/848b80aeb52026648a8ff9f7c45a9b0a80641e2e-1748750512.tar.gz
Please install missing certificates.
Debian/Ubuntu:  sudo apt-get install ca-certificates

        由于我的ubuntu无法认证SSL导致下载失败

最后解决方法如下

wget https://update.code.visualstudio.com/commit:848b80aeb52026648a8ff9f7c45a9b0a80641e2e/server-linux-x64/stable -O vscode-server.tar.gz
mkdir -p ~/.vscode-server/bin/848b80aeb52026648a8ff9f7c45a9b0a80641e2e
tar -xzf vscode-server.tar.gz -C ~/.vscode-server/bin/848b80aeb52026648a8ff9f7c45a9b0a80641e2e --strip-components=1

在运行

code .

可以重新使用VS Code了

### 配置和使用 Git 的详细步骤 在 VSCode 中通过 WSL Ubuntu 环境配置和使用 Git,需要确保 WSL 环境中已正确安装 Git,并在 VSCode 中设置适当的配置以支持 Git 操作。以下是详细的说明: #### 1. 安装 Git 首先,在 WSLUbuntu 环境中安装 Git: ```bash sudo apt update sudo apt install git -y ``` 完成安装后,可以通过以下命令验证是否成功安装: ```bash git --version ``` 如果返回 Git 的版本号,则表示安装成功[^1]。 #### 2. 配置 Git 用户信息 为了确保提交的代码具有正确的用户信息,需配置全局用户名和邮箱: ```bash git config --global user.name "Your Name" git config --global user.email "your.email@example.com" ``` 此外,为了防止中文文件名或路径出现乱码问题,可关闭 Git 的编码转换功能: ```bash git config --global core.quotepath false ``` 同时,为支持系统语言(如中文),可以安装语言包并设置 locale: ```bash sudo apt install $(check-language-support) --fix-missing sudo locale-gen zh_CN.UTF-8 export LC_ALL=zh_CN.UTF-8 ``` #### 3. 在 VSCode 中启用 Remote-WSL 插件 安装 VSCode 的 `Remote - WSL` 插件后,可通过以下方式进入 WSL 环境: - 使用快捷键 `Ctrl+Shift+P` 打开命令面板。 - 输入并选择 `Remote-WSL: New Window` 或 `Remote-WSL: Reopen in WSL`。 此时,VSCode 将切换到 WSL 环境,所有终端操作均基于 WSL 的 Bash[^2]。 #### 4. 配置 VSCode 的 Git 设置 在 WSL 环境下,确保 VSCode 使用的是 WSL 中的 Git 而非 Windows 上的 Git。可以通过以下方法检查: - 打开 VSCode 设置(`File > Preferences > Settings`)。 - 搜索 `Git Path`,将其值设置为 `/usr/bin/git`(即 WSL 中的 Git 可执行文件路径)。 #### 5. 初始化 Git 仓库并测试 在 WSL 的项目目录中初始化一个 Git 仓库: ```bash git init ``` 添加文件并提交: ```bash echo "# Test" >> README.md git add README.md git commit -m "Initial commit" ``` 此时,可以在 VSCode 的源代码管理视图中查看提交记录和更改内容。 #### 6. 解决常见问题 - **中文乱码**:如前所述,通过设置 `core.quotepath` 和调整 locale 可解决乱码问题[^1]。 - **权限问题**:确保项目目录具有正确的权限,避免因权限不足导致的操作失败。 ### 示例代码 以下是一个简单的 Python 脚本示例,展示如何结合 Git 使用: ```python # test.py print("Hello, Git!") ``` 保存后,在终端中运行以下命令: ```bash git add test.py git commit -m "Add test script" ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

livepy

老码农,赋闲在家要吃饭

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值