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

Bundler error on 9.0.0.0 #3216

Closed
Ch4s3 opened this issue Aug 3, 2015 · 10 comments
Closed

Bundler error on 9.0.0.0 #3216

Ch4s3 opened this issue Aug 3, 2015 · 10 comments

Comments

@Ch4s3
Copy link

Ch4s3 commented Aug 3, 2015

Not sure if this is a bundler or jRuby issue, but it seems like there's an issue in uri/classloader when I run jruby -S bundle install --deployment.

jruby -S bundle install --deployment
 ---> Running in ff7de2a2aa10
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
--- ERROR REPORT TEMPLATE -------------------------------------------------------
- What did you do?

  I ran the command `uri:classloader:/bin/bundle install --deployment`

- What did you expect to happen?

  I expected Bundler to...

- What happened instead?

  Instead, what actually happened was...


Error details

    Java::JavaLang::NullPointerException:
      org.jruby.util.io.PosixShim.write(PosixShim.java:92)
      org.jruby.util.io.OpenFile.flushBufferSync(OpenFile.java:573)
      org.jruby.util.io.OpenFile.flushBufferSync2(OpenFile.java:564)
      org.jruby.util.io.OpenFile.flushBufferAsync2(OpenFile.java:557)
      org.jruby.util.io.OpenFile.flushBuffer(OpenFile.java:550)
      org.jruby.util.io.OpenFile.io_fflush(OpenFile.java:426)
      org.jruby.util.io.OpenFile.finalize(OpenFile.java:860)
      org.jruby.util.io.OpenFile.cleanup(OpenFile.java:803)
      org.jruby.RubyIO.rbIoClose(RubyIO.java:2008)
      org.jruby.RubyFile.rbIoClose(RubyFile.java:276)
      org.jruby.RubyIO.close(RubyIO.java:1956)
<rest of trace removed>

Environment

    Bundler   1.10.6
    Rubygems  2.4.8
    Ruby      2.2.2p0 (2015-07-21 revision 50293) [java]
    GEM_HOME  /usr/local/bundle
    GEM_PATH
    Git       1.9.1

Bundler settings

    path
      Set for the current user (/root/.bundle/config): "/usr/local/bundle"
    bin
      Set for the current user (/root/.bundle/config): "/usr/local/bundle/bin"
    frozen
      Set for your local app (uri:classloader://.bundle/config): "1"
    gemfile
      Set via BUNDLE_GEMFILE: "uri:classloader://Gemfile"
--- TEMPLATE END ----------------------------------------------------------------

Unfortunately, an unexpected error occurred, and Bundler cannot continue.
NoMethodError: undefined method `chomp' for nil:NilClass
                issues_url at /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:85
  request_issue_report_for at /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:76
      with_friendly_errors at /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:41
                     <top> at /usr/local/bundle/gems/bundler-1.10.6/bin/bundle:18
                      load at org/jruby/RubyKernel.java:958
                     <top> at uri:classloader:/bin/bundle:3
@headius
Copy link
Member

headius commented Aug 6, 2015

Ick, that's not good. Investigating.

@headius
Copy link
Member

headius commented Aug 6, 2015

Ok, after a quick examination, it appears that an IO stream that's not writable is getting write data buffered into it somehow. When the stream goes to close, it assumes the write buffer's content means the stream is writable and proceeds to try to write; however, the write stream is null and the code blows up.

I'll try to reproduce. Do you have a Gemfile that reproduces this consistently that you can share with us?

@headius
Copy link
Member

headius commented Aug 6, 2015

So far I can't reproduce this with e.g. a new Rails app. I can add a safety check into the flushing logic to make sure it doesn't try to flush this stream, but I'd like to know how write data is getting into the write buffer for an unwritable stream.

Hopefully you can share something with us that reproduces this.

@gordrs
Copy link

gordrs commented Aug 6, 2015

I've managed to (unintentionally) reproduce this whilst setting up a new Rails project on JRuby. Gemfile is just a standard one that's generated with a new Rails project on Rails version 4.1.12 with two additions to it such as the jdbc gem and warbler. I've included it here.

I should point out, I did not use --deployment

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.12'
# Use jdbcsqlite3 as the database for Active Record
gem 'activerecord-jdbcsqlite3-adapter'
# Postgresql stuff
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyrhino'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',                              group: :doc

gem 'warbler'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

Exact same thing happened.

Error details

    Java::JavaLang::NullPointerException:
      org.jruby.util.io.PosixShim.write(PosixShim.java:92)
      org.jruby.util.io.OpenFile.flushBufferSync(OpenFile.java:573)
      org.jruby.util.io.OpenFile.flushBufferSync2(OpenFile.java:564)
      org.jruby.util.io.OpenFile.flushBufferAsync2(OpenFile.java:557)
      org.jruby.util.io.OpenFile.flushBuffer(OpenFile.java:550)
      org.jruby.util.io.OpenFile.io_fflush(OpenFile.java:426)
      org.jruby.util.io.OpenFile.finalize(OpenFile.java:860)
      org.jruby.util.io.OpenFile.cleanup(OpenFile.java:803)
      org.jruby.RubyIO.rbIoClose(RubyIO.java:2008)
      org.jruby.RubyFile.rbIoClose(RubyFile.java:276)
      org.jruby.RubyIO.close(RubyIO.java:1956)
      org.jruby.RubyIO$INVOKER$i$0$0$close.call(RubyIO$INVOKER$i$0$0$close.gen)
      org.jruby.RubyClass.finvokeChecked(RubyClass.java:634)
      org.jruby.runtime.Helpers.invokeChecked(Helpers.java:447)
      org.jruby.RubyBasicObject.checkCallMethod(RubyBasicObject.java:357)
      org.jruby.RubyIO.ioClose(RubyIO.java:1966)
      org.jruby.RubyIO.ensureYieldClose(RubyIO.java:1135)
      org.jruby.RubyIO.open(RubyIO.java:1126)
<truncated>

Environment

    Bundler   1.10.6
    Rubygems  2.4.8
    Ruby      2.2.2p0 (2015-07-21 revision 50293) [java]
    GEM_HOME  /home/grs/.rvm/gems/jruby-9.0.0.0
    GEM_PATH  /home/grs/.rvm/gems/jruby-9.0.0.0:/home/grs/.rvm/gems/jruby-9.0.0.0@global
    RVM       1.26.11 (master)
    Git       2.1.0
    rubygems-bundler (1.4.4)

Bundler settings

    gemfile
      Set via BUNDLE_GEMFILE: "uri:classloader://Gemfile"

@mkristian
Copy link
Member

I did look into this a bit before - at least it sounds familiar. the write
comes into play when bundler tries to tries to write out Gemfile.lock.

the last line says: Set via BUNDLE_GEMFILE: "uri:classloader://Gemfile"
i.e. the lock-file would be uri:classloader://Gemfile.lock which is per
definition not writeable.

On Thu, Aug 6, 2015 at 11:58 PM, Gordon Robert Speirs <
notifications@github.com> wrote:

I've managed to (unintentionally) reproduce this whilst setting up a new
Rails project on JRuby. Gemfile is just a standard one that's generated
with a new Rails project on Rails version 4.1.12 with two additions to it
such as the jdbc gem and warbler. I've included it here.

source 'https://rubygems.org'

Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

gem 'rails', '4.1.12'

Use jdbcsqlite3 as the database for Active Record

gem 'activerecord-jdbcsqlite3-adapter'

Postgresql stuff

gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby

Use SCSS for stylesheets

gem 'sass-rails', '~> 4.0.3'

Use Uglifier as compressor for JavaScript assets

gem 'uglifier', '>= 1.3.0'

Use CoffeeScript for .js.coffee assets and views

gem 'coffee-rails', '~> 4.0.0'

See https://github.com/rails/execjs#readme for more supported runtimes

gem 'therubyrhino'

Use jquery as the JavaScript library

gem 'jquery-rails'

Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks

gem 'turbolinks'

Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder

gem 'jbuilder', '~> 2.0'

bundle exec rake doc:rails generates the API under doc/api.

gem 'sdoc', '~> 0.4.0', group: :doc

gem 'warbler'

Use ActiveModel has_secure_password

gem 'bcrypt', '~> 3.1.7'

Use unicorn as the app server

gem 'unicorn'

Use Capistrano for deployment

gem 'capistrano-rails', group: :development

Exact same thing happened.

Error details

Java::JavaLang::NullPointerException:
  org.jruby.util.io.PosixShim.write(PosixShim.java:92)
  org.jruby.util.io.OpenFile.flushBufferSync(OpenFile.java:573)
  org.jruby.util.io.OpenFile.flushBufferSync2(OpenFile.java:564)
  org.jruby.util.io.OpenFile.flushBufferAsync2(OpenFile.java:557)
  org.jruby.util.io.OpenFile.flushBuffer(OpenFile.java:550)
  org.jruby.util.io.OpenFile.io_fflush(OpenFile.java:426)
  org.jruby.util.io.OpenFile.finalize(OpenFile.java:860)
  org.jruby.util.io.OpenFile.cleanup(OpenFile.java:803)
  org.jruby.RubyIO.rbIoClose(RubyIO.java:2008)
  org.jruby.RubyFile.rbIoClose(RubyFile.java:276)
  org.jruby.RubyIO.close(RubyIO.java:1956)
  org.jruby.RubyIO$INVOKER$i$0$0$close.call(RubyIO$INVOKER$i$0$0$close.gen)
  org.jruby.RubyClass.finvokeChecked(RubyClass.java:634)
  org.jruby.runtime.Helpers.invokeChecked(Helpers.java:447)
  org.jruby.RubyBasicObject.checkCallMethod(RubyBasicObject.java:357)
  org.jruby.RubyIO.ioClose(RubyIO.java:1966)
  org.jruby.RubyIO.ensureYieldClose(RubyIO.java:1135)
  org.jruby.RubyIO.open(RubyIO.java:1126)

Environment

Bundler   1.10.6
Rubygems  2.4.8
Ruby      2.2.2p0 (2015-07-21 revision 50293) [java]
GEM_HOME  /home/grs/.rvm/gems/jruby-9.0.0.0
GEM_PATH  /home/grs/.rvm/gems/jruby-9.0.0.0:/home/grs/.rvm/gems/jruby-9.0.0.0@global
RVM       1.26.11 (master)
Git       2.1.0
rubygems-bundler (1.4.4)

Bundler settings

gemfile
  Set via BUNDLE_GEMFILE: "uri:classloader://Gemfile"


Reply to this email directly or view it on GitHub
#3216 (comment).

mkristian added a commit that referenced this issue Aug 7, 2015
…ted as files

jruby always looks on classpath in 'bin' for executables but finding
it there leads to uri:classloader:/bin/rails which can have side effects.
looking first on the filesystem ./bin will find bin/rails instead.

fixes #3233 and partially #3216

Sponsored by Lookout Inc.
@mkristian
Copy link
Member

workaround for the bundler issue: remove bin/bundler from the rails application
or use rbenv instead of rvm

it is rvm only issue as far I can tell.

the above fix solves the actual problem BUT not the error when bundler tries to update Gemfile.lock inside a classloader.

@Ch4s3
Copy link
Author

Ch4s3 commented Aug 7, 2015

@headius Sorry I missed the request for a gemfile. Here are the (seemingly) relevant parts.

source "https://rubygems.org"

# Bundle edge Rails instead: gem "rails", github: "rails/rails"
gem "rails", "4.1.12"

platform :jruby do
  gem "activerecord-jdbcpostgresql-adapter"
  gem "jruby-openssl"
end

platform :ruby do
  gem "concurrent-ruby-ext", "~> 0.9.0"
  gem "pg"
  gem "simplecov", require: false, group: :test
end

gem "concurrent-ruby", "~> 0.9.0", require: false
gem "nokogiri", require: false

source "https://rails-assets.org" do
  gem "rails-assets-elasticsearch"
end

group :development do
  gem "better_errors"
  gem "binding_of_caller", "0.7.3.pre1"
  gem "rack-mini-profiler"
end

group :development, :test do
  gem "awesome_print"
  gem "bundler-audit", require: false
  gem "hirb"
  gem "pry-rails"
  gem "pry-stack_explorer"
  gem "rspec-rails"
end

group :test do
  gem "capybara"
  gem "connection_pool"
  gem "email_spec"
  gem "fabrication"
  gem "factory_girl_rails"
  gem "poltergeist"
  gem "rspec-its"
  gem "shoulda-matchers", require: false
  gem "timecop"
  gem "vcr"
  gem "webmock"
end

Some random ui gems and misc are omitted for brevity. I've managed to circumvent it on docker by running:

RUN echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc
RUN gem install bundler
ENV RAILS_ENV production
RUN bundle config --global --jobs 4
RUN bundle install --deployment --without test development

@gordrs
Copy link

gordrs commented Aug 7, 2015

@mkristian Confirmed, removing bin/bundle from the rails directory took care of the problem.

Thanks so much for the workaround!

@donv
Copy link
Member

donv commented Aug 7, 2015

Other workarounds include using the path to the binary bin/bundle or using jruby-head from RVM.

The problem is not specific to RVM. Using the tarball for JRuby 9.0.0.0 from http://jruby.org/ also gives the same problem.

Thanks @mkristian for the fix!

mkristian added a commit that referenced this issue Aug 10, 2015
…ted as files

jruby always looks on classpath in 'bin' for executables but finding
it there leads to uri:classloader:/bin/rails which can have side effects.
looking first on the filesystem ./bin will find bin/rails instead.

fixes #3233 and partially #3216

Sponsored by Lookout Inc.
@kares
Copy link
Member

kares commented Jun 11, 2018

defunct/resolved by now

@kares kares closed this as completed Jun 11, 2018
@kares kares added this to the JRuby 9.0.3.0 milestone Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants