boltops-tools / terraspace

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

Gem::ConflictError: Unable to activate aws-sdk-dynamodb-1.74.0 #217

Closed ericpardee closed 2 years ago

ericpardee commented 2 years ago

Checklist

My Environment

Software Version
macOS 12.2.1
Terraform 0.14.11
Terraspace 1.1.7
Ruby 3.0.3p157

Expected Behaviour

Current Behavior

Gem::ConflictError: Unable to activate aws-sdk-dynamodb-1.74.0, because aws-sdk-core-3.126.2 conflicts with aws-sdk-core (~> 3, >= 3.127.0) ERROR: Unable to require plugin terraspace_plugin_aws

Step-by-step reproduction instructions

$ brew tap boltops-tools/software
$ brew install terraspace
$ terraspace new project terraspace
=> Creating new project called terraspace
      create  terraspace
      create  terraspace/.gitignore
      create  terraspace/Gemfile
      create  terraspace/README.md
      create  terraspace/Terrafile
      create  terraspace/config/app.rb
=> Installing dependencies with: bundle install
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies....
Using aws-eventstream 1.2.0
Using jmespath 1.6.0
Using memoist 0.16.2
Using text-table 1.2.4
Using zeitwerk 2.5.4
Using deep_merge 1.2.2
Using diff-lcs 1.5.0
Using dotenv 2.7.6
Using concurrent-ruby 1.1.9
Using bundler 2.3.7
Using rainbow 3.1.1
Using eventmachine 1.2.7
Using racc 1.6.0
Using tilt 2.0.10
Using graph 2.10.0
Using rubyzip 2.3.2
Using nokogiri 1.13.3 (x86_64-darwin)
Fetching aws-partitions 1.558.0
Using rspec-support 3.11.0
Using aws-sigv4 1.4.0
Using rspec-core 3.11.0
Using rspec-expectations 3.11.0
Using eventmachine-tail 0.6.5
Using i18n 1.10.0
Using tzinfo 2.0.4
Using thor 1.2.1
Using rhcl 0.1.0
Fetching minitest 5.15.0
Using rexml 3.2.5
Using rspec-mocks 3.11.0
Using tty-tree 0.4.0
Using hcl_parser 0.2.1
Using rspec 3.11.0
Installing aws-partitions 1.558.0
Installing minitest 5.15.0
Fetching aws-sdk-core 3.127.0
Using activesupport 7.0.2.2
Using cli-format 0.2.2
Fetching dsl_evaluator 0.2.2
Using render_me_pretty 0.8.4
Using rspec-terraspace 0.3.1
Installing dsl_evaluator 0.2.2
Installing aws-sdk-core 3.127.0
Fetching aws-sdk-dynamodb 1.74.0
Fetching aws-sdk-kms 1.55.0
Fetching aws_data 0.1.1
Fetching aws-sdk-ssm 1.132.0
Fetching aws-sdk-secretsmanager 1.58.0
Installing aws-sdk-kms 1.55.0
Installing aws_data 0.1.1
Installing aws-sdk-secretsmanager 1.58.0
Installing aws-sdk-dynamodb 1.74.0
Fetching aws-sdk-s3 1.113.0
Installing aws-sdk-ssm 1.132.0
Installing aws-sdk-s3 1.113.0
Using terraspace-bundler 0.5.0
Fetching s3-secure 0.6.1
Using terraspace 1.1.7
Installing s3-secure 0.6.1
Fetching terraspace_plugin_aws 0.3.7
Installing terraspace_plugin_aws 0.3.7
Bundle complete! 3 Gemfile dependencies, 49 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Gem::ConflictError: Unable to activate aws-sdk-dynamodb-1.74.0, because aws-sdk-core-3.126.2 conflicts with aws-sdk-core (~> 3, >= 3.127.0)
ERROR: Unable to require plugin terraspace_plugin_aws
Are you sure you the plugin exists and you specified the right plugin option.
You specified --plugin aws

Thought maybe a version of ruby conflicting but only had default macOS version of ruby prior to terraspace install.

$ which -a ruby
/usr/local/bin/ruby
/usr/bin/ruby

$ which -a bundle
/usr/local/bin/bundle
/usr/bin/bundle

Code Sample

N/A

Solution Suggestion

I think a gem needs to be pinned but not sure how to do this TBH

ericpardee commented 2 years ago

I was able to get it working by reverting to terraspace 1.1.6 (gem install terraspace -v 1.1.6), which installed correctly and coincidentally it upgraded terraspace to 1.1.7:

$ terraspace new project terraspace
=> Creating new project called terraspace
      create  terraspace
      create  terraspace/.gitignore
      create  terraspace/Gemfile
      create  terraspace/README.md
      create  terraspace/Terrafile
      create  terraspace/config/app.rb
=> Installing dependencies with: bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using concurrent-ruby 1.1.9
Using i18n 1.10.0
Fetching minitest 5.15.0
Installing minitest 5.15.0
Using tzinfo 2.0.4
Using zeitwerk 2.5.4
Using activesupport 6.1.4.6
Using aws-eventstream 1.2.0
Using aws-partitions 1.558.0
Using aws-sigv4 1.4.0
Using jmespath 1.6.0
Using aws-sdk-core 3.127.0
Fetching aws-sdk-dynamodb 1.74.0
Installing aws-sdk-dynamodb 1.74.0
Using aws-sdk-kms 1.55.0
Using aws-sdk-s3 1.113.0
Fetching aws-sdk-secretsmanager 1.58.0
Installing aws-sdk-secretsmanager 1.58.0
Fetching aws-sdk-ssm 1.132.0
Installing aws-sdk-ssm 1.132.0
Using memoist 0.16.2
Fetching aws_data 0.1.1
Installing aws_data 0.1.1
Using bundler 1.17.2
Using text-table 1.2.4
Using cli-format 0.2.2
Using deep_merge 1.2.2
Using diff-lcs 1.5.0
Using dotenv 2.7.6
Using rainbow 3.1.1
Using dsl_evaluator 0.2.2
Using eventmachine 1.2.7
Using eventmachine-tail 0.6.5
Using graph 2.10.0
Using rhcl 0.1.0
Using hcl_parser 0.2.1
Fetching mini_portile2 2.8.0
Installing mini_portile2 2.8.0
Fetching racc 1.6.0
Installing racc 1.6.0 with native extensions
Fetching nokogiri 1.13.3 (x86_64-darwin)
Installing nokogiri 1.13.3 (x86_64-darwin)
Using tilt 2.0.10
Using render_me_pretty 0.8.4
Fetching rexml 3.2.5
Installing rexml 3.2.5
Using rspec-support 3.11.0
Using rspec-core 3.11.0
Using rspec-expectations 3.11.0
Using rspec-mocks 3.11.0
Using rspec 3.11.0
Using rspec-terraspace 0.3.1
Using rubyzip 2.3.2
Using thor 1.2.1
Fetching s3-secure 0.6.1
Installing s3-secure 0.6.1
Using terraspace-bundler 0.5.0
Using tty-tree 0.4.0
Fetching terraspace 1.1.7
Installing terraspace 1.1.7
Fetching terraspace_plugin_aws 0.3.7
Installing terraspace_plugin_aws 0.3.7
Bundle complete! 3 Gemfile dependencies, 50 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
       exist  terraspace
      create  terraspace/config/terraform/backend.tf
      create  terraspace/config/terraform/provider.tf
      create  terraspace/app/modules
      create  terraspace/app/stacks
================================================================
Congrats! You have successfully created a terraspace project.
Check out the created files.

    cd terraspace

You can create starter modules and stacks with their generators:

    terraspace new module example
    terraspace new stack demo

Add your code to them, and deploy when you are ready:

    terraspace up demo -y   # to deploy

Destroy with:

    terraspace down demo -y # to destroy

More info: https://terraspace.cloud/
tongueroo commented 2 years ago

Wondering if you can run:

which terraspace
cat $(which terraspace)
ericpardee commented 2 years ago

Wondering if you can run:

which terraspace
cat $(which terraspace)

Sure, but just to reiterate, after the brew install issue in this GH Issue, I ended up removing the brew install of terraspace

sudo pkgutil --forget test.boltops.pkg.terraspace # had issue with brew uninstall terraspace, not sure why
rm -rf /usr/local/Homebrew/Library/Taps/boltops-tools
sudo rm -rf /opt/terraspace
grep -l /opt/terraspace /usr/local/bin/* | xargs rm -f
rm -rf ~/.bundle

Then installed the gem manually

asdf install ruby 3.0.3
asdf local ruby terraspace
GEM_HOME="$HOME/.terraspace_gems"
PATH=$HOME/.terraspace_gems/bin:$PATH
gem install terraspace -v 1.1.6

which is what the output will reflect

$ which -a terraspace
/Users/ericpardee/.terraspace_gems/bin/terraspace

$ cat $(which terraspace)
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'terraspace' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
  str = str.b[/\A_(.*)_\z/, 1]
  if str and Gem::Version.correct?(str)
    version = str
    ARGV.shift
  end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('terraspace', 'terraspace', version)
else
gem "terraspace", version
load Gem.bin_path("terraspace", "terraspace", version)
end
tongueroo commented 2 years ago

Think realized what's going on. The standalone installer will install an embedded version of

  1. ruby
  2. terraspace
  3. gem dependencies

When the standalone installer is built, it snapshots the latest versions of the gem dependencies at that time. When installing terraspace with the standalone installer for the very first time, the Terraspace project's Gemfile.lock gems will match whatever the installer has.

However, later on, when terraspace is upgraded with the another standalone installer version, though terraspace is updated, the other gems in the standalone installer package are not guaranteed to match with the project's Gemfile.lock. So the recommendation for upgrading terraspace is to:

  1. update the project's Gemfile
  2. run bundle update or bundle install

This will use the embedded ruby and bundle commands in the standalone installer and update the terraspace gem embedded in the standalone package. Have updated the docs with these instruction: