记录 macOS/ubuntu 环境下常见工具问题的解决方案和 bug 修复

🛠️ Convert Zotero Citations to Superscript in Word

❶ The Problem

When using the Zotero plugin in Word to insert citations, they appear as regular-sized text like [1]. However, I wanted to convert them to superscript format.

❷ The Solution

Operation Screenshots
Find and Replace Window
Find and Replace Window
Replace Font Window
Replace Font Window
  1. Open Find & Replace with Ctrl + H, check “use wildcards” in the replace options, and use one of these search patterns:
  1. \[[0-9]{1,3}\] (matches only citations with single numbers) or
  2. \[[0-9][0-9 ,–-]*\], which matches all these citation formats:
    [12]
    [33,37,38,38–43]
    [44–46]
    [22,26,34,47–57]
    [44,45,72]
    [50,75,79,80,83,84]
    [33, 37, 38, 38–43]
    [50, 75, 79, 80, 83, 84]
    
  1. Replace with ^& (which keeps the original content), select Font in the format options, then check Superscript in the font window.

  2. Just hit “Replace All” and you’re done! All your citations will now appear as superscript.

⭕️ “Zotero experienced an error updating your document” on Mac Word Plugin

❶ The Problem

自从电脑换成 MBP 后,使用 Zotero Word 插件在 Word 里面 Add/Edit Citation 时,经常出现 “Zotero experienced an error updating your document” 的错误。如下图所示。

Zotero Word Plugin Error message
Zotero Word Plugin Error message

我先后尝试过

  • 更新:把 Word 和 Zotero 都更新到最新版本
  • 重启:包括但不仅限于多次重启 Zotero、重启 Word、甚至于重启电脑。

但都是治标不治本,最多只能在更新、重启的当下成功 Add/Edit Citation 若干次,后面过了一会儿又会报一样的错误。

❷ The Solution

在穷途末路之际,我在 Zotero Forum 发现了这个帖子,其中 adomasven 的回复让我仿佛看到了一线生机。

adomasven November 29, 2024

Do you use any security software that interacts with your clipboard, like stores its history (e.g. TextExpander, LaunchBar)? Have you tried restarting your Mac?

在按照他说的方法 Force quit 了一直在用的 Paste.app 后,又尝试了几次 Add/Edit Citation,到目前为止都没有再出现过这个错误了。

❸ Root Cause Analysis

从他的思路出发,分析了一下这个 Post 里给出的错误日志:

首先,Zotero 插入引用的过程是

  1. 插件通过后台通信让 Zotero 准备好引用内容;
  2. Zotero 把引用的文本(或编码)写入剪贴板;
  3. 插件控制 Word 把剪贴板内容插入到指定位置。因此,如果 Zotero 无法把内容写入剪贴板(比如 data 是 nil),整个插入过程就会失败,出现错误。

其次,下面这句错误日志的意思是,Zotero 试图通过 NSPasteboardItem 向系统剪贴板写入一段文本(类型是 public.utf8-plain-text),但传入的 data 是 nil,即空值,所以系统报错了,在 setText:field.m:395 的位置。然后这个错误一路往上传播,最终在 Zotero 插件中抛出 “Zotero experienced an error updating your document”。

Error: Calling -setData:forType: on NSPasteboardItem with nil `data` for type public.utf8-plain-text. @[setText:field.m:395]

所以,可以看出关键错误出现在 NSPasteboardItem 上(这是 macOS 上用于剪贴板读写的对象)。错误信息显示的是 data 为 nil,而 Zotero 理应不会主动传入一个空数据。所以,可能的原因就是:有些剪贴板管理软件拦截或干扰了 clipboard 的读写,例如我在使用的 Paste.app.

希望这是最后一次遇到这个问题🥳。不过下一次遇到也知道该怎么排查了,先想办法拿到错误日志,然后从日志入手分析~

🛠️ Use markdown & live preview with bibtex citation on VSCode

❶ Setting up

  • Ensure Pandoc is installed on Mac. It’s required for handling Markdown with citations.
  • Install the following VS Code extensions:
    • Pandoc Citer – Enables auto-completion for citations from bibliography.bib.
    • Pandoc Markdown – Provides a live preview.

❷ Configuration

  • Use the default YAML configuration for the Pandoc Markdown extension.

  • Modify the ’extra Pandoc arguments’ setting for the Pandoc Markdown extension: --citeproc

Pandoc markdown setting
Pandoc markdown setting

❸ Running the Live Preview

Execute “Pandoc Markdown: Open Preview” in VS Code. Then the live preview renders Markdown with properly formatted citations and updates as you edit.

Run the preview command
Run the preview command

⚠️ Note that Pandoc currently does not support CLS-M (see: 为何英文文献会显示中文“等”、“卷”而不是“et al.”, “vol.”?). A cumbersome workaround can be found here.

⭕️ Location Enabled on Mac, but Shortcuts Can’t Find Location

This comment works for me:

Sometimes I can fix the issue by going into WIFI>Details>TCP/IP>Renew DHCP Lease> Apply. Or a reboot of the mac will fix it. Don’t know the cause . Very annoying

⭕️ Proxyman Internal Error 999

  1. Toggle off any other proxy app (CRUCIAL!)
  2. Configure Proxyman settings: Advanced Proxy Settings > External Proxy Settings > Enable Web Proxy (HTTP) > Set it to the system proxy address, e.g., 127.0.0.1:7890

⭕️ VSCode Latex Workshop build error: “spawn latexmk ENOENT”, “LaTeX build process spawned with PID undefined”

First, verify latexmk path is in the system PATH

➜ ~ which latexmk
/Library/TeX/texbin/latexmk
➜ ~ echo $PATH	# Look for /Library/TeX/texbin in the output

If it is but the error persists, try granting permissions to the texbin directory

sudo chown -R <username> /Library/TeX/texbin

If still not working, grant “Full Disk Access” to VSCode (this worked for me).

⭕️ VSCode Latex Workshop build error: “Cannot find LaTeX root file” or “Active document is not a TeX file”

Identify the problem: According to the error log, the language ID is django-txt, which is not a LaTeX file type.

[01:21:25.491][Build] The document of the active editor: file://%WS1%/file.tex
[01:21:25.491][Build] The languageId of the document: django-txt
[01:21:25.491][Build] Cannot find LaTeX root file. See https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#the-root-file

The Solution: 把 VS Code 右下角的语言模式切换为 LaTeX。Check the language mode in the bottom-right corner of VS Code. If it shows anything other than LaTeX (e.g., django-txt), change it to LaTeX.

Select language mode
Select language mode

🛠️ Building QGIS from source for Apple Silicon (M1 Pro, macOS Sonoma 14.4)

For a detailed guide for this, check out my reddit post below for the complete process.

Build and install QGIS with native Apple Silicon (M1 Pro, Sonoma 14.4)
byu/Ok-Sky-1162 inQGIS