Skip to content

Conversation

@beechtom
Copy link
Contributor

@beechtom beechtom commented May 7, 2020

This adds a warning that Bolt may be installed as a gem when bundled
content is missing. Bolt checks if any modules other than aggregate,
canary, and puppetdb_fact are installed at Bolt::PAL::MODULES_PATH
to determine if it may be a gem install.

This warning can be disabled by setting the BOLT_GEM environment
variable.

Closes #1779

!feature

  • Warn when Bolt is installed as a gem
    (#1779)

    Bolt now issues a warning when it detects that it may have been
    installed as a gem. This warning can be disabled by setting the
    BOLT_GEM environment variable.

    To install Bolt reliably and with all of its dependencies, it should
    be installed as a package.

This adds a warning that Bolt may be installed as a gem when bundled
content is missing. Bolt checks if any modules other than `aggregate`,
`canary`, and `puppetdb_fact` are installed at `Bolt::PAL::MODULES_PATH`
to determine if it may be a gem install.

This warning can be disabled by setting the `BOLT_GEM` environment
variable to `false`.

!feature

* **Warn when Bolt is installed as a gem**
  ([puppetlabs#1779](puppetlabs#1779))

  Bolt now issues a warning when it detects that it may have been
  installed as a gem. This warning can be disabled by setting the
  `BOLT_GEM` environment to `false`.

  To install Bolt reliably and with all of its dependencies, it should
  be [installed as a
  package](https://puppet.com/docs/bolt/latest/bolt_installing.html).
@beechtom beechtom requested a review from a team as a code owner May 7, 2020 00:32
lib/bolt/cli.rb Outdated

def bundled_content
# If the bundled content directory is empty, Bolt is likely installed as a gem.
if ENV['BOLT_GEM'] != 'false' && gem_install?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ticket said "when BOLT_GEM is anything but true", which seemed weird as we'd need to first check that it wasn't nil. Since a user will need to explicitly set this variable to disable the warning, I felt that requiring the value to be false made sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think common practice with variables like these is to simply require they be set. That is, setting BOLT_GEM means "I know I'm running from a gem install and that's okay".

@puppetcla
Copy link

CLA signed by all contributors.

Copy link
Contributor

@nicklewis nicklewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to set BOLT_GEM in the Gemfile so you don't get this warning when running from source? Or is the warning useful because it reminds you that you may need to r10k puppetfile install?

lib/bolt/cli.rb Outdated

def bundled_content
# If the bundled content directory is empty, Bolt is likely installed as a gem.
if ENV['BOLT_GEM'] != 'false' && gem_install?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think common practice with variables like these is to simply require they be set. That is, setting BOLT_GEM means "I know I'm running from a gem install and that's okay".

@beechtom beechtom requested a review from nicklewis May 7, 2020 18:48
@nicklewis nicklewis merged commit 28b3516 into puppetlabs:master May 7, 2020
@beechtom beechtom deleted the 1779/bolt-gem branch May 7, 2020 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn when running Bolt as a gem

3 participants