[{"content":" What this is Some notes on how I fixed an issue where I couldn\u0026rsquo;t paste text into tmux on WSL.\nWhat happened When I tried to paste text copied from Notepad on Windows into tmux on WSL, nothing would paste, no matter what I copied.\nEnvironment Windows 11 + WSL2 (Ubuntu 24.04) + tmux I was using the VS Code integrated terminal Cause The cause turned out to be broken WSL interop.\nInvestigating the cause I tried a test where I put a known string on the clipboard and then pasted it.\nprintf \u0026#39;PASTE_TEST_OK_123\u0026#39; | clip.exe # Put a known value on the clipboard # Press Ctrl+V immediately afterward. If everything is working, # PASTE_TEST_OK_123 should be pasted. The result was that something completely different was pasted. From this behavior, I suspected that the problem was with writing to the clipboard, before the paste operation itself.\nAfter some investigation, I found that while this problem was occurring, Windows executables in WSL were all failing like this:\n$ powershell.exe /mnt/c/.../powershell.exe: 1: MZ����: not found /mnt/c/.../powershell.exe: 9: Syntax error: \u0026#34;(\u0026#34; unexpected I asked an AI about this, and apparently MZ is the magic number used by Windows executables.An error like MZ����: not found apparently means that the exe file is being interpreted and executed as a shell script. According to the AI, this is a characteristic symptom of the WSL interop execution handler having disappeared.\nApparently, the reason Windows binaries can be launched from within WSL in the first place is that the Linux kernel\u0026rsquo;s binfmt_misc mechanism has a registration rule that says, roughly, \u0026ldquo;if the first bytes of a file match this particular magic number, pass it to this particular interpreter.\u0026rdquo; Normally, when a file starts with MZ, it\u0026rsquo;s handed to the WSL interop bridge, which starts the process on the Windows side. This time, however, that registration had disappeared, so clip.exe was being interpreted as a shell script, which is why pasting stopped working.\nI wasn\u0026rsquo;t able to determine exactly why the registration disappeared. The registrations under /proc/sys/fs/binfmt_misc/, which are used by binfmt_misc, are not persistent. At least in my environment, I found the following in the logs:\nA Docker Desktop crash followed by the WSL integration distro being unmounted Repeated Clock change detected messages, which I assume were traces of the system waking from sleep A cannot create /proc/sys/fs/binfmt_misc/WSLInterop: Permission denied message, apparently from a failed registration attempt caused by a conflict Personally, I suspect the Docker Desktop crash was the cause.\nSolution You can use the following commands to check whether broken WSL interop is really the cause.\nCommands for diagnosing the cause # Check whether the registration exists: # if WSLInterop is listed, it is registered ls /proc/sys/fs/binfmt_misc/ # Check whether it actually works: # if interop-alive is printed, everything is working cmd.exe /c \u0026#34;echo interop-alive\u0026#34; If the second command fails with an MZ...: not found error, restoring the registration is enough to fix the problem. Since all you\u0026rsquo;re doing is restoring the registration, pasting starts working again without restarting the shell.\nCommand to write the registration back sudo sh -c \u0026#34;echo \u0026#39;:WSLInterop:M::MZ::/init:PF\u0026#39; \u0026gt; /proc/sys/fs/binfmt_misc/register\u0026#34; If you run this command when everything is working normally, it will fail with an echo: I/O error. This is because writing to the register rejects a duplicate entry with the same name, so the error does not indicate that anything is wrong. By the way, you can combine the check and the fix into a single line like this:\n[ -e /proc/sys/fs/binfmt_misc/WSLInterop ] \u0026amp;\u0026amp; echo \u0026#34;No repair needed\u0026#34; || sudo sh -c \u0026#34;echo \u0026#39;:WSLInterop:M::MZ::/init:PF\u0026#39; \u0026gt; /proc/sys/fs/binfmt_misc/register\u0026#34; Wrapping up Thanks, Claude Code.\n","date":"2026-09-07T23:03:16+09:00","image":"/post/wsl-tmux-paste-not-working/image.webp","permalink":"/en/post/wsl-tmux-paste-not-working/","title":"When Paste Suddenly Stopped Working in tmux on WSL: Notes on the Fix"},{"content":" Overview Notes on the changes I made and the issues I ran into while migrating the Hugo Stack theme used on this site from v3 to v4.\nI mostly followed the official migration guide below.\nUpgrade to v4 | Stack Card-style Hugo theme designed for bloggers\nstack.cai.im Environment OS: Windows 11 Pro 25H2 Hugo: v0.155.3 → v0.165.0 hugo-theme-stack: v3.31.0 → v4.0.3 Upgrade Hugo Stack v4 requires Hugo v0.157.0 or later. My local version was v0.155.3, so I had to upgrade. I went with the latest version at the time (v0.165.0).\nHugo binaries are available from Hugo\u0026rsquo;s GitHub releases page.\nReleases · gohugoio/hugo The world’s fastest framework for building websites. - gohugoio/hugo\ngithub.com Stack requires the extended version of Hugo in both v3 and v4, so download a release with extended in its name. Extract the downloaded file and put its contents somewhere on your PATH. I\u0026rsquo;m on Windows, so I put it in C:\\HugoExtended\\bin and added C:\\HugoExtended\\bin to the PATH environment variable.\nChecking the Hugo version $ hugo version hugo v0.165.0-76a5e1880ab46688155b02e99bab9be2a6134492+extended windows/amd64 BuildDate=2026-08-12T14:26:28Z VendorInfo=gohugoio This site is hosted on Netlify, so I also had to bump Netlify\u0026rsquo;s build environment to Hugo v0.165.0. If you set HUGO_VERSION in netlify.toml, or as an environment variable in the Netlify dashboard, change that too.\nFix the X shortcode This one comes from upgrading Hugo rather than from the Stack theme itself: Hugo\u0026rsquo;s built-in tweet shortcode was removed in Hugo v0.156. Use the x shortcode instead.\nExample of the shortcode change - {{\u0026lt; tweet user=\u0026#34;username\u0026#34; id=\u0026#34;1234567890\u0026#34; \u0026gt;}} + {{\u0026lt; x user=\u0026#34;username\u0026#34; id=\u0026#34;1234567890\u0026#34; \u0026gt;}} Replace .Site.Data with hugo.Data This is another change caused by the Hugo upgrade: Hugo\u0026rsquo;s built-in .Site.Data was deprecated in Hugo v0.156. Use hugo.Data instead. In my case a custom shortcode I had written used .Site.Data, so I replaced it.\nTemporarily move custom files aside Going from v3 to v4, the way the theme is written and how its files are split up have both changed. So if you have layouts or assets directories that override the theme, move them aside temporarily.\nOne caveat: shortcodes (layouts/shortcodes in v3) must exist or the build will fail, so if you want builds to keep succeeding during the migration, move just the shortcodes to layouts/_shortcodes/.\nMigrate the config files The config files were YAML in v3, but v4 switched to TOML. Hugo converts YAML automatically, so it seems that sticking with YAML should be fine. Since I was going to review the settings anyway, I took the opportunity to switch to TOML.\nhugo-theme-stack-starter is a good reference for how to write the config. The Stack theme demo works too. Judging by Stack\u0026rsquo;s Getting Started, hugo-theme-stack-starter seems to be the official template, so that\u0026rsquo;s what I used as my reference. Create a config/_default directory and put the following files in it.\nconfig.toml config.toml holds the basic information about the site. I changed the following from the official template.\nAdded theme = \u0026quot;hugo-theme-stack\u0026quot; Changed baseurl to my own site\u0026rsquo;s URL Changed locale and defaultContentLanguage to Japanese, and accordingly set hasCJKLanguage to true I manage the Hugo theme as a Git Submodule rather than a Hugo Module, which is why theme = \u0026quot;hugo-theme-stack\u0026quot; is needed. If you manage it as a Hugo Module, you don\u0026rsquo;t need theme. In TOML, settings that don\u0026rsquo;t belong to any table won\u0026rsquo;t take effect unless you write them first. config.toml after the changes config.toml theme = \u0026#34;hugo-theme-stack\u0026#34; baseurl = \u0026#34;https://notes.nakurei.com/\u0026#34; locale = \u0026#34;ja-JP\u0026#34; title = \u0026#34;NakuRei\u0026#39;s Notes\u0026#34; copyright = \u0026#34;NakuRei\u0026#34; # Theme i18n support # See all available values at https://github.com/CaiJimmy/hugo-theme-stack/tree/master/i18n defaultContentLanguage = \u0026#34;ja\u0026#34; # Set hasCJKLanguage to true if DefaultContentLanguage is in [zh-cn ja ko] # This will make .Summary and .WordCount behave correctly for CJK languages. hasCJKLanguage = true enableRobotsTXT = true enableGitInfo = true timeout = \u0026#34;300s\u0026#34; [services.googleAnalytics] ID = \u0026#34;G-XXXXXXXXXX\u0026#34; [pagination] pagerSize = 10 [frontmatter] lastmod = [\u0026#34;lastmod\u0026#34;, \u0026#34;:git\u0026#34;, \u0026#34;date\u0026#34;, \u0026#34;publishDate\u0026#34;] languages.toml languages.toml holds the multilingual settings. These options are the same as languages in v3.\nIn the hugo-theme-stack-starter template the file is named _languages.toml; the leading underscore is there to keep the settings from being applied. So when you actually configure this, create it as languages.toml with the underscore removed. languages.toml after the changes languages.toml [ja] label = \u0026#34;日本語\u0026#34; locale = \u0026#34;ja\u0026#34; weight = 1 [ja.params] description = \u0026#34;努力の積み重ねを記録しておくためのサイト。\u0026#34; [ja.params.sidebar] subtitle = \u0026#34;努力の積み重ねを記録しておくだけ\u0026#34; [en] label = \u0026#34;English\u0026#34; locale = \u0026#34;en\u0026#34; weight = 2 [en.params] description = \u0026#34;A website to keep track of my efforts.\u0026#34; [en.params.sidebar] subtitle = \u0026#34;Just keep track of my efforts.\u0026#34; markup.toml markup.toml holds the settings for Markdown rendering. There\u0026rsquo;s no change from what I had under markup in v3, so it ports over as-is.\nmarkup.toml after the changes markup.toml # Markdown renderer configuration [goldmark.renderer] unsafe = false [goldmark.extensions.passthrough] enable = true [goldmark.extensions.passthrough.delimiters] block = [[\u0026#39;\\[\u0026#39;, \u0026#39;\\]\u0026#39;], [\u0026#39;$$\u0026#39;, \u0026#39;$$\u0026#39;]] inline = [[\u0026#39;\\(\u0026#39;, \u0026#39;\\)\u0026#39;]] [tableOfContents] endLevel = 4 ordered = true startLevel = 2 [highlight] noClasses = false codeFences = true guessSyntax = true lineNoStart = 1 lineNos = false lineNumbersInTable = true tabWidth = 4 menu.toml menu.toml holds the settings for the main menu and the social menu. I only configure the social menu on this site, but at least for that menu, the options are the same as in v3.\nmenu.toml after the changes menu.toml [[social]] identifier = \u0026#34;github\u0026#34; name = \u0026#34;GitHub\u0026#34; url = \u0026#34;https://github.com/NakuRei\u0026#34; [social.params] icon = \u0026#34;brand-github\u0026#34; [[social]] identifier = \u0026#34;x\u0026#34; name = \u0026#34;X\u0026#34; url = \u0026#34;https://x.com/nakurei7901\u0026#34; [social.params] icon = \u0026#34;brand-twitter\u0026#34; [[social]] identifier = \u0026#34;rss\u0026#34; name = \u0026#34;RSS\u0026#34; url = \u0026#34;https://notes.nakurei.com/index.xml\u0026#34; [social.params] icon = \u0026#34;rss\u0026#34; [[social]] identifier = \u0026#34;zenn\u0026#34; name = \u0026#34;Zenn\u0026#34; url = \u0026#34;https://zenn.dev/nakurei\u0026#34; [social.params] icon = \u0026#34;link\u0026#34; module.toml module.toml holds the Hugo Module settings. I manage the theme as a Git Submodule rather than a Hugo Module, so I didn\u0026rsquo;t create module.toml.\nparams.toml params.toml holds site-wide parameters — what used to live under params in v3. The following params changed in v4.\ndateFormat moved from Go format strings like Jan 02, 2006 to Hugo format strings like :date_full and :date_medium SortBy was added featuredImageField was removed: v4 always uses image defaultImage.opengraph was removed params.toml after the changes params.toml # Pages placed under these sections will be shown on homepage and archive page. mainSections = [\u0026#34;post\u0026#34;] # Output page\u0026#39;s full content in RSS. rssFullContent = true favicon = \u0026#34;img/favicon.png\u0026#34; # Accepted values: \u0026#34;default\u0026#34;, \u0026#34;lastmod\u0026#34; # default = see https://gohugo.io/quick-reference/glossary/#default-sort-order # lastmod = sort by last modified date, in descending order SortBy = \u0026#34;lastmod\u0026#34; [author] name = \u0026#34;NakuRei\u0026#34; url = \u0026#34;https://notes.nakurei.com/\u0026#34; [footer] since = 2022 customText = \u0026#34;\u0026#34; [dateFormat] published = \u0026#34;:date_medium\u0026#34; lastUpdated = \u0026#34;:date_medium\u0026#34; [sidebar] compact = false emoji = \u0026#34;🐢\u0026#34; subtitle = \u0026#34;\u0026#34; avatar = \u0026#34;img/avatar.png\u0026#34; [article] headingAnchor = true math = false toc = true readingTime = true [article.license] enabled = true default = \u0026#34;Licensed under CC BY-NC-SA 4.0\u0026#34; [widgets] homepage = [ { type = \u0026#34;search\u0026#34; }, { type = \u0026#34;categories\u0026#34;, params = { limit = 10 } }, { type = \u0026#34;tag-cloud\u0026#34;, params = { limit = 10 } }, { type = \u0026#34;archives\u0026#34;, params = { limit = 5 } }, ] page = [ { type = \u0026#34;toc\u0026#34; }, { type = \u0026#34;categories\u0026#34;, params = { limit = 10 } }, { type = \u0026#34;tag-cloud\u0026#34;, params = { limit = 10 } }, ] [opengraph.twitter] site = \u0026#34;nakurei7901\u0026#34; card = \u0026#34;summary_large_image\u0026#34; [colorScheme] toggle = true default = \u0026#34;auto\u0026#34; ## Comments [comments] enabled = false provider = \u0026#34;disqus\u0026#34; # See all the available configurations at https://github.com/CaiJimmy/hugo-theme-stack/blob/master/config/_default/params.toml # Copy the configurations you need from there and paste it here. ## Original url-card shortcode defaultNoImage = \u0026#34;icons/photo-off.svg\u0026#34; defaultNoLinkImage = \u0026#34;/icons/link-off.svg\u0026#34; imageQuality = 80 permalinks.toml permalinks.toml contains the same settings that were under permalinks in v3.\npermalinks.toml after the changes permalinks.toml post = \u0026#34;/post/:slug/\u0026#34; page = \u0026#34;/:slug/\u0026#34; related.toml related.toml contains the same settings that were under related in v3. There are no new options.\nrelated.toml after the changes related.toml # Related contents configuration includeNewer = true threshold = 60 toLower = false indices = [ { name = \u0026#34;tags\u0026#34;, weight = 100 }, { name = \u0026#34;categories\u0026#34;, weight = 200 }, ] Move the favicon The favicon and avatar images lived in static/ in v3, but v4 expects them in assets/. On this site the avatar was already in assets/img/, but the favicon was in static/img/, so I moved the favicon image to assets/img/.\nFix the front matter of your pages The front matter of articles changed between v3 and v4. What was hidden in v3 became build.list in v4. So if you were setting hidden = true, you need to change build.list to never like this.\nExample of the front matter change --- - hidden: true + build: + list: never --- If you were setting hidden = false, set build.list to always.\nExample of the front matter change --- - hidden: false + build: + list: always --- Migrate your layout customizations In Hugo, you can override a theme\u0026rsquo;s files by placing a file with the same name in the same location. Between v3 and v4, the Stack theme changed both how the theme is written and how its files are split up. So if you customized the theme, you need to fix the location, name and content of your customized files to match v4.\nMove the contents of layouts/_default/ into layouts/ With the Modern Template System introduced in Hugo v0.146.0, organizing files under a layouts/_default/ folder was deprecated and consolidated into placing them directly under layouts/. The Stack theme followed suit: in v4 the contents of layouts/_default/ moved into layouts/. So if you were using layouts/_default/, move it to layouts/.\nIn my case I had modified the theme\u0026rsquo;s layouts/_default/_markup, so I moved layouts/_default/_markup to layouts/_markup.\nMove the contents of layouts/partials into layouts/_partials This is another consequence of the Modern Template System introduced in Hugo v0.146.0. Stack v4 follows it and changed layouts/partials to layouts/_partials. So if you customized the theme, you need to move the contents of layouts/partials into layouts/_partials.\nChange the header image height In Stack v4 you can change the header image height in assets/scss/custom.scss1. The defaults are 150px on mobile, 200px in between, and 250px on large screens. In v3 I had customized these to 100px on mobile, 150px in between and 150px on large screens, so I created assets/scss/custom.scss with the following.\nassets/scss/custom.scss :root { --article-image-height: 100px; @include respond(md) { --article-image-height: 150px; } @include respond(xl) { --article-image-height: 150px; } } Remove var(--zh-font-family) In v3 I had customized the CSS on this site to change the font, but Stack v4 removed var(--zh-font-family), so my existing setting was ignored if left as-is. I removed var(--zh-font-family). Referencing an undefined CSS variable invalidates the whole property, so just deleting it brought my customization back.\nReferences and URLs Upgrade to v4 | Stack Card-style Hugo theme designed for bloggers\nstack.cai.im hugo-theme-stack-starter/config/_default at master · CaiJimmy/hugo-theme-stack-starter A quickstart template to create a Hugo blog using hugo-theme-stack - CaiJimmy/hugo-theme-stack-starter\ngithub.com In Stack v3 you had to override assets/scss/partials/article.scss to change this, so personally I\u0026rsquo;m glad about this change.\u0026#160;\u0026#x21a9;\u0026#xfe0e;\n","date":"2026-09-03T23:32:21+09:00","image":"/post/hugo-stack-v4-migration/image.webp","permalink":"/en/post/hugo-stack-v4-migration/","title":"Notes on Migrating the Hugo Stack Theme from v3 to v4"}]