cat articles/wsl-sharp

When sharp fails to install on WSL

This was a small but annoying trap. When I ran yarn add sharp on Linux inside WSL2, sharp started trying to build itself locally and failed with:

"/usr/include/vips/vips8:35:10: fatal error: glib-object.h:"

The confusing part was that the libvips-related packages existed, and /usr/include/glib-2.0/glib-object.h existed too. I tried several things, but none of them fixed it.

Looking more carefully at the other error messages, I found that it first failed here:

sharp: Installation error: ENOENT: no such file or directory, mkdir 'C:\Users\hotch\AppData\Roaming/npm-cache'

After that failure, it tried to start a local build. But why was Linux inside WSL referring to a Windows path in the first place? Looking at the environment, I found that the APPDATA environment variable was being passed into WSL as-is, and that path was coming from there.

In sharp's install code, the cache path includes env.APPDATA, which made it refer to the odd Windows path.

When I set APPDATA to an empty string, which evaluates as false in Node.js, sharp used the prebuilt Linux binary from the cache and installed successfully.

APPDATA='' yarn add sharp

This does not fix the underlying local-build problem, but sharp became usable, so that was good enough for now.

cat related_articles/wsl-sharp.yaml

  1. Adding type hints to a Python project and getting value from type checkingI added Python type hints and pyright to a machine learning project, and found that the setup cost was low while editor support and static checks were immediately useful.
  2. Starting Weekly AI News: automated summaries with clustering and GPTI started a weekly Substack newsletter that automatically summarizes AI-related news. This note explains how I cluster articles with multilingual-e5-small and generate topic titles and summaries with GPT.
  3. Building a Machine Learning PC with Two RTX 5090 GPUsNotes from building a two RTX 5090 machine learning PC in Japan, including power supply constraints, cooling, parts, and multi-GPU training tradeoffs.