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

Returns LoadError (cannot load such file -- ibm_watson/authenticators): #85

Closed
drwhirst opened this issue Jan 16, 2020 · 11 comments
Closed
Labels
bug Something isn't working

Comments

@drwhirst
Copy link

drwhirst commented Jan 16, 2020

I am trying to test out watson NLU features, and I keep getting this error:

LoadError (cannot load such file -- ibm_watson/authenticators):
  
app/controllers/concerns/watson.rb:2:in `<module:Watson>'
app/controllers/concerns/watson.rb:1:in `<main>'
app/controllers/messages_controller.rb:2:in `<class:MessagesController>'
app/controllers/messages_controller.rb:1:in `<main>'
Started POST "/messages" for ::1 at 2020-01-16 14:57:36 -0500

My ruby version is 2.6.2 and I am running on Rails 6.0.1

Please help

the code is as follows:

require "ibm_watson/authenticators"
    require "ibm_watson/natural_language_understanding_v1"
    include IBMWatson

    def parse_messages()
        authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
            apikey: ENV['API_KEY'],
        )
         
        natural_language_understanding = NaturalLanguageUnderstandingV1.new(
            version: "2019-07-12",
            authenticator: authenticator
        )
        natural_language_understanding.service_url = ENV['API_URL']
        response = natural_language_understanding.analyze(
            url: "www.ibm.com",
            features: {categories: {limit:3}}
        )
        puts JSON.pretty_generate(response.result)
    end
@drwhirst drwhirst added the bug Something isn't working label Jan 16, 2020
@mamoonraja
Copy link
Member

Hi @drwhirst , Thanks for opening the issue, can you please confirm which version of Ruby SDK are you using?

@drwhirst
Copy link
Author

ibm_watson-0.20.1

@drwhirst
Copy link
Author

I resolved this issue by switching my ruby version from 2.6.2 to 2.6.0, as 2.6.2 isn't supported by the gem

@rafaltrojanowski
Copy link

rafaltrojanowski commented Feb 22, 2020

Same issue with ruby 2.6.3p62. Thanks for sharing @drwhirst

In my case downgrade to 2.6.0 didn't help. I had to use the latest master version of this gem to be able to run it with Rails 👍

Finally, I made it work with ruby 2.6.3p62

Gemfile:

gem 'ibm_watson', git: 'https://github.com/watson-developer-cloud/ruby-sdk', branch: 'master'

However, there were some problems with 'require_relative` on 2.7.0 with Rails 6.0:

24: from bin/rails:3:in `<main>'
	23: from bin/rails:3:in `require_relative'
(...)
.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require': no implicit conversion of String into Integer (TypeError)

@ajshemi
Copy link

ajshemi commented Feb 29, 2020

I wonder if a solution has been found for this load error issue

@mamoonraja
Copy link
Member

I see an issue on rails repo, It looks like the fix is to move to 6.0.x stable version. Which version are you using @ajshemi ?

@ajshemi
Copy link

ajshemi commented Feb 29, 2020

I am using ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin17]. is the version acceptable?

@ajshemi
Copy link

ajshemi commented Feb 29, 2020

It worked. I think I was missing the right apikey.

ruby version
ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]

my gemfile includes
ruby '2.6.1'
gem 'ibm_watson', '~> 1.3

@rafaltrojanowski
Copy link

rafaltrojanowski commented Mar 1, 2020

I can say that when I added your gem to Gemfile in that way:

gem 'ibm_watson'

it installed a version where authenticator was missing in the codebase, so that was the reason for the error from the title.

Not sure how many Rails Devs would use this gem but IMHO it would be good to add docs for installation with Rails, like:

gem 'ibm_watson', '~> 1.3'

Btw, thanks for a great gem!

@mamoonraja
Copy link
Member

@ajshemi Glad, it worked :)

Thanks, @rafaltrojanowski, Interesting why rails is not adding the recent version. We will look into adding additional instructions for people seeing this issue in rails. One additional issue with adding a specific version in the readme is that semantic release has to update readme too. Anyways we will update the instructions soon :)

@Mikemosca
Copy link
Contributor

talked with @mamoonraja and will we close this one for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

5 participants