nov / openid_connect

OpenID Connect Server & Client Library
MIT License
418 stars 122 forks source link

Include tzinfo-data gem #73

Closed willdowglas closed 10 months ago

willdowglas commented 2 years ago

When you're using this gem outside the Rails environment (Sinatra, for instance), the gem tzinfo-data is not included, so when you do

require 'openid_connect'
...

It will raise the TZInfo::DataSourceNotFound error.

The fix is pretty simple, as the doc suggests: https://github.com/tzinfo/tzinfo/wiki/Resolving-TZInfo::DataSourceNotFound-Errors

If you want to simulate this, I made a simple Dockerfile so you can try it.

FROM ruby:3.1.2-alpine3.16

WORKDIR /opt

COPY Gemfile* ./
COPY VERSION .
COPY openid_connect.gemspec .

RUN apk add --update-cache --no-cache --virtual .build-deps g++ make \
    && apk add --update-cache --no-cache gcompat shared-mime-info git \
    && bundle install \
    && gem build openid_connect.gemspec \
    && gem install openid_connect-1.3.1.gem \
    && rm -rf /usr/local/bundle/cache/*.gem \
    && find /usr/local/bundle/gems/ -name "*.c" -delete \
    && find /usr/local/bundle/gems/ -name "*.o" -delete \
    && apk --purge del .build-deps

COPY . .

Build with

docker build . -t openid

And run IRB trying to import the openid_connect gem

docker run -it openid bundle exec irb

irb(main):001:0> require 'openid_connect'

Or run the tests, which will fail:

docker run -it openid bundle rake

If you run these steps with this commit, you'll see that everything works as supposed.

nov commented 2 years ago

can't you install tzdata via apt?

willdowglas commented 2 years ago

Yes, but it doesn't come pre-installed in most Linux distros, as well as windows and mac os.

If you don't want to add another dependency, maybe I can update the readme pointing out that tzdata is a prerequisite.

What do you think would be better?

nov commented 10 months ago

if you can google the solution, it should be enough.