SciRuby / iruby

Official gem repository: Ruby kernel for Jupyter/IPython Notebook
https://github.com/SciRuby/iruby
MIT License
901 stars 29 forks source link

Load Error while including "local" gem file #275

Open KamalPatel365 opened 4 years ago

KamalPatel365 commented 4 years ago
LoadError: cannot load such file -- payapi_client
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
<main>:2:in `<main>'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/lib/iruby/backend.rb:44:in `eval'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/lib/iruby/backend.rb:44:in `eval'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/lib/iruby/backend.rb:12:in `eval'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:90:in `execute_request'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:49:in `dispatch'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:38:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/lib/iruby/command.rb:110:in `run_kernel'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/lib/iruby/command.rb:40:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/iruby-0.4.0/bin/iruby:5:in `<top (required)>'
/usr/local/bin/iruby:23:in `load'
/usr/local/bin/iruby:23:in `<main>'

### Below is the version of Ruby and RubyGem:

$ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] $bundle -v Bundler version 1.17.3 $gem -v 3.0.3

KamalPatel365 commented 4 years ago

Anyone any suggestion on this @kojix2

kojix2 commented 4 years ago

Well, there have been a lot of troubles reported about bundler in the past... A number of contributors have tried to solve these problems. However, even today, IRuby is not fully integrated with bundler. That's why I was hesitant to reply.

So I'm going to ask a few additional questions, even though I may not be able to solve this problem...

  1. Have you run the bundle install command yet?
  2. Is payapi_client your original gem? Perhaps it's some kind of API client you make to get data from the web service, and that hasn't been open-sourced yet?
  3. Can you call gems other than payapi_client with bundler in Jupyter? I mean, is this problem specific to payapi_client? Or you can not call all the other gem?
  4. Can you call payapi_client with bundle exec irb -r payapi_clinet ? I mean, is this problem specific to IRuby and you can call payapi_client in irb console?
  5. Which do you use? jupyter lab or jupyter notebook or other consoles?
  6. Do you use IRuby with Rails or not?
KamalPatel365 commented 4 years ago

@kojix2 Answer to your question

  1. I executed 'bundle install' but it didn't resolve the error.
  2. Yes 'payapi_client' is original gem and its not opensource. It is local gem.
  3. Yes I am able to call open source and from gem repository but error arises when I tried calling local gem using 'require'
  4. Its issue with 'IRuby'
  5. I am using 'Jupyter Notebook'.
  6. I am using 'IRuby' not rails.
olleolleolle commented 4 years ago

$LOAD_PATH is a Ruby array of paths to look for files to ’require‘ in. Does your path show up in that array? If not, can you add it, and work around your issue?

KamalPatel365 commented 4 years ago

Ok I will try this. Thanks @olleolleolle

kojix2 commented 4 years ago

It was not reproduced in the latest environment. IRuby 0.4.0 and Ruby 2.7.1

As @olleolleolle suggests, you should check p $LOAD_PATH to see if bundler adds the load path correctly.

KamalPatel365 commented 4 years ago

Ok @kojix2 I will do this

ankane commented 3 years ago

Hey @KamalPatel365, I couldn't tell if you've already tried this, but this seems to work for me for local gems with iRuby.

In Gemfile:

gem 'payapi_client', path: 'path/to/payapi_client'

In notebook:

# require all gems
Bundler.require
# or require individually
require "payapi_client"