Search code examples
rubygemsjrubyrbenv

Bundle failing on JRuby with "TypeError: can't convert Regexp into String"


I've deployed a new server that has the exact same version of JRuby (1.7.22), Java (openjdk-7-jre-headless 7u51), and bundler as the other servers. Both servers are running Ubuntu 14.04, but the new one has some newer packages.

I deployed the same version of the project using Capistrano to the new server.

When Capistrano runs bundle (or when I do it myself), the following error and callstack are presented:

TypeError: can't convert Regexp into String
                 end_with? at org/jruby/RubyString.java:5281
                     path= at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/shared/rubygems/path_support.rb:62
                initialize at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/shared/rubygems/path_support.rb:35
                     paths at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/shared/rubygems.rb:329
                      path at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/shared/rubygems.rb:352
                      dirs at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/shared/rubygems/defaults/jruby.rb:84
                 stubs_for at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/shared/rubygems/specification.rb:850
                 find_name at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/bundler-1.10.6/lib/bundler/rubygems_integration.rb:639
                    report at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/bundler-1.10.6/lib/bundler/env.rb:23
                      each at org/jruby/RubyArray.java:1613
                    report at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/bundler-1.10.6/lib/bundler/env.rb:22
  request_issue_report_for at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:66
      with_friendly_errors at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:41
                    (root) at /usr/local/rbenv/versions/jruby-1.7.22/lib/ruby/gems/shared/gems/bundler-1.10.6/bin/bundle:18
                      load at org/jruby/RubyKernel.java:1059
                    (root) at /usr/local/rbenv/versions/jruby-1.7.22/bin/bundle:22

I've done some debugging, and for certain, Gem.path_separator is a Regexp. I did the same debugging with JRuby on my local machine, which has had the same version of JRuby installed for months, and while I can confirm that Gem.path_separator is a Regexp there too, I can't reproduce the issue.

I was able to get the server working by copying the entire /usr/local/rbenv/versions/jruby-1.7.22 folder from a working server.

I'm installing JRuby using rbenv, which is installed thusly: git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build. I reset the commit to be the same as the one on the older server, and after deleting the /usr/local/rbenv/versions/jruby-1.7.22 folder and reinstalling jruby, I still get the same result.

I see nothing on this server that should affect whether JRuby allows a Regex to match the end of a string.

Edit: Also want to add that the following is in the .jrubyrc file (which hasn't changed):

compat.version=2.0

Edit: I'm getting closer to an answer. Turns out the installation script I used had run gem update --system. The version of rubygems is different (2.4.8 vs 2.5.2). I'm working to see if a specific version of rubygems is broken.


Solution

  • I've confirmed, this is a problem with Rubygems 2.5.2. All versions up through 2.5.1 work correctly.

    I've not found a way to downgrade rubygems, so for me the solution is to reinstall jruby using rbenv and either leave rubygems alone, or if you need a newer version than the default, run:

    gem update --system 2.5.1