Reputation: 1159
I have a very simple container running Sinatra in a Google Cloud Run. With no changes in the Dockerfile it recently stopped working.
When I try to run it I get the error:
/usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- sinatra (LoadError)
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from main_wow.rb:1:in `<main>'
Dockerfile:
FROM ruby:2.6.4-alpine3.9
ENV APP_HOME /WOW
WORKDIR $APP_HOME
ADD Gemfile* $APP_HOME/
RUN gem install bundler
RUN bundle install
ADD main_wow.rb $APP_HOME
ADD views/ $APP_HOME/views
# Start server
ENV PORT 3000
EXPOSE 3000
CMD ["ruby", "main_wow.rb"]
Gemfile:
source "http://rubygems.org"
gem 'sinatra'
gem 'i18n'
First 10 lines of main_wow.rb
:
require "sinatra"
require "net/http"
require "json"
require "i18n"
I18n.config.available_locales = :en
configure do
set :public_folder, './views'
set :bind, '0.0.0.0'
end
From what I could understand, it's trying to fetch the ruby gems from the major version 2.6.0, instead of 2.6.4. I have already tried to create a link, to set ruby version on the Gemfile but none seems to work...
Upvotes: 2
Views: 1416
Reputation: 1159
After several guesses, I fixed it with bundle exec
on the last line of the Dockerfile:
CMD ["bundle", "exec", "ruby", "main_wow.rb"]
Upvotes: 1