stelligent / cfn_nag

Linting tool for CloudFormation templates
MIT License
1.25k stars 210 forks source link

Getting an error when install cfn-nag on Mac using brew #517

Closed gockle closed 3 years ago

gockle commented 3 years ago

Commands executed were,

brew install ruby brew-gem
brew gem install cfn-nag
==> /usr/local/opt/ruby/bin/gem install /Users/[]/Library/Caches/Homebrew/cfn-nag-0.6.23.gem --no-document --no-wrapper --no-user-install --install-dir /usr/local/Cellar/ge
Last 15 lines from /Users/[]/Library/Logs/Homebrew/gem-cfn-nag/01.gem:
2021-01-19 17:03:33 -0500

/usr/local/opt/ruby/bin/gem
install
/Users/[]/Library/Caches/Homebrew/cfn-nag-0.6.23.gem
--no-document
--no-wrapper
--no-user-install
--install-dir
/usr/local/Cellar/gem-cfn-nag/0.6.23
--bindir
/usr/local/Cellar/gem-cfn-nag/0.6.23/bin

ERROR:  While executing gem ... (NoMethodError)
    undefined method `request' for nil:NilClass

Do not report this issue to Homebrew/brew or Homebrew/core!

Traceback (most recent call last):
    22: from /usr/local/Homebrew/Library/Homebrew/build.rb:223:in `<main>'
    21: from /usr/local/Homebrew/Library/Homebrew/build.rb:134:in `install'
    20: from /usr/local/Homebrew/Library/Homebrew/utils.rb:531:in `with_env'
    19: from /usr/local/Homebrew/Library/Homebrew/build.rb:139:in `block in install'
    18: from /usr/local/Homebrew/Library/Homebrew/formula.rb:1215:in `brew'
    17: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2236:in `stage'
    16: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/lib/ruby/2.6.0/forwardable.rb:230:in `stage'
    15: from /usr/local/Homebrew/Library/Homebrew/resource.rb:91:in `stage'
    14: from /usr/local/Homebrew/Library/Homebrew/resource.rb:116:in `unpack'
    13: from /usr/local/Homebrew/Library/Homebrew/resource.rb:197:in `mktemp'
    12: from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `run'
    11: from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
    10: from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
     9: from /usr/local/Homebrew/Library/Homebrew/resource.rb:121:in `block in unpack'
     8: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2256:in `block in stage'
     7: from /usr/local/Homebrew/Library/Homebrew/utils.rb:531:in `with_env'
     6: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2257:in `block (2 levels) in stage'
     5: from /usr/local/Homebrew/Library/Homebrew/formula.rb:1222:in `block in brew'
     4: from /usr/local/Homebrew/Library/Homebrew/build.rb:171:in `block (2 levels) in install'
     3: from /var/folders/m3/1ncqfxcs44d8py32yqpjdyg8hc6nkx/T/gem-cfn-nag.rb:71:in `install'
     2: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2043:in `system'
     1: from /usr/local/Homebrew/Library/Homebrew/formula.rb:2043:in `open'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2107:in `block in system': Failed executing: /usr/local/opt/ruby/bin/gem install /Users/[]/Library/Caches/Homebrew/cfn-nag-0.6.23.gem --no-document --no-wrapper --no-user-install --install-dir /usr/local/Cellar/gem-cfn-nag/0.6.23 --bindir /usr/local/Cellar/gem-cfn-nag/0.6.23/bin (BuildError)
    5: from /usr/local/Homebrew/Library/Homebrew/brew.rb:153:in `<main>'
    4: from /usr/local/Homebrew/Library/Homebrew/brew.rb:165:in `rescue in <main>'
    3: from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:474:in `dump'
    2: from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:420:in `issues'
    1: from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:424:in `fetch_issues'
/usr/local/Homebrew/Library/Homebrew/utils/github.rb:323:in `issues_for_formula': undefined method `full_name' for nil:NilClass (NoMethodError)
arothian commented 3 years ago

Thanks for the report. I think this is related to Ruby 3 support mentioned in #509.

This should now be fixed with the most recent release. Let me know if you still have issues with the brew install.

hnishar commented 3 years ago

arothian@ I tried the most recent release (0.7.0), while the install works fine on Mac, running cfn_nag_scan on command line fails:


$ cfn_nag_scan --help
/usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:74:in `set_default_engine': Unable to find a compatible xml library. Ensure that you have installed or added to your Gemfile one of ox, oga, libxml, nokogiri or rexml (RuntimeError)
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:96:in `<class:Parser>'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:7:in `<module:Xml>'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:5:in `<module:Aws>'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:3:in `<top (required)>'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml.rb:8:in `require_relative'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml.rb:8:in `<top (required)>'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core.rb:68:in `require_relative'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core.rb:68:in `<top (required)>'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-kms-1.41.0/lib/aws-sdk-kms.rb:11:in `<top (required)>'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-s3-1.87.0/lib/aws-sdk-s3.rb:11:in `<top (required)>'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/rule_repos/s3_based_rule_repo.rb:3:in `<top (required)>'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/custom_rule_loader.rb:8:in `require_relative'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/custom_rule_loader.rb:8:in `<top (required)>'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/cfn_nag.rb:3:in `require_relative'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/cfn_nag.rb:3:in `<top (required)>'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag.rb:3:in `<top (required)>'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/bin/cfn_nag_scan:4:in `<top (required)>'
    from /usr/local/bin/cfn_nag_scan:6:in `load'
    from /usr/local/bin/cfn_nag_scan:6:in `<main>'
groverlalit commented 3 years ago

@arothian I can duplicate this error after the upgrade steps.

$ brew install ruby brew-gem
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
luv
==> Updated Formulae
Updated 56 formulae.

Warning: ruby 3.0.0_1 is already installed and up-to-date
To reinstall 3.0.0_1, run `brew reinstall ruby`
Warning: brew-gem 1.0.0 is already installed and up-to-date
To reinstall 1.0.0, run `brew reinstall brew-gem`
➜  $ brew gem install cfn-nag
==> Fetching cfn-nag from gem source
Fetching cfn-nag-0.7.0.gem
Downloaded cfn-nag-0.7.0
Warning: Cannot verify integrity of 'cfn-nag-0.7.0.gem'.
No checksum was provided for this resource.
For your reference, the checksum is:
  sha256 "3bce69032d81f3df6f8c505204e0568d62d64f00dedb7889da0cebcb89649b7e"
==> /usr/local/opt/ruby/bin/gem install /Users/XXX/Library/Caches/Homebrew/cfn-nag-0.7.0.gem --no-document --no-wrapper --no-user-install --insta
🍺  /usr/local/Cellar/gem-cfn-nag/0.7.0: 1,136 files, 7.9MB, built in 15 seconds

$ cfn_nag initiation.template                                               
/usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:74:in `set_default_engine': Unable to find a compatible xml library. Ensure that you have installed or added to your Gemfile one of ox, oga, libxml, nokogiri or rexml (RuntimeError)
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:96:in `<class:Parser>'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:7:in `<module:Xml>'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:5:in `<module:Aws>'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml/parser.rb:3:in `<top (required)>'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml.rb:8:in `require_relative'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core/xml.rb:8:in `<top (required)>'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core.rb:68:in `require_relative'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-core-3.111.2/lib/aws-sdk-core.rb:68:in `<top (required)>'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-kms-1.41.0/lib/aws-sdk-kms.rb:11:in `<top (required)>'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/aws-sdk-s3-1.87.0/lib/aws-sdk-s3.rb:11:in `<top (required)>'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/rule_repos/s3_based_rule_repo.rb:3:in `<top (required)>'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/custom_rule_loader.rb:8:in `require_relative'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/custom_rule_loader.rb:8:in `<top (required)>'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/cfn_nag.rb:3:in `require_relative'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag/cfn_nag.rb:3:in `<top (required)>'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/lib/cfn-nag.rb:3:in `<top (required)>'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /usr/local/Cellar/gem-cfn-nag/0.7.0/gems/cfn-nag-0.7.0/bin/cfn_nag:4:in `<top (required)>'
        from /usr/local/bin/cfn_nag:6:in `load'
        from /usr/local/bin/cfn_nag:6:in `<main>'
arothian commented 3 years ago

Thanks, looks like this is related to some Ruby 3.0 changes made upstream in the ruby aws-sdk (https://github.com/aws/aws-sdk-ruby/pull/2459).

rjcoelho commented 3 years ago

Thanks, looks like this is related to some Ruby 3.0 changes made upstream in the ruby aws-sdk (aws/aws-sdk-ruby#2459).

That PR was merged. So is it still occuring ? Btw I reverted to Ruby 2.7 and installed cfn-nag manually.

txynidakis commented 3 years ago

Hi I've got the same issue, however I installed cfn_nag using 'gem install' and it worked.

however still having issues via brew gem install.

arothian commented 3 years ago

This should be fixed in the latest version. Please let me know if still having issues with running the latest via homebrew.

tangix commented 2 years ago

Back in the office after a longer trip and just ran brew update and got a warning related to this issue report so I wanted to add this here for reference:

msa@verdandi ~ % brew --version
Homebrew 3.3.16-15-g6661f5b
Homebrew/homebrew-core (git revision 2468aa4748a; last commit 2022-02-22)
Homebrew/homebrew-cask (git revision 2d9c7603fe; last commit 2022-02-22)
msa@verdandi ~ % brew gem install cfn-nag
gem-cfn-nag 0.7.5 is already installed but outdated (so it will be upgraded).
==> Fetching cfn-nag from gem source
Fetching cfn-nag-0.8.9.gem
Downloaded cfn-nag-0.8.9
Warning: Cannot verify integrity of 'cfn-nag-0.8.9.gem'.
No checksum was provided for this resource.
For your reference, the checksum is:
  sha256 "eae1d782bf7b9e89948c0c00986c5d9239d6955053d8a4da969095dea9b31493"
==> Upgrading gem-cfn-nag
  0.7.5 -> 0.8.9

==> /usr/local/opt/ruby/bin/gem install /Users/msa/Library/Caches/Homebrew/cfn-nag-0.8.9.gem --no-do
🍺  /usr/local/Cellar/gem-cfn-nag/0.8.9: 1,236 files, 9.2MB, built in 13 seconds
==> Running `brew cleanup gem-cfn-nag`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/gem-cfn-nag/0.7.5... (1,224 files, 8.7MB)