赛博疑难杂症药方

views
Word count: 435 (~2 mins to read) Last updated:
  • git add . 仍有文件无法加入

    • 可能是submodule导致,即使删除子模块的.git文件夹也不足够,还需要git rm --cached
  • 电脑怎样都没有声音,声卡等硬件均无问题,驱动没有更改过

    • 检查是否是Windows更新导致,可以回滚
  • 远程桌面出现奇奇怪怪的渲染问题

    • 可能是由于远程设备没有连接屏幕,需要保持屏幕开启;或者使用虚拟显示器(Virtual display)
  • WSL2 手动设置 NAT 模式下的网络适配器,给 WSL2 分配静态 IP:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    netsh winsock reset
    wsl -d Ubuntu -u root ip addr del $(ip addr show eth0 ^| grep 'inet\b' ^| awk '{print $2}' ^| head -n 1) dev eth0
    wsl -d Ubuntu -u root ip addr add 192.168.50.2/24 broadcast 192.168.50.255 dev eth0
    wsl -d Ubuntu -u root ip route add 0.0.0.0/0 via 192.168.50.1 dev eth0
    wsl -d Ubuntu -u root echo nameserver 192.168.50.1^> /etc/resolv.conf
    wsl -d Ubuntu -u root echo nameserver 8.8.8.8^>^> /etc/resolv.conf
    wsl -d Ubuntu -u root echo nameserver 10.0.0.21^>^> /etc/resolv.conf
    wsl -d Ubuntu -u root echo nameserver 114.114.114.114^>^> /etc/resolv.conf
    powershell -c "Get-NetAdapter -IncludeHidden 'vEthernet (WSL)' | Get-NetIPAddress | Remove-NetIPAddress -Confirm:$False; New-NetIPAddress -IPAddress 192.168.50.1 -PrefixLength 24 -InterfaceAlias 'vEthernet (WSL)'; Get-NetNat | ? Name -Eq WSLNat | Remove-NetNat -Confirm:$False; New-NetNat -Name WSLNat -InternalIPInterfaceAddressPrefix 192.168.50.0/24;"
    • 每次开机启动都需要在管理员权限下运行(需要 UAC)
    • 其中对于 WSL2 内部来说,宿主的地址:192.168.50.1
    • 对宿主机来说,WSL2 的地址:192.168.50.2
  • 在 WSL2 中,.wslconfignetworkingMode=nat 时通过代理使用 Gradle 的正确姿势:

    • ./gradlew -Dhttp.proxyHost=192.168.50.1 -Dhttp.proxyPort=7777 -Dhttps.proxyHost=192.168.50.1 -Dhttps.proxyPort=7777 "-Dhttp.nonProxyHosts=*.nonproxyrepos.com|localhost"
    • 有时需要重启一下 daemon: gradle --stop