<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>snap | no dogma blog</title><link>https://nodogmablog.bryanhogan.net/tag/snap/</link><atom:link href="https://nodogmablog.bryanhogan.net/tag/snap/index.xml" rel="self" type="application/rss+xml"/><description>snap</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Mon, 22 Jun 2026 00:00:00 +0000</lastBuildDate><image><url>https://nodogmablog.bryanhogan.net/media/icon_hu9c23d68d4e9f1f9acfa8237e5c2ea674_3344_512x512_fill_lanczos_center_3.png</url><title>snap</title><link>https://nodogmablog.bryanhogan.net/tag/snap/</link></image><item><title>Unhandled exception - An error occurred trying to start process when using .NET CLI in VS Code snap on Ubuntu</title><link>https://nodogmablog.bryanhogan.net/2026/06/unhandled-exception-an-error-occurred-trying-to-start-process-when-using-net-cli-in-vs-code-snap-on-ubuntu/</link><pubDate>Mon, 22 Jun 2026 00:00:00 +0000</pubDate><guid>https://nodogmablog.bryanhogan.net/2026/06/unhandled-exception-an-error-occurred-trying-to-start-process-when-using-net-cli-in-vs-code-snap-on-ubuntu/</guid><description>&lt;p>I install VS Code in Ubuntu using snap. This has generally been fine, but with the new-ish &lt;code>dotnet run app.cs&lt;/code>, I hit an interesting problem. When I try to run some .NET CLI applications using a terminal within VS Code, I get an error that looks like this -&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-cfg" data-lang="cfg">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">Unhandled exception: An error occurred trying to start process &amp;#39;/home/bryan/snap/code/237/.local/share/dotnet/runfile/SimpleWebServer-6a1d7e4454421e2378bbc9c66e68b9889d32b9b306e8503dd754e1248aa787cd/bin/debug/SimpleWebServer&amp;#39; with working directory &amp;#39;/home/bryan/tools/bin&amp;#39;. No such file or directory&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;p>The application I was trying to run is called &lt;code>SimpleWebServer.cs&lt;/code> and it is located in the &lt;code>/home/bryan/tools/bin&lt;/code>, so why am I getting an error in the snap subfolder for VS Code?&lt;/p>
&lt;p>When I use a &amp;ldquo;normal&amp;rdquo; terminal outside VS Code, it works just fine.&lt;/p>
&lt;h3 id="behind-the-scenes">Behind the scenes&lt;/h3>
&lt;p>When I first run my &lt;code>SimpleWebServer.cs&lt;/code> application using the .NET CLI a build is performed, and the output is placed in a cache folder.&lt;/p>
&lt;p>The first time I run the application outside of VS Code, the output goes to a cache folder under &lt;code>~/.local/share/dotnet/&lt;/code>.&lt;/p>
&lt;p>But when I do this within VS Code, the output goes to a subfolder of the snap folder for my &lt;strong>current version&lt;/strong> of VS Code, for example, &lt;code>~/snap/code/247/.local/share/dotnet/runfile/&lt;/code>. Where &lt;code>247&lt;/code> is the version of VS Code I have installed.&lt;/p>
&lt;h4 id="the-problem">The problem&lt;/h4>
&lt;p>When I install a new version of VS Code, .NET CLI application are just copied to the new version. Say my previous version was 244, then the &lt;code>~/snap/code/244/.local/share/dotnet/runfile/&lt;/code> directory is copied to the new version of VS Code. But the .NET CLI applications still point to the previous version of VS Code, when they were built.&lt;/p>
&lt;p>Inside the folder for each .NET CLI application, there is a file named &lt;code>build-success.cache&lt;/code>. If you open this, you will see it has full paths defined, and these will point to the earlier version of VS Code, &lt;code>244&lt;/code> in this example.&lt;/p>
&lt;p>When VS Code tries to execute the application, it finds the cached binaries under the current version of VS Code, but the &lt;code>build-success.cache&lt;/code> file points to the old version of VS Code. This causes the error because the old version of VS Code has been removed, and the path no longer exists.&lt;/p>
&lt;h3 id="the-fix---wipe-em-all-away">The fix - wipe `em all away&lt;/h3>
&lt;p>Here is a simple script to delete all cached versions of an application inside the &lt;code>~/snap/code/*/.local/share/dotnet/runfile/&lt;/code> folders.&lt;/p>
&lt;p>Just pass the name of your application to the script, and it will print out the &lt;code>rm -rf&lt;/code> commands to remove all the cached versions of the application.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-cfg" data-lang="cfg">&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1&lt;/span>&lt;span>&lt;span style="color:#888;font-style:italic">#/bin/bash &lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2&lt;/span>&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3&lt;/span>&lt;span>&lt;span style="color:#000">if [[ $# -ne 1 ]]; then&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4&lt;/span>&lt;span> &lt;span style="color:#000">echo &amp;#34;Usage: $(basename &amp;#34;$0&amp;#34;) &amp;lt;app-name&amp;gt;&amp;#34; &amp;gt;&amp;amp;2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5&lt;/span>&lt;span> &lt;span style="color:#000">exit 1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6&lt;/span>&lt;span>&lt;span style="color:#000">fi&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7&lt;/span>&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8&lt;/span>&lt;span>&lt;span style="color:#000">app_name&lt;/span>=&lt;span style="color:#5a2">&amp;#34;$1&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9&lt;/span>&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10&lt;/span>&lt;span>&lt;span style="color:#000">find ~/snap/code -type d \&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11&lt;/span>&lt;span> &lt;span style="color:#000">-path &amp;#39;*/.local/share/dotnet/runfile/*&amp;#39; \&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12&lt;/span>&lt;span> &lt;span style="color:#000">-name &amp;#34;${app_name}-*&amp;#34; \&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13&lt;/span>&lt;span> &lt;span style="color:#000">-prune \&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14&lt;/span>&lt;span> &lt;span style="color:#000">| sort \&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15&lt;/span>&lt;span> &lt;span style="color:#000">| while IFS&lt;/span>= &lt;span style="color:#5a2">read -r dir; do
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16&lt;/span>&lt;span>&lt;span style="color:#5a2"> echo &amp;#34;rm -rf \&amp;#34;${dir}\&amp;#34;&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17&lt;/span>&lt;span>&lt;span style="color:#5a2"> done&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;p>Here&amp;rsquo;s how to use the script -
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-cfg" data-lang="cfg">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">./cleanup-dotnet-cache.sh SimpleWebServer&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/p>
&lt;p>The output will look something like this -&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-cfg" data-lang="cfg">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">rm -rf &amp;#34;/home/bryan/snap/code/244/.local/share/dotnet/runfile/SimpleWebServer-6a1d7e4454421e2378bbc9c66e68b9889d32b9b306e8503dd754e1248aa787cd&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">rm -rf &amp;#34;/home/bryan/snap/code/244/.local/share/dotnet/runfile/SimpleWebServer-83dd72e5c46d2016d117e6965e75daeea2f109439a9d32cb04351d6aac27b933&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">rm -rf &amp;#34;/home/bryan/snap/code/247/.local/share/dotnet/runfile/SimpleWebServer-6a1d7e4454421e2378bbc9c66e68b9889d32b9b306e8503dd754e1248aa787cd&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">rm -rf &amp;#34;/home/bryan/snap/code/247/.local/share/dotnet/runfile/SimpleWebServer-83dd72e5c46d2016d117e6965e75daeea2f109439a9d32cb04351d6aac27b933&amp;#34;&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;p>There you go, hope that helps someone.&lt;/p></description></item></channel></rss>