学习AI(三):安装openClaw、WSL、配置git github

今天在Windows 11(家庭版)上安装openClaw, 遇到一些问题,简单记录。

安装wsl

旧版 Docker 使用 Hyper-V 虚拟机,但效率较低且资源占用高。新版 Docker Desktop 默认使用 WSL 2 作为后端, WSL 2 提供了一个轻量级、高性能的 Linux 内核环境,Docker 依赖这个环境来运行容器。所以安装Docker Desktop时,自带安装了WSL, WSL 2 (Windows Subsystem for Linux 2):这是基础架构,是一个兼容层,让 Windows 能运行 Linux 内核。Ubuntu:这是一个运行在 WSL 2 之上的 Linux 发行版(操作系统),你只需要 WSL 2 就能运行它。

如果你的系统还没有WSL 2,可以这样安装:

  1. 以管理员身份打开PowerShell
  2. 运行:
wsl --install

安装ubuntu

D:\code\openclaw>wsl --install
正在下载: Ubuntu
正在安装: Ubuntu
已成功安装分发。可以通过 “wsl.exe -d Ubuntu” 启动它
正在启动 Ubuntu…
Provisioning the new WSL instance Ubuntu
This might take a while…
Create a default Unix user account: weejar
New password:weejar123
Retype new password:weejar123
passwd: password updated successfully
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

启动ubuntu

D:\code\openclaw>wsl -l -v
  NAME              STATE           VERSION
* docker-desktop    Running         2
  Ubuntu            Stopped         2

D:\code\openclaw>wsl -d ubuntu

C:\Users\weejar>wsl --list --verbose
  NAME              STATE           VERSION
* docker-desktop    Running         2
  Ubuntu            Running         2

下载 CLI,通过 npm 全局安装,并启动设置向导。

$ curl -fsSL https://openclaw.ai/install.sh | bash

  🦞 OpenClaw Installer
  Because texting yourself reminders is so 2024.

✓ Detected: linux
→ Detected a OpenClaw source checkout in: /mnt/d/code/openclaw
Choose install method:
  1) Update this checkout (git) and use it
  2) Install global via npm (migrate away from git)
Enter 1 or 2:
2

Install plan
OS: linux
Install method: npm
Requested version: latest
Detected checkout: /mnt/d/code/openclaw

[1/3] Preparing environment
· Node.js v18.19.1 found, upgrading to v22+
· Installing Node.js via NodeSource
· Installing Linux build tools (make/g++/cmake/python3)
✓ Build tools installed



✓ Node.js v22 installed
· Active Node.js: v22.22.1 (/usr/bin/node)
· Active npm: 10.9.4 (/usr/bin/npm)

[2/3] Installing OpenClaw
✓ Git already installed
· Configuring npm for user-local installs
✓ npm configured for user installs
· Installing OpenClaw v2026.3.13
✓ OpenClaw npm package installed
✓ OpenClaw installed

[3/3] Finalizing setup

! PATH missing npm global bin dir: /home/weejar/.npm-global/bin
  This can make openclaw show as "command not found" in new terminals.
  Fix (zsh: ~/.zshrc, bash: ~/.bashrc):
    export PATH="/home/weejar/.npm-global/bin:$PATH"

🦞 OpenClaw installed successfully (OpenClaw 2026.3.13 (61d171a))!
Home sweet home. Don't worry, I won't rearrange the furniture.

· Starting setup


🦞 OpenClaw 2026.3.13 (61d171a) — Hot reload for config, cold sweat for deploys.

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██
██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██
██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
                  🦞 OPENCLAW 🦞

┌  OpenClaw onboarding
...

Note: 后面的配置省略. 参考第一篇

OpenClaw WEB控制台登录方式http://127.0.0.1:18789/

后面可能需要自己创建一些agent skill, 也可以从github上下载, 先安装git. 在clone时报错。

wsl中git 代码仓库

D:\code>wsl -d ubuntu
wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。
weejar@dbaor:/mnt/d/code$ 

weejar@dbaor:/mnt/d/code$ git clone https://github.com/xxxxxx/db-ops-skills.git
Cloning into 'db-ops-skills'...
Username for 'https://github.com': weejar@gmail.com
Password for 'https://weejar%40gmail.com@github.com':
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/xxxx/db-ops-skills.git/'

原因是因为github已经几年前禁用了用户密码的方式,需要把密码替换为令牌(在github网站创建,有有效期).

解决方法

创建个人访问令牌(最简单)

你需要从你的 Git 提供商处生成一个令牌,并在终端提示你输入密码时,使用该令牌代替你的密码。

如果你使用的是 GitHub:

  1. 访问 GitHub 并登录。
  2. 点击右上角的个人头像,然后选择 Settings (设置)
  3. 向下滚动左侧边栏,点击最底部的 Developer settings (开发者设置)
  4. 点击 Personal access tokens (个人访问令牌),然后选择 Tokens (classic) (经典令牌)
  5. 点击 Generate new token (生成新令牌) 按钮(选择 classic)。
  6. 认证会发邮件一个认证码,
  7. 在 创建时 填写用途(例如:“我的电脑 Git”)。
  8. Scopes (范围) 下,勾选 repo 旁边的复选框(这赋予它访问你代码仓库的权限)。
  9. 向下滚动并点击 Generate token (生成令牌)
  10. 立即复制该令牌。(因为你之后将无法再次查看它)。
weejar@dbaor:/mnt/d/code$ git clone https://github.com/xxxx/db-ops-skills.git
Cloning into 'db-ops-skills'...
Username for 'https://github.com': weejar
Password for 'https://weejar@github.com':  --- 这里复制github上创建的一段令牌码
remote: Enumerating objects: 79, done.
remote: Counting objects: 100% (79/79), done.
remote: Compressing objects: 100% (52/52), done.
remote: Total 79 (delta 4), reused 79 (delta 4), pack-reused 0 (from 0)
Receiving objects: 100% (79/79), 116.91 KiB | 76.00 KiB/s, done.
Resolving deltas: 100% (4/4), done.

— 持续更新

Leave a Comment