首页 > 解决方案 > 由于缺少 perl 模块,在 Windows 10 上使用 LaTeX Workshop 在 VSCode 上格式化文档时出错

问题描述

我在 Visual Studio Code 和 MikTex 的最新版本和 ActivePerl 上安装了最新版本的 LaTeX Workshop:

This is perl 5, version 28, subversion 1 (v5.28.1) built for MSWin32-x64-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2018, Larry Wall
Binary build 0000 [25391a6d] provided by ActiveState http://www.ActiveState.com
Built Oct 28 2020 18:24:51

在 Windows 10 Pro 20H2 机器上。我也有一个 IEEE 科学文档项目,它可以正确构建,但是当我尝试格式化文档时,我得到了这个错误:`

[13:58:18] Start formatting with latexindent.
[13:58:18] Formatting with command latexindent -c,c:/Users/user/Desktop/path/,c:/Users/user/Desktop/path/__latexindent_temp.tex,-y=defaultIndent: '    ' 
[13:58:18] Formatting failed with exit code 2
[13:58:18] stderr: Can't locate YAML/Tiny.pm in u/INC
   (you may need to install the YAML::Tiny module)
   (@INC contains: C:/Users/user/AppData/Local/Programs/MiKTeX/scripts/latexindent C:/Perl64/site/lib C:/Perl64/lib)
   at C:/Users/user/AppData/Local/Programs/MiKTeX/scripts/latexindent/LatexIndent/GetYamlSettings.pm line 20.

(为了便于阅读,添加了换行符。)

我搜索了有关如何安装缺少的 YAML::Tiny 模块的说明,但没有成功。我见过一个名为 ppm 的工具,但它似乎不再可用,我该如何安装这个和其他缺少的包?十分感谢。

标签: perlvisual-studio-codemodulewindows-10latex

解决方案


如果您使用的是 ActiveState 平台,您可以简单地:

    state install yaml-tiny

如果您不使用它,您可以通过在 CMD 提示符下运行以下命令,从 ActiveState 平台在 Windows 上安装最新版本的 Perl 5.32:

    powershell -Command "& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://platform.activestate.com/dl/cli/install.ps1'))) -activate-default ActiveState/Perl-5.32"

然后你可以为你需要的每个包运行以下命令(状态工具就像 PPM 一样工作):

    state install <packagename>

或者

    state import <CPANfile/Meta.json>

推荐阅读