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

JRuby 9.1.2 / MacOS X / LoadError: no such file to load -- sinatra #4041

Closed
leleuj opened this issue Jul 29, 2016 · 4 comments
Closed

JRuby 9.1.2 / MacOS X / LoadError: no such file to load -- sinatra #4041

leleuj opened this issue Jul 29, 2016 · 4 comments

Comments

@leleuj
Copy link

leleuj commented Jul 29, 2016

Using JRuby to launch a very simple sinatra app, I get the following error:

$ jruby app.rb
LoadError: no such file to load -- sinatra
  require at org/jruby/RubyKernel.java:944
  require at /Users/bidou/tools/jruby-9.1.2.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55
    <top> at app.rb:1

app.rb:

require 'sinatra'

get '/' do
 "Hello World!"
end

My environment:

$ jruby -v
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [darwin-x86_64]
$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14.1
  - RUBY VERSION: 2.0.0 (2015-12-16 patchlevel 648) [universal.x86_64-darwin15]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-15
  - GEM PATHS:
     - /Library/Ruby/Gems/2.0.0
     - /Users/bidou/.gem/ruby/2.0.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

Yes, Sinatra is installed:

$ gem which sinatra
/Library/Ruby/Gems/2.0.0/gems/sinatra-1.4.7/lib/sinatra.rb

but:

$ jruby -S gem which sinatra
ERROR:  Can't find ruby library file or shared library sinatra

It works perfectly with: ruby app.rb:

$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
$ which -a ruby
/usr/bin/ruby

Adding: require 'rubygems' at the top of the app.rb file does not help, same error one line below:

$ jruby app.rb
LoadError: no such file to load -- sinatra
  require at org/jruby/RubyKernel.java:944
  require at /Users/bidou/tools/jruby-9.1.2.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55
    <top> at app.rb:2
@enebo
Copy link
Member

enebo commented Jul 29, 2016

Your problem is you do not have sinatra installed in a GEM directory JRuby knows about (and C Ruby and JRuby cannot share the same GEM dirs because JRuby uses Java native extensions and Ruby uses native C extensions). So if you:

jruby -S gem install sinatra

your app should run fine.

@enebo
Copy link
Member

enebo commented Jul 29, 2016

@leleuj I should add that your detailed report also shows you what is up. When you do raw ruby you get a C ruby and when you call gem by itself it uses that C Ruby. When you use JRuby -S you are hitting the right sutff for JRuby. If you want 'gem' to work you just need to put JRuby's bin dir higher in your path than any C Ruby (rvm or other ruby manager should also be able to manage this for you).

@leleuj
Copy link
Author

leleuj commented Jul 29, 2016

Many thanks. Just installed sinatra via jruby and it works (usr/bin is before ~/tools/jruby-9.1.2.0/bin in the PATH).

@leleuj leleuj closed this as completed Jul 29, 2016
@enebo enebo added this to the Invalid or Duplicate milestone Aug 26, 2016
@sixtyfive
Copy link

Not sure if this is an actual bug, so I'll post into this old one here first. What is going on here?

root@kadmosboxos:~/kadmos# jruby -S gem install multi_json
Successfully installed multi_json-1.13.1
1 gem installed
root@kadmosboxos:~/kadmos# jruby -J-Xmx1g -J-Dfile.encoding=UTF-8 lib/kadmos.rb
Loading Kadmos Version 0.0.21
/usr/share/jruby/lib/ruby/gems/shared/gems/naether-0.14.3-java/lib/naether/configuration.rb:25: warning: key (SymbolNode:version 28) is duplicated and overwritten on line 25
0    [main] INFO  com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration  - Generated unique-instance-id=7f0001016757-kadmosboxos1
31   [main] INFO  com.thinkaurelius.titan.diskstorage.Backend  - Configuring index [search]
67   [main] INFO  com.thinkaurelius.titan.diskstorage.Backend  - Initiated backend operations thread pool of size 4
120  [main] INFO  com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog  - Loaded unidentified ReadMarker start time Timepoint[1569334552335000 μs] into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller@66522ead
#<PacerGraph titangraph[berkeleyje:/root/kadmos/db/system]
"reader"
1
#<PacerGraph titangraph[berkeleyje:/root/kadmos/db/system]
"writer"
1
#<PacerGraph titangraph[berkeleyje:/root/kadmos/db/system]
"manager"
1
/root/kadmos/lib/kadmos/corpus_graphs.rb:11: warning: Dir.exists? is a deprecated name, use Dir.exist? instead
562  [main] INFO  com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration  - Generated unique-instance-id=7f0001016757-kadmosboxos2
571  [main] INFO  com.thinkaurelius.titan.diskstorage.Backend  - Configuring index [search]
576  [main] INFO  com.thinkaurelius.titan.diskstorage.Backend  - Initiated backend operations thread pool of size 4
585  [main] INFO  com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog  - Loaded unidentified ReadMarker start time Timepoint[1569334552801000 μs] into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller@39549f33
#<PacerGraph titangraph[berkeleyje:/root/kadmos/db/default/.]
"reader"
1
#<PacerGraph titangraph[berkeleyje:/root/kadmos/db/default/.]
"writer"
1
#<PacerGraph titangraph[berkeleyje:/root/kadmos/db/default/.]
"manager"
1
LoadError: no such file to load -- multi_json
  require at org/jruby/RubyKernel.java:955
   <main> at /root/kadmos/lib/kadmos/eventsource.rb:3
  require at org/jruby/RubyKernel.java:955
   (root) at uri:classloader:/jruby/kernel/kernel.rb:1
   <main> at lib/kadmos.rb:17

As you can see I installed multi_json exactly as recommended above. JRuby still doesn't see it, though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants