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

Using Solargraph with JRuby and Bundler #128

Closed
AprilArcus opened this issue Dec 30, 2018 · 2 comments
Closed

Using Solargraph with JRuby and Bundler #128

AprilArcus opened this issue Dec 30, 2018 · 2 comments

Comments

@AprilArcus
Copy link

This is more of a support request than a bug, so please forgive me if this is not the appropriate place to open this conversation. My project uses jruby as its runtime, and bundler to manage gems. The documentation is clear enough that I can install the solargraph gem into my bundle in order to access completions for my gems, but if I do this then I end up adding the long startup time of jruby to the startup time of my text editor.

So, my question: is there a way to run solargraph inside YARV ruby (to benefit from the faster startup time), while retaining access to documentation from gems in a gemfile marked for use with jruby?

@castwide
Copy link
Owner

As far as I'm concerned, GitHub is an appropriate place for any bug reports, feature requests, or technical support questions for any of my public projects. Thanks for your participation. Bringing it here can help other people with similar issues.

Solargraph shouldn't care if it uses a different Ruby runtime from the software you're developing, e.g., JRuby vs. MRI vs. Rubinius vs. whatever. The biggest issue here is making sure it has access to the same gems. (Compatibility issues are possible but should be uncommon.) One thing to remember: run yardoc gems in whichever Ruby environment Solargraph uses to make sure the gems are documented.

Since your Gemfile is marked for use with JRuby, you might need to jump through a couple extra hoops to get the same gems installed in YARV. If nothing else, you could manually run gem install for each dependency.

Anything I missed or failed to answer, or anything not working as expected, please let me know.

@castwide castwide reopened this Dec 30, 2018
@drkstr101
Copy link

drkstr101 commented Aug 28, 2023

Anything I missed or failed to answer, or anything not working as expected, please let me know.

It is very common for gems that depend on native extensions to break in jruby.

see: https://github.com/jruby/jruby/wiki/C-Extension-Alternatives

Output from gem install solargraph

Building native extensions. This could take a while...
ERROR:  Error installing solargraph:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/jruby-9.4.3.0/gems/rbs-2.8.4/ext/rbs_extension
/usr/local/rvm/rubies/jruby-9.4.3.0/bin/jruby -I /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib extconf.rb
checking for whether -std=gnu99 is accepted as CFLAGS... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/local/rvm/rubies/jruby-9.4.3.0/bin/jruby
RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.

         try_do at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:456
    try_compile at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:571
    with_werror at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:522
    try_compile at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:571
     try_cflags at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:635
  append_cflags at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:641
   checking_for at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:942
       postpone at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:350
           open at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:320
       postpone at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:350
           open at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:320
       postpone at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:346
   checking_for at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:941
  append_cflags at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:640
           each at org/jruby/RubyArray.java:1989
  append_cflags at /usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/stdlib/mkmf.rb:639
         <main> at extconf.rb:3

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/rvm/gems/jruby-9.4.3.0/extensions/universal-java-11/3.1.0/rbs-2.8.4/mkmf.log

extconf failed, exit code 1

/usr/local/rvm/gems/jruby-9.4.3.0/extensions/universal-java-11/3.1.0/rbs-2.8.4/mkmf.log

" -o conftest -I/include/universal-java11 -I/usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/include/ruby/backward -I/usr/local/rvm/rubies/jruby-9.4.3.0/lib/ruby/include -I.     -fno-omit-frame-pointer -fno-strict-aliasing  -fexceptions  conftest.c  -L. -L/usr/local/rvm/rubies/jruby-9.4.3.0/lib         "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <ruby.h>
4: int main(int argc, char **argv)
5: {
6:   return 0;
7: }
/* end */

Output from ruby --version:

jruby 9.4.3.0 (3.1.4) 2023-06-07 3086960792 OpenJDK 64-Bit Server VM 11.0.18+10-post-Debian-1deb11u1 on 11.0.18+10-post-Debian-1deb11u1 +jit [aarch64-linux]

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