<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Terminal on NakuRei's Notes</title><link>https://notes.nakurei.com/en/categories/terminal/</link><description>Recent content in Terminal on NakuRei's Notes</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>NakuRei</copyright><atom:link href="https://notes.nakurei.com/en/categories/terminal/index.xml" rel="self" type="application/rss+xml"/><item><title>When Paste Suddenly Stopped Working in tmux on WSL: Notes on the Fix</title><link>https://notes.nakurei.com/en/post/wsl-tmux-paste-not-working/</link><pubDate>Mon, 07 Sep 2026 23:03:16 +0900</pubDate><guid>https://notes.nakurei.com/en/post/wsl-tmux-paste-not-working/</guid><description>&lt;img src="https://notes.nakurei.com/post/wsl-tmux-paste-not-working/image.webp" alt="Featured image of post When Paste Suddenly Stopped Working in tmux on WSL: Notes on the Fix" /&gt;&lt;h2 id="what-this-is"&gt;&#10; What this is&lt;a href="#what-this-is"&gt;&#10; &lt;img src="https://notes.nakurei.com/icons/link.svg" width="44" height="44" style="width: 0.9em; margin-left: 0.25em; margin-bottom: -0.12em;" alt="Link to this heading" /&gt;&#10; &lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Some notes on how I fixed an issue where I couldn&amp;rsquo;t paste text into tmux on WSL.&lt;/p&gt;&#10;&lt;h2 id="what-happened"&gt;&#10; What happened&lt;a href="#what-happened"&gt;&#10; &lt;img src="https://notes.nakurei.com/icons/link.svg" width="44" height="44" style="width: 0.9em; margin-left: 0.25em; margin-bottom: -0.12em;" alt="Link to this heading" /&gt;&#10; &lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;When I tried to paste text copied from Notepad on Windows into tmux on WSL, nothing would paste, no matter what I copied.&lt;/p&gt;&#10;&lt;h2 id="environment"&gt;&#10; Environment&lt;a href="#environment"&gt;&#10; &lt;img src="https://notes.nakurei.com/icons/link.svg" width="44" height="44" style="width: 0.9em; margin-left: 0.25em; margin-bottom: -0.12em;" alt="Link to this heading" /&gt;&#10; &lt;/a&gt;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Windows 11 + WSL2 (Ubuntu 24.04) + tmux&lt;/li&gt;&#10;&lt;li&gt;I was using the VS Code integrated terminal&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="cause"&gt;&#10; Cause&lt;a href="#cause"&gt;&#10; &lt;img src="https://notes.nakurei.com/icons/link.svg" width="44" height="44" style="width: 0.9em; margin-left: 0.25em; margin-bottom: -0.12em;" alt="Link to this heading" /&gt;&#10; &lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The cause turned out to be broken WSL interop.&lt;/p&gt;&#10;&lt;h3 id="investigating-the-cause"&gt;&#10; Investigating the cause&lt;a href="#investigating-the-cause"&gt;&#10; &lt;img src="https://notes.nakurei.com/icons/link.svg" width="44" height="44" style="width: 0.9em; margin-left: 0.25em; margin-bottom: -0.12em;" alt="Link to this heading" /&gt;&#10; &lt;/a&gt;&lt;/h3&gt;&#10;&lt;p&gt;I tried a test where I put a known string on the clipboard and then pasted it.&lt;/p&gt;&#10;&lt;style&gt;&#10; .code-block-filename {&#10; --code-filename-fontsize: calc(0.96em * 0.9);&#10;&#10; display: table;&#10; max-width: 100%;&#10; background: var(--accent-color-darker);&#10; color: var(--accent-color-text);&#10; font-size: var(--code-filename-fontsize);&#10; line-height: 1;&#10; padding-top: calc(var(--code-filename-fontsize) * 0.5);&#10; padding-left: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-right: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-bottom: calc(var(--code-filename-fontsize) * 0.7);&#10; border-radius: calc(var(--code-filename-fontsize) * 0.5)&#10; calc(var(--code-filename-fontsize) * 0.5) 0 0;&#10; }&#10; .code-block-content {&#10; padding-top: 0px;&#10; }&#10;&lt;/style&gt;&#10;&#10;&lt;div&gt;&#10; &lt;div class="code-block-content"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;PASTE_TEST_OK_123&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; clip.exe &lt;span class="c1"&gt;# Put a known value on the clipboard&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Press Ctrl+V immediately afterward. If everything is working,&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# PASTE_TEST_OK_123 should be pasted.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10; &lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;The result was that something completely different was pasted.&#10;From this behavior, I suspected that the problem was with writing to the clipboard, before the paste operation itself.&lt;/p&gt;&#10;&lt;p&gt;After some investigation, I found that while this problem was occurring, Windows executables in WSL were all failing like this:&lt;/p&gt;&#10;&lt;style&gt;&#10; .code-block-filename {&#10; --code-filename-fontsize: calc(0.96em * 0.9);&#10;&#10; display: table;&#10; max-width: 100%;&#10; background: var(--accent-color-darker);&#10; color: var(--accent-color-text);&#10; font-size: var(--code-filename-fontsize);&#10; line-height: 1;&#10; padding-top: calc(var(--code-filename-fontsize) * 0.5);&#10; padding-left: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-right: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-bottom: calc(var(--code-filename-fontsize) * 0.7);&#10; border-radius: calc(var(--code-filename-fontsize) * 0.5)&#10; calc(var(--code-filename-fontsize) * 0.5) 0 0;&#10; }&#10; .code-block-content {&#10; padding-top: 0px;&#10; }&#10;&lt;/style&gt;&#10;&#10;&lt;div&gt;&#10; &lt;div class="code-block-content"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ powershell.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/mnt/c/.../powershell.exe: 1: MZ����: not found&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/mnt/c/.../powershell.exe: 9: Syntax error: &lt;span class="s2"&gt;&amp;#34;(&amp;#34;&lt;/span&gt; unexpected&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10; &lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;I asked an AI about this, and apparently &lt;code&gt;MZ&lt;/code&gt; is the magic number used by Windows executables.An error like &lt;code&gt;MZ����: not found&lt;/code&gt; apparently means that the exe file is being interpreted and executed as a shell script.&#10;According to the AI, this is a characteristic symptom of the WSL interop execution handler having disappeared.&lt;/p&gt;&#10;&lt;p&gt;Apparently, the reason Windows binaries can be launched from within WSL in the first place is that the Linux kernel&amp;rsquo;s binfmt_misc mechanism has a registration rule that says, roughly, &amp;ldquo;if the first bytes of a file match this particular magic number, pass it to this particular interpreter.&amp;rdquo;&#10;Normally, when a file starts with &lt;code&gt;MZ&lt;/code&gt;, it&amp;rsquo;s handed to the WSL interop bridge, which starts the process on the Windows side. This time, however, that registration had disappeared, so &lt;code&gt;clip.exe&lt;/code&gt; was being interpreted as a shell script, which is why pasting stopped working.&lt;/p&gt;&#10;&lt;p&gt;I wasn&amp;rsquo;t able to determine exactly why the registration disappeared. The registrations under &lt;code&gt;/proc/sys/fs/binfmt_misc/&lt;/code&gt;, which are used by binfmt_misc, are not persistent.&#10;At least in my environment, I found the following in the logs:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;A Docker Desktop crash followed by the WSL integration distro being unmounted&lt;/li&gt;&#10;&lt;li&gt;Repeated &lt;code&gt;Clock change detected&lt;/code&gt; messages, which I assume were traces of the system waking from sleep&lt;/li&gt;&#10;&lt;li&gt;A &lt;code&gt;cannot create /proc/sys/fs/binfmt_misc/WSLInterop: Permission denied&lt;/code&gt; message, apparently from a failed registration attempt caused by a conflict&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Personally, I suspect the Docker Desktop crash was the cause.&lt;/p&gt;&#10;&lt;h2 id="solution"&gt;&#10; Solution&lt;a href="#solution"&gt;&#10; &lt;img src="https://notes.nakurei.com/icons/link.svg" width="44" height="44" style="width: 0.9em; margin-left: 0.25em; margin-bottom: -0.12em;" alt="Link to this heading" /&gt;&#10; &lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;You can use the following commands to check whether broken WSL interop is really the cause.&lt;/p&gt;&#10;&lt;style&gt;&#10; .code-block-filename {&#10; --code-filename-fontsize: calc(0.96em * 0.9);&#10;&#10; display: table;&#10; max-width: 100%;&#10; background: var(--accent-color-darker);&#10; color: var(--accent-color-text);&#10; font-size: var(--code-filename-fontsize);&#10; line-height: 1;&#10; padding-top: calc(var(--code-filename-fontsize) * 0.5);&#10; padding-left: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-right: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-bottom: calc(var(--code-filename-fontsize) * 0.7);&#10; border-radius: calc(var(--code-filename-fontsize) * 0.5)&#10; calc(var(--code-filename-fontsize) * 0.5) 0 0;&#10; }&#10; .code-block-content {&#10; padding-top: 0px;&#10; }&#10;&lt;/style&gt;&#10;&#10;&lt;div&gt;&#10; &lt;div class="code-block-filename"&gt;Commands for diagnosing the cause&lt;/div&gt;&#10; &#10; &lt;div class="code-block-content"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Check whether the registration exists:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# if WSLInterop is listed, it is registered&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ls /proc/sys/fs/binfmt_misc/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Check whether it actually works:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# if interop-alive is printed, everything is working&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cmd.exe /c &lt;span class="s2"&gt;&amp;#34;echo interop-alive&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10; &lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;If the second command fails with an &lt;code&gt;MZ...: not found&lt;/code&gt; error, restoring the registration is enough to fix the problem. Since all you&amp;rsquo;re doing is restoring the registration, pasting starts working again without restarting the shell.&lt;/p&gt;&#10;&lt;style&gt;&#10; .code-block-filename {&#10; --code-filename-fontsize: calc(0.96em * 0.9);&#10;&#10; display: table;&#10; max-width: 100%;&#10; background: var(--accent-color-darker);&#10; color: var(--accent-color-text);&#10; font-size: var(--code-filename-fontsize);&#10; line-height: 1;&#10; padding-top: calc(var(--code-filename-fontsize) * 0.5);&#10; padding-left: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-right: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-bottom: calc(var(--code-filename-fontsize) * 0.7);&#10; border-radius: calc(var(--code-filename-fontsize) * 0.5)&#10; calc(var(--code-filename-fontsize) * 0.5) 0 0;&#10; }&#10; .code-block-content {&#10; padding-top: 0px;&#10; }&#10;&lt;/style&gt;&#10;&#10;&lt;div&gt;&#10; &lt;div class="code-block-filename"&gt;Command to write the registration back&lt;/div&gt;&#10; &#10; &lt;div class="code-block-content"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo sh -c &lt;span class="s2"&gt;&amp;#34;echo &amp;#39;:WSLInterop:M::MZ::/init:PF&amp;#39; &amp;gt; /proc/sys/fs/binfmt_misc/register&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10; &lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="block-highlight-warning"&gt;&#10; &lt;span class="icon-warning"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-alert-triangle" width="44" height="44" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"&gt;&#10; &lt;path stroke="none" d="M0 0h24v24H0z" fill="none"/&gt;&#10; &lt;path d="M12 9v2m0 4v.01" /&gt;&#10; &lt;path d="M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75" /&gt;&#10;&lt;/svg&gt;&#10;&lt;/span&gt;&#10; &lt;span&gt;If you run this command when everything is working normally, it will fail with an &lt;code&gt;echo: I/O error&lt;/code&gt;. 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.&lt;/span&gt;&#10;&lt;/div&gt;&#10;&#10;&lt;p&gt;By the way, you can combine the check and the fix into a single line like this:&lt;/p&gt;&#10;&lt;style&gt;&#10; .code-block-filename {&#10; --code-filename-fontsize: calc(0.96em * 0.9);&#10;&#10; display: table;&#10; max-width: 100%;&#10; background: var(--accent-color-darker);&#10; color: var(--accent-color-text);&#10; font-size: var(--code-filename-fontsize);&#10; line-height: 1;&#10; padding-top: calc(var(--code-filename-fontsize) * 0.5);&#10; padding-left: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-right: calc(var(--code-filename-fontsize) * 0.7);&#10; padding-bottom: calc(var(--code-filename-fontsize) * 0.7);&#10; border-radius: calc(var(--code-filename-fontsize) * 0.5)&#10; calc(var(--code-filename-fontsize) * 0.5) 0 0;&#10; }&#10; .code-block-content {&#10; padding-top: 0px;&#10; }&#10;&lt;/style&gt;&#10;&#10;&lt;div&gt;&#10; &lt;div class="code-block-content"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt; -e /proc/sys/fs/binfmt_misc/WSLInterop &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;No repair needed&amp;#34;&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; sudo sh -c &lt;span class="s2"&gt;&amp;#34;echo &amp;#39;:WSLInterop:M::MZ::/init:PF&amp;#39; &amp;gt; /proc/sys/fs/binfmt_misc/register&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10; &lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;h2 id="wrapping-up"&gt;&#10; Wrapping up&lt;a href="#wrapping-up"&gt;&#10; &lt;img src="https://notes.nakurei.com/icons/link.svg" width="44" height="44" style="width: 0.9em; margin-left: 0.25em; margin-bottom: -0.12em;" alt="Link to this heading" /&gt;&#10; &lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Thanks, Claude Code.&lt;/p&gt;&#10;</description></item></channel></rss>