boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
678 stars 46 forks source link

'terraspace new plugin' throws 'NoMethodError' #73

Closed ideas-into-software closed 2 years ago

ideas-into-software commented 3 years ago

My Environment

Software Version
Operating System Fedora 31
Terraform 0.14.4
Terraspace 0.5.10
Ruby 2.7.2p137

Expected Behaviour

Skeleton for new plugin created.

Current Behavior

'terraspace new plugin' throws 'NoMethodError'

Step-by-step reproduction instructions

terraspace new plugin terraspace_plugin_hyperv
=> Creating new plugin: terraspace_plugin_hyperv
Traceback (most recent call last):
    23: from /opt/terraspace/embedded/bin/terraspace:23:in `<main>'
    22: from /opt/terraspace/embedded/bin/terraspace:23:in `load'
    21: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.5.10/exe/terraspace:14:in `<top (required)>'
    20: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
    19: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.5.10/lib/terraspace/command.rb:59:in `dispatch'
    18: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
    17: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
    16: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
    15: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:243:in `block in subcommand'
    14: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:116:in `invoke'
    13: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.5.10/lib/terraspace/command.rb:59:in `dispatch'
    12: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
    11: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
    10: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
     9: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:40:in `block in register'
     8: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:116:in `invoke'
     7: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/group.rb:232:in `dispatch'
     6: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `invoke_all'
     5: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `map'
     4: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `each'
     3: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `block in invoke_all'
     2: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
     1: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
/opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.5.10/lib/terraspace/cli/new/plugin.rb:16:in `create_plugin': undefined method `core_template_source' for #<Terraspace::CLI::New::Plugin:0x0000000002d25440> (NoMethodError)
dlethin commented 3 years ago

I'm a bit rusty with ruby, but this seems to have to do with the fact that the method trying to be called core_template_source, is defined in a different file than that one that is actually be included. The function is here in lib/terraspace/cli/new/plugin/helper.rb, but the there is another file in lib/terraspace/cli/new/helpers.rb that is actually getting included when include Helpers is called in plugin.rb .

To work around this, I manually copied the core_template_source function definition into the file lib/terraspace/cli/new/helpers.rb and that removed the error for me.

What the actual correct thing to do is to submit a PR, I don't know, but maybe that gives someone with more experience a better clue to figure out how to solve the problem.

Cheers.

ChristopherLenz commented 3 years ago

I have a similar error in my environment. But for me this error comes for every command I try

I have worked with terraspace end of april. Now I wanted to destroy everything but terraspace is not working anymore. The onle thing which was changed is the version of terraspace (apt-get). I tried to downgrade to the oldest available version without success.

Mine from april (0.6.6-20210425100245) is not available anymore

Building one of the modules to get backend.tf info
Traceback (most recent call last):
    22: from /opt/terraspace/embedded/bin/terraspace:23:in `<main>'
    21: from /opt/terraspace/embedded/bin/terraspace:23:in `load'
    20: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/exe/terraspace:14:in `<top (required)>'
    19: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
    18: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/command.rb:59:in `dispatch'
    17: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
    16: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
    15: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
    14: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/cli.rb:178:in `summary'
    13: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/cli/summary.rb:14:in `run'
    12: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/cli/summary.rb:25:in `build_placeholder'
    11: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/cli/build/placeholder.rb:23:in `build'
    10: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/builder.rb:13:in `run'
     9: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/builder.rb:77:in `clean'
     8: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/compiler/cleaner.rb:9:in `clean'
     7: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/compiler/cleaner.rb:16:in `backend_change_purge'
     6: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/compiler/cleaner/backend_change.rb:10:in `purge'
     5: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/compiler/cleaner/backend_change.rb:20:in `purge?'
     4: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/compiler/cleaner/backend_change.rb:34:in `current_backend'
     3: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/memoist-0.16.2/lib/memoist.rb:169:in `cache_dir'
     2: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/mod.rb:130:in `cache_dir'
     1: from /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/memoist-0.16.2/lib/memoist.rb:213:in `autodetect'
/opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/terraspace-0.6.6/lib/terraspace/compiler/expander.rb:26:in `autodetect': undefined method `[]' for nil:NilClass (NoMethodError)

Edit: For me it was the missing Gemfile