Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta Version is not Loadable #7

Open
MattyCodes opened this issue Nov 29, 2021 · 3 comments
Open

Beta Version is not Loadable #7

MattyCodes opened this issue Nov 29, 2021 · 3 comments
Labels

Comments

@MattyCodes
Copy link

Overview

It is my understanding that new API consumers are meant to be using the "beta 1.0.0" version of this library, however we've run into some issues loading it which I think are related to how the library is registered with RubyGems. Here is the guide we are following: https://github.com/OneSignal/onesignal-ruby-client/blob/aa5a0bea2fadf3f023d76de5f1492f25af3f7d34/README.md. After installing the gem, when trying to require it in our project in the boot-file (or in a console), we see the following error:

[1] pry(main)> require 'onesignal'
LoadError: cannot load such file -- onesignal
from /home/$USER/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'

Steps to Reproduce

Per the documentation, we've added the following to our Gemfile:

gem 'onesignal', '~> 1.0.0.beta1'

Then we run bundle, which appears to work and yields the following output:

Fetching onesignal 1.0.0.beta1 (was 0.3.0)
Installing onesignal 1.0.0.beta1 (was 0.3.0)

Then, either in a console or on application-startup, add the line require 'onesignal' and you should see the error above.

Temporary Fix

For the time being, we have found that we can work around this issue by specifying the git location and the git branch for the targeted beta release; the line in the Gemfile must be changed to:

gem 'onesignal', '~> 1.0.0.beta1', git: 'git://github.com/OneSignal/onesignal-ruby-client.git', branch: '1.0.0.beta1'

When running bundle with that in our Gemfile, we are able to use the library as expected:

[6] pry(main)> require 'onesignal'
=> false # Already required.
[8] pry(main)> OneSignal::DefaultApi
=> OneSignal::DefaultApi # Working as expected.

Summary

The temporary fix will give us access to the library in our project for now, but it is not an optimal solution. When targeting this branch bundle could begin failing if this branch were deleted from GitHub, or if the release were removed from the branch etc. In the short-term it would make sense to update the docs to reflect this usage, but long-term we would like to just target the gem version alone rather than listing the repository and branch as well.

@rgomezp
Copy link
Contributor

rgomezp commented Feb 25, 2022

@MattyCodes @FHappy,
Thanks for your patience.

I wanted to let you know that we merged the beta branch into main so you may want to update your dependency to use the main github branch.

That said, we haven't been able to reproduce this issue.

I think are related to how the library is registered with RubyGems
Can you expand on this a bit? You can see that the gem is there and I don't see anything "off" at first glance.

@FHappy, are you running into the same problem?

Cheers

@nickKolya
Copy link

@rgomezp looks like we have similar issues as well.

Problem with gem loading on test environment

It seems like we have the same issue with loading onesignal gem on our project only on test environment. After some time of investigation we figured out that the published version of gem 'onesignal', '~> 1.0.0.beta1' is different from the source code in the repo under 1.0.0.beta1 tag (take a look at the screenshots attached below, the issue is the difference between file names OneSignal.rb vs onesignal.rb). Could you publish the same version of the codebase to Rubygems as it's in the repo?

As a temporary fix we added the following line to our Gemfile so that it loads correct file:
gem 'onesignal', '~> 1.0.0.beta1', require: 'OneSignal'

image

image

Problem with file/constant naming

Also, I noticed that constant names doesn't correctly correspond to file names which theoretically might cause some issues for Zeitwerk file loader which was added by default starting from Rails 6. Due to the file structure they follow you either should use Onesignal constant everywhere or rename file paths to one_signal.rb, one_signal/ instead.

Thank you and let me know if you have any follow up questions!

@rgomezp
Copy link
Contributor

rgomezp commented Mar 23, 2022

@nickKolya ,
Thanks for the input! We will get this fixed

@rgomezp rgomezp added the bug label Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants