升级 VirtualBox 后 Vagrant 无法启动

最新发布的 Vagrant v2.4.2 已经支持 VirtualBox 7.1 了。

近期将本地安装的 VirtualBox 升级到 7.1 版本,昨天启动开发环境时时发现 Vagrant 2.4.1 不支持 VirtualBox 7.1,错误提示如下:

The provider 'virtualbox' that was requested to back the machine
'xxxxyyyyyzzzz' is reporting that it isn't usable on this system. The
reason is shown below:

Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:

4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0

A Vagrant update may also be available that adds support for the version
you specified. Please check www.vagrantup.com/downloads.html to download
the latest version.

看起来 Vagrant 2.4.1 最高支持到 7.0 版本的 VirtualBox。如果要等 Vagrant 更新版本还不知道要到猴年马月,将 VirtualBox 退回到 7.0 版本也怕把开发环境弄坏。好在只要稍稍动一下手脚就能让 Vagrant 支持 VirtualBox 7.1 了。

……

Windows 下 Neovim 的 nvim.treesitter 插件无法加载 yaml 模块

Neovim 的插件 nvim.treesitter 无法加载 yaml 模块,错误消息为:Failed to load parser for language ‘yaml’: uv_dlopen: The specified procedure could not be found. 可以按照本文提供的方案解决该错误

Vagrant SSH 登录要求密码

故障现象

日常操作系统是 Windows ,通常使用 Vagrant 来搭建本地开发环境。在某次重装系统后,像往常一样用 vagrant up --provision 命令成功地创建了开发环境,接下来用 vagrant ssh 登录系统时,竟然提示要求输入密码:

[email protected]'s password:

这是之前从未遇到过的问题。虽然可以用默认密码 vagrant 登录系统,但是总觉得不爽。一定要找到原因。

排查原因

vagrant ssh --debug 命令输出调试信息:

DEBUG safe_exec: Converted - Command: `"C:\\Windows\\System32\\OpenSSH\\/ssh.EXE"` Args: `["[email protected]", "-p", "2222", "-o", "LogLevel=FATAL", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-o", "PubkeyAcceptedKeyTypes=+ssh-rsa", "-o", "HostKeyAlgorithms=+ssh-rsa", "-i", "D:/myproject/devenv/.vagrant/machines/myproject/virtualbox/private_key", "-o", "ForwardAgent=yes"]`
[email protected]'s password:

发现 ssh 命令确实有使用 private_key 文件来进行验证身份。但是不知道为什么失败了,转而要求输入密码。

……

asyncio.DatagramProtocol 收到错误后停止响应

Python 官方文档提供了一个使用 asyncio 创建 UDP Echo Server 的示例,代码如下:

……

特殊的服务器环境引发的 Laravel 框架异常

一个使用 Laravel 框架的项目,在某次更新生产环境代码后报了奇怪的错误。而代码在开发环境和测试环境运行都是正常的。由于无法接触到生产环境,只能通过 PHP 引擎的源代码来猜测导致错误的原因

解决 curl 无法获取本地发行者证书问题

问题

当使用 curl 命令打开 HTTPS 网站,比如:

shellcurl -sSL https://www.github.com/

显示如下错误:

curl: (60) SSL certificate problem: unable to get local issuer certificate

根据错误信息可以得知,问题是 curl 找不到本地的 CA 证书所导致。

解决方案

首先,下载 CA 证书:https://curl.se/ca/cacert.pem

  1. 不验证 TSL 证书:
    • liburl:curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    • 命令行:添加参数 -k--insecure
  2. 指定 CA 证书:
    • liburl:curl_easy_setopt(curl, CURLOPT_CAINFO, cacert);
    • 命令行:添加参数 --cacert /path/to/cacert.pem
  3. 使用环境变量(仅命令行):set CURL_CA_BUNDLE=/path/to/cacert.pem
  4. 对于 Windows 下的 curl 命令,将 cacert.pem 重命名为 curl-ca-bundle.crt,并保存到以下路径之一:
    1. curl.exe 命令所在路径;
    2. 当前工作路径;
    3. Windows 系统路径(C:\Windows\system32);
    4. Windows 路径(C:\Windows);
    5. 任意 %PATH% 路径。
OpenSSH for Windows 错误提示:“Could not create directory '/home/username/.ssh'.”

使用 OpenSSH for Windows 的 ssh 命令时,会提示“Could not create directory ‘/home/username/.ssh’.”。因为 Windows 和 Linux 文件系统不同,所以不存在 /home 的路径。

按照网上提供的方法,修改注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/home 分支下(64位系统应为 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cygnus Solutions\Cygwin\mounts v2\/home)的"native"键值为 C:\Users。然而这并没有什么卵用。

……