aws / aws-xray-sdk-ruby

The official AWS X-Ray Recorder SDK for Ruby
Apache License 2.0
60 stars 58 forks source link

Rails: Does version 0.12.0 conflict with aws-sdk? #74

Closed tokoroga-dokkoi closed 2 years ago

tokoroga-dokkoi commented 3 years ago

Hello,

We have a rails application and run in docker.

We add 'aws-xray-sdk' (version 0.12.0) and re-build docker image, but build is failed.

What should I do?

Gemfile

gem 'aws-sdk', '~> 3' # We use this for uploading image to s3 and sending mail via ses
gem 'aws-xray-sdk', '~> 0.12.0', require: ['aws-xray-sdk/facets/rails/railtie']

Docker build log

 => ERROR [11/14] RUN bundle install                                                                                             29.1s
------
 > [11/14] RUN bundle install:
#15 2.922 Fetching gem metadata from https://rubygems.org/.........
#15 27.93 Resolving dependencies......
#15 28.99 Bundler could not find compatible versions for gem "aws-sdk-xray":
#15 28.99   In snapshot (Gemfile.lock):
#15 28.99     aws-sdk-xray (= 1.42.0)
#15 28.99
#15 28.99   In Gemfile:
#15 28.99     aws-sdk (~> 3) was resolved to 3.1.0, which depends on
#15 28.99       aws-sdk-resources (~> 3) was resolved to 3.116.0, which depends on
#15 28.99         aws-sdk-xray (~> 1)
#15 28.99
#15 28.99     aws-xray-sdk (~> 0.12.0) was resolved to 0.12.0, which depends on
#15 28.99       aws-sdk-xray (~> 1.4.0)
#15 28.99
#15 28.99 Running `bundle update` will rebuild your snapshot from scratch, using only
#15 28.99 the gems in your Gemfile, which may resolve the conflict.
------
NathanielRN commented 2 years ago

Hey @MikiWaraMiki ! Thanks for raising this issue.

I was trying to reproduce this issue locally but I can't get it to occur. I started by created a very simple Gemfile using your setup like this:

source 'https://rubygems.org'

gem 'aws-sdk', '~> 3' # We use this for uploading image to s3 and sending mail via ses
gem 'aws-xray-sdk', '~> 0.12.0', require: ['aws-xray-sdk/facets/rails/railtie']

When I run bundle install this completes successfully, which makes me think it should work in a Docker build successfully as well.

Looking at your error output it looks like you have 3 requests for aws-sdk-xray, not aws-xray-sdk, which is slightly different in name 🙂

#15 28.99   In snapshot (Gemfile.lock):
#15 28.99     aws-sdk-xray (= 1.42.0)
...
#15 28.99   In Gemfile:
...
#15 28.99         aws-sdk-xray (~> 1)
...
#15 28.99       aws-sdk-xray (~> 1.4.0)

The ~> 1 and ~> 1.4.0 should not conflict, which means the aws-sdk and aws-xray-sdk don't have conflicting values, but the requirement you have in your Gemfile.lock of aws-sdk-xray (= 1.42.0) will definitely conflict with the other requirements.

Do you know why your Gemfile.lock has this requirement? It might be worth it to delete this file and allow bundle install to generate it again in hopes that this fixes the problem? Otherwise you can post the section of Gemfile.lock which requires aws-sdk-xray and we can see which part of your dependencies is requiring such a specific (and dependency-conflict error-causing) version of = 1.42.0.

Let me know if that helps!

tokoroga-dokkoi commented 2 years ago

Hello, @NathanielRN !

The ~> 1 and ~> 1.4.0 should not conflict, which means the aws-sdk and aws-xray-sdk don't have conflicting values, but the requirement you have in your Gemfile.lock of aws-sdk-xray (= 1.42.0) will definitely conflict with the other requirements.

Noted with thanks! Your explanation really helped!

Thank you for your support in your busy time.