ibnesayeed / linkextractor

A Docker tutorial using a link extraction application example
https://training.play-with-docker.com/microservice-orchestration/
MIT License
51 stars 54 forks source link

Step6 fails with Ruby 2.7 image #6

Closed laurensknoll closed 4 years ago

laurensknoll commented 4 years ago

Step 6 currently fails on docker run. A LoadError occurs for the "sinatra"-gem.

Error

/usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- sinatra (LoadError)
from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
from ./linkextractor.rb:4:in `<main>'

Cause

Step 6 uses the ruby:2-image. As of December 27th this is Ruby version 2.7 Ruby PR. With this image, the "bundle install" command installs to "/usr/local/bundle/ruby/2.7.0" vs "/usr/local/bundle".

The version-specific path is not configured in the Gem environment. Causing the LoadError.

Resolution

To get step 6 running, I found two options:

1 Restore old behaviour and use Ruby 2.6

FROM       ruby:2.6
...

2 Add version-specific bundle path to the GEM_PATH environment variable

...
ENV        REDIS_URL "redis://localhost:6379"
ENV        GEM_PATH "$GEM_HOME/ruby/$RUBY_VERSION:$GEM_PATH"
...

Please let me know what kind of resolution is accepted and I'll be happy to submit a PR.

ibnesayeed commented 4 years ago

Thanks for reporting this @laurensknoll. This is rather surprising to me because the Ruby language and the community usually does not introduce such breaking changes in the spirit of programmers' happiness mantra. If it was done for a good reason, I hope this gets addressed in the base docker images of affected Ruby versions instead of requiring every user to set this environment variable explicitly. I would like to see any discussions around this change, if you have any references handy.

I usually prefer a change that is forward-looking and ideally backward-compatible. However, in this case I would go for a more explicit version specification of Ruby (i.e., ruby:2.6) for the simple reason of not adding yet another instruction in the Dockerfile that we will end up describing unnecessarily or confusing beginners of this tutorial.

Please note that any changes need to be reflected in the specific branch as well as corresponding directory of the master branch, so you need to create two separate PRs.

laurensknoll commented 4 years ago

Thanks for the feedback. Just created two PR's that set the Ruby image version to 2.6.

ibnesayeed commented 4 years ago

Thanks for PRs, I have created one in the tutorial repo as well https://github.com/play-with-docker/play-with-docker.github.io/pull/197.

rrazor commented 4 years ago

I filed this issue upstream with the maintainers of the Docker image: https://github.com/docker-library/ruby/issues/305