DEV Community

Puppet Developer Experience for puppet

Posted on • Originally published at on

puppet-lint: Already initialized constant warnings

For a while now, the voxpupuli-puppet-lint-plugins meta gem has provided the community with a number of amazing plugins for puppet-lint.

With the latest release of puppet-lint and and Vox’s plugins gem, a few things have changed that might cause a bit of friction when updating.

I wanted to take a second to go over a few scenarios that might help you on your journey.


First of all, lets talk about the problem.

In puppet-lint v3.1.0 we adopted two plugins which are now included as default checks:

Prior to v4.0.0 of voxpupuli-puppet-lint-plugins, these plugins were included in the meta gem.

So now we have a scenario where it’s possible to update puppet-lint (>= 3.1.0) and end up with duplicate plugins installed.

In this case, users may see warnings like this:

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

Enter fullscreen mode Exit fullscreen mode

Not the end of the world, but it’s extra noise that you don’t want in your pipeline.

Help! This is happening to me!

So you are seeing these warnings? Read on…

What we are seeing here is a soft dependency conflict.

We have two identical plugins registering the same code inside puppet lint. That’s what is causing the already initialized constant warning.

The best way forward is to clean up our environment and start again.

Remove voxpupuli-puppet-lint-plugins and it’s dependencies

We can start by removing dependencies of voxpupuli-puppet-lint-plugins.

The command below will do just that. We grab the dependencies of Vox’s meta gem and remove them one by one.

gem dependency voxpupuli-puppet-lint-plugins --pipe | grep "puppet-lint" | cut -d" " -f1 | xargs gem uninstall -aIx

Enter fullscreen mode Exit fullscreen mode

Note: Take extra care when running commands like this! 👀

After the previous command has completed, we should be left with the voxpupuli-puppet-lint-plugins meta gem.

Let’s remove it with the following command:

gem uninstall voxpupuli-puppet-lint-plugins

Enter fullscreen mode Exit fullscreen mode

..and check to see if everything has really gone.

gem list | grep "puppet-lint"

Enter fullscreen mode Exit fullscreen mode

Tldr; It should return nothing! Hurrah 🎉

Re-install the latest gems

Now we are free to re-install puppet-lint and voxpupuli-puppet-lint-plugins

gem install puppet-lint
gem install voxpupuli-puppet-lint-plugins

Enter fullscreen mode Exit fullscreen mode

Once they have installed you can enjoy a warning free puppet-lint experience with all of the joys from voxpupuli-puppet-lint-plugins!

… unless you have linting issues!

Top comments (0)