<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Craig Gumbley</title>
    <description>The latest articles on Forem by Craig Gumbley (@chelnak).</description>
    <link>https://forem.com/chelnak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1047073%2F669ff3c1-52c6-4828-9dd1-1c6c36cdf1bb.jpeg</url>
      <title>Forem: Craig Gumbley</title>
      <link>https://forem.com/chelnak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/chelnak"/>
    <language>en</language>
    <item>
      <title>Puppet-lint: Soft dependency conflicts after updating</title>
      <dc:creator>Craig Gumbley</dc:creator>
      <pubDate>Fri, 17 Mar 2023 11:54:37 +0000</pubDate>
      <link>https://forem.com/puppet/puppet-lint-soft-dependency-conflicts-after-updating-430l</link>
      <guid>https://forem.com/puppet/puppet-lint-soft-dependency-conflicts-after-updating-430l</guid>
      <description>&lt;p&gt;For a &lt;a href="https://github.com/voxpupuli/voxpupuli-puppet-lint-plugins/commit/04879bddcd1d2f52bcb8806140cf666bd94120cb" rel="noopener noreferrer"&gt;while now&lt;/a&gt;, the &lt;a href="https://github.com/voxpupuli/voxpupuli-puppet-lint-plugins" rel="noopener noreferrer"&gt;&lt;code&gt;voxpupuli-puppet-lint-plugins&lt;/code&gt;&lt;/a&gt; meta gem has provided the community with a number of amazing plugins for &lt;code&gt;puppet-lint&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With the latest release of &lt;code&gt;puppet-lint&lt;/code&gt; and and Vox's plugins gem, a few things have changed that might cause a bit of friction when updating.&lt;/p&gt;

&lt;p&gt;I wanted to take a second to go over a few scenarios that might help you on your journey. &lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;First of all, lets talk about the problem.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;puppet-lint&lt;/code&gt; v3.1.0 we adopted two plugins which are now included as default checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/mmckinst/puppet-lint-legacy_facts-check" rel="noopener noreferrer"&gt;puppet-lint-legacy_facts-check&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/mmckinst/puppet-lint-top_scope_facts-check" rel="noopener noreferrer"&gt;puppet-lint-top_scope_facts-check&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prior to v4.0.0 of &lt;code&gt;voxpupuli-puppet-lint-plugins&lt;/code&gt;, these plugins were included in the meta gem.&lt;/p&gt;

&lt;p&gt;So now we have a scenario where it's possible to update &lt;code&gt;puppet-lint&lt;/code&gt; (&amp;gt;= 3.1.0) and end up with duplicate plugins installed.&lt;/p&gt;

&lt;p&gt;In this case, users may see warnings like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;warning: already initialized constant PuppetLint::CheckLegacyFacts
warning: previous definition of CheckLegacyFacts was here
warning: already initialized constant LEGACY_FACTS_VAR_TYPES
....
warning: already initialized constant TOP_SCOPE_FACTS_VAR_TYPES
warning: previous definition of TOP_SCOPE_FACTS_VAR_TYPES was here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not the end of the world, but it's extra noise that you don't want in your pipeline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Help! This is happening to me!
&lt;/h3&gt;

&lt;p&gt;So you are seeing these warnings? Read on...&lt;/p&gt;

&lt;p&gt;What we are seeing here is a soft dependency conflict.&lt;/p&gt;

&lt;p&gt;We have two identical plugins registering the same code inside puppet lint. That's what is causing the &lt;code&gt;already initialized constant&lt;/code&gt; warning.&lt;/p&gt;

&lt;p&gt;The best way forward is to clean up our environment and start again.&lt;/p&gt;

&lt;h4&gt;
  
  
  Remove voxpupuli-puppet-lint-plugins and it's dependencies
&lt;/h4&gt;

&lt;p&gt;We can start by removing dependencies of &lt;code&gt;voxpupuli-puppet-lint-plugins&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The command below will do just that. We grab the dependencies of Vox's meta gem and remove them one by one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gem dependency voxpupuli-puppet-lint-plugins &lt;span class="nt"&gt;--pipe&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"puppet-lint"&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt; &lt;span class="nt"&gt;-f1&lt;/span&gt; | xargs gem uninstall &lt;span class="nt"&gt;-aIx&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: Take extra care when running commands like this! 👀 &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After the previous command has completed, we should be left with the &lt;code&gt;voxpupuli-puppet-lint-plugins&lt;/code&gt; meta gem.&lt;/p&gt;

&lt;p&gt;Let's remove it with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gem uninstall voxpupuli-puppet-lint-plugins
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;..and check to see if everything has really gone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gem list | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"puppet-lint"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tldr; It should return nothing! Hurrah 🎉 &lt;/p&gt;

&lt;h4&gt;
  
  
  Re-install the latest gems
&lt;/h4&gt;

&lt;p&gt;Now we are free to re-install puppet-lint and &lt;code&gt;voxpupuli-puppet-lint-plugins&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install puppet-lint
gem install voxpupuli-puppet-lint-plugins
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once they have installed you can enjoy a warning free &lt;code&gt;puppet-lint&lt;/code&gt; experience with all of the joys from &lt;code&gt;voxpupuli-puppet-lint-plugins&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;... unless you have linting issues!&lt;/p&gt;

</description>
      <category>puppet</category>
      <category>linting</category>
      <category>puppetlint</category>
    </item>
  </channel>
</rss>
