感觉 WSL 2 蛮好用的, 汇总一些以前和最近搞过的一些东西和技巧.
以前碰到过这种问题, 似乎是 vscode 连接 WSL2
窗口没关然后频繁地休眠+启动导致的. 之前可以用
wsl --shutdown
来强制关闭, 或者也可以用
wsl -l -v
先查看状态. 今天又碰到这个问题了, 但是 shutdown
之后没有反应, -l -v
也是没有反应,
然后检索了一些其他的解决方案.
解决方案 [2] 没有用.
直接重启也没有用, 重启开机后 Vmmem 仍然在占用 CPU.
后来是在启用或关闭 Windows 功能这一设置中,
找到适用于 Linux 的 Windows 子系统
这一项, 然后把它关闭,
重启即可. 如果还需要继续使用 WSL 2, 就再打开即可.
[1] https://zhuanlan.zhihu.com/p/277825426
[2] https://web.archive.org/web/20220201155338/https://www.cnblogs.com/coding8832/p/14445835.html
执行下面的命令即可:
1 | sudo chown -R username path |
比如:
1 | sudo chown -R xubaoduo /home/xubaoduo/project |
在官网下载运行安装打开后出现下面的情况:
以管理员权限运行cmd后, 输入
1 | path - C:\Windows\system32 |
再打开就解决了.
在WSL2的CLI中输入 docker --veriosn
后提示 1
2
3
4
5
6
7
The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.
For details about using Docker Desktop with WSL 2, visit:
https://docs.docker.com/go/wsl2/
1 | sudo apt update |
微软商店的 Windows Terminal 确实挺好看的.
[1] ChatGPT
[2] StackOverflow
记得每次使用打开 clash 的 Allow LAN
, 打开 get google
的网页尝试:
1 | wget www.google.com |
[1] 参考文章
首先打开 clash, 不然连接 172.31.192.1
会失败.
先安装 Ruby:
1 | sudo apt-get install ruby-full build-essential zlib1g-dev |
再安装 RubyGems 包, 然后避免为 root 安装, 现在当前用户下创建一个
gems
文件夹, 然后用下面的命令配置 gem 安装路径:
1 | echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc |
接下来就可以安装 jekyll 和 bundler 了:
1 | gem install jekyll bundler |
发现很久没动静, 按理说不应该啊. 切换源为清华镜像:
1 | gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/ |
然后再运行 gem install jekyll
,
其实还是尝试了好几次才成功的, maybe 看运气. bundler 是必须的吗?
好像是包管理器, 还是装一下吧.
安装 bundler
的时候发现 ruby 的版本不够新, 升级 ruby,
好吧还需要 RVM:
1 | \curl -sSL https://get.rvm.io | bash -s stable |
运行上述命令遇到了下面的问题:
1 | curl: (22) The requested URL returned error: 403 |
看错误信息是没有公钥, 需要安装 GPG v2, 问 GPT 给的命令是
1 | sudo apt update |
然后就把上面那个
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys <key>
输入就行, 再重新
\curl -sSL https://get.rvm.io | bash -s stable
安装 RVM,
有一个 warning:
1 | gpg: WARNING: This key is not certified with a trusted signature! |
这好像意味着前面不应该新建 gems
文件夹. Anyway, 运行一下
unset GEM_HOME
就行, 反正 GPT 也说这个 warning
只是个小问题. 成功安装后用 rvm --version
来看版本, 输出
1 | rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io] |
接下来升级 ruby, 首先 rvm list known
列出可安装的:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.10]
[ruby-]2.5[.8]
[ruby-]2.6[.6]
[ruby-]2.7[.2]
[ruby-]3[.0.0]
ruby-head
略去剩余内容
找到 ruby 最新版本, 然后 rvm install 3.0.0
(注意输入
rvm install 3
和 rvm install [ruby-]3[.0.0]
都会报错), 最终成功是这个样子的: 1
2Install of ruby-3.0.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-rirvm use 3.0.0 --default
切换为 3.0
:
1
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
gem install bundler
. 大功告成. 哦发现
jekyll -v
没反应, 重新 gem intall jekyll
了一下: 1
jekyll 4.3.4
然后是按照 jekyll 正常的流程搞, 但是碰到了很多问题. 用这个主题搞的, 提前 clone 到博客目录下了, 然后
1 | bundle install |
然后输出下面的报错信息了: 1
2
3
4
5
6
7
8
9
10
11
12Error: Can't find stylesheet to import.
╷
29 │ @import "bootstrap/functions";
│ ^^^^^^^^^^^^^^^^^^^^^
╵
/home/xxx/xxx/jekyll-serif-theme/assets/css/style.scss 29:9 root stylesheet
Conversion error: Jekyll::Converters::Scss encountered an error while converting 'jekyll-serif-theme/assets/css/style.scss':
Can't find stylesheet to import.
------------------------------------------------
Jekyll 4.3.4 Please append --trace to the serve command
for any additional information or backtrace.
------------------------------------------------bootstrap
,
刚开始尝试用 bundle add bootstrap
, 但是没用, 然后用 npm
npm install bootstrap
, 但还是没用. 然后观察了一下文件结构,
发现抱错的文件 /jekyll-serif-theme/assets/css/style.scss
的同级目录出现了 bootstrap:
jekyll-serif-theme/_sass/bootstrap
, 但还是报错没有找到
bootstrap
, 这里就是路径的问题, 根目录下没有 bootstrap,
如果文件内都改成相对路径有点太麻烦了, 于是 copy 了这个文件夹到根目录下
xxx/_sass/bootstrap
, 报错就解决了. 但是主题还是有点问题,
localhost 显示的效果是默认主题 minima 和 serif 这个主题杂糅在一起了,
而且主要显示的还是默认主题.
[1] https://jekyllrb.com/docs/installation/ubuntu/#install-dependencies
[2] https://wilson1202.github.io/posts/install-jekyll-on-wsl2-ubuntu/
[3] https://wilson1202.github.io/posts/install-rvm-ruby-on-ubuntu/
[4] https://blog.csdn.net/Wjhsmart/article/details/85311236
[5] ChatGPT.
1: https://repo.anaconda.com/archive/index.html 找到要安装的版本, 复制链接.
2: 1
wget https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh
3: ;