weixin_39738152
weixin_39738152
2021-01-12 05:22

bundle exec always tries to use Jruby

Good evening.

I've moved from rvm to chruby for switching between Jruby and MRI on two completely different projects. The Jruby/Rails 4 stuff works great (bin/rails bin/rake etc.)

My MRI/Rails 3.2 will bundle install fine but using bundle exec rake routes (for example blows up with:


$ chruby
   jruby-1.7.4
 * ruby-1.9.3-p448
$ which bundle
/opt/rubies/ruby-1.9.3-p448/bin/bundle
$ bundle exec rake routes
rake aborted!
no such file to load -- pg_ext
org/jruby/RubyKernel.java:1054:in `require'
/Users/Reid/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg.rb:4:in `(root)'
org/jruby/RubyKernel.java:1054:in `require'
[...]

Which looks like it is trying to load the Jruby gems. Even more strange is that POW loads the correct gems and works just fine. If I remove the exports needed for torquebox in the Jruby app here is what I get in the MRI app:


$ bundle exec rake routes
env: jruby: No such file or directory

The bundle env for the MRI app:


Bundler 1.3.5
Ruby 1.9.3 (2013-06-27 patchlevel 448) [x86_64-darwin12.4.0]
Rubygems 1.8.23
GEM_HOME /Users/Reid/.gem/ruby/1.9.3
GEM_PATH /Users/Reid/.gem/ruby/1.9.3:/opt/rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1


Gemfile
source 'https://rubygems.org'

ruby '1.9.3'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'pg'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'bootstrap-sass'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
gem 'unicorn'

# Deploy with Capistrano
gem 'capistrano'
gem 'rvm-capistrano'

gem 'newrelic_rpm'

# To use debugger
# gem 'debugger'

gem 'simple_form'

gem 'devise'
gem 'mailman', require: false
gem 'daemons'
gem 'google_calendar'

gem 'foreman'


Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.13)
      actionpack (= 3.2.13)
      mail (~> 2.5.3)
    actionpack (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activemodel (3.2.13)
      activesupport (= 3.2.13)
      builder (~> 3.0.0)
    activerecord (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
    activesupport (3.2.13)
      i18n (= 0.6.1)
      multi_json (~> 1.0)
    addressable (2.3.4)
    arel (3.0.2)
    bcrypt-ruby (3.0.1)
    bcrypt-ruby (3.0.1-java)
    bootstrap-sass (2.3.1.0)
      sass (~> 3.2)
    builder (3.0.4)
    capistrano (2.15.4)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.1.0)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.2)
    daemons (1.1.9)
    devise (2.2.3)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (~> 3.1)
      warden (~> 1.2.1)
    dotenv (0.8.0)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    ffi (1.8.1)
    ffi (1.8.1-java)
    foreman (0.63.0)
      dotenv (>= 0.7)
      thor (>= 0.13.6)
    foreman (0.63.0-java)
      dotenv (>= 0.7)
      thor (>= 0.13.6)
    google_calendar (0.3.0)
      addressable (>= 2.2.2)
      nokogiri (>= 1.4.4)
    highline (1.6.19)
    hike (1.2.2)
    i18n (0.6.1)
    journey (1.0.4)
    jquery-rails (2.2.1)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.7.7)
    json (1.7.7-java)
    kgio (2.8.0)
    listen (1.1.1)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
      rb-kqueue (>= 0.2)
    mail (2.5.3)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    maildir (2.1.0)
    mailman (0.6.0)
      activesupport (>= 2.3.4)
      i18n (>= 0.4.1)
      listen (>= 0.4.1)
      mail (>= 2.0.3)
      maildir (>= 0.5.0)
    mime-types (1.23)
    multi_json (1.7.2)
    net-scp (1.1.1)
      net-ssh (>= 2.6.5)
    net-sftp (2.1.2)
      net-ssh (>= 2.6.5)
    net-ssh (2.6.7)
    net-ssh-gateway (1.2.0)
      net-ssh (>= 2.6.5)
    newrelic_rpm (3.6.3.111)
    nokogiri (1.5.9)
    nokogiri (1.5.9-java)
    orm_adapter (0.4.0)
    pg (0.15.1)
    polyglot (0.3.3)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.13)
      actionmailer (= 3.2.13)
      actionpack (= 3.2.13)
      activerecord (= 3.2.13)
      activeresource (= 3.2.13)
      activesupport (= 3.2.13)
      bundler (~> 1.0)
      railties (= 3.2.13)
    railties (3.2.13)
      actionpack (= 3.2.13)
      activesupport (= 3.2.13)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    raindrops (0.11.0)
    rake (10.0.4)
    rb-fsevent (0.9.3)
    rb-inotify (0.9.0)
      ffi (>= 0.5.0)
    rb-kqueue (0.2.0)
      ffi (>= 0.5.0)
    rdoc (3.12.2)
      json (~> 1.4)
    rvm-capistrano (1.3.0)
      capistrano (>= 2.0.0)
    sass (3.2.8)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    simple_form (2.1.0)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    thor (0.18.1)
    tilt (1.3.7)
    treetop (1.4.12)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.37)
    uglifier (2.0.1)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    unicorn (4.6.2)
      kgio (~> 2.6)
      rack
      raindrops (~> 0.7)
    warden (1.2.1)
      rack (>= 1.0)

PLATFORMS
  java
  ruby

DEPENDENCIES
  bootstrap-sass
  capistrano
  coffee-rails (~> 3.2.1)
  daemons
  devise
  foreman
  google_calendar
  jquery-rails
  mailman
  newrelic_rpm
  pg
  rails (= 3.2.13)
  rvm-capistrano
  sass-rails (~> 3.2.3)
  simple_form
  uglifier (>= 1.0.3)
  unicorn

I've been fighting with this for a few evenings now so any help/suggestions would be greatly appreciated. I'm happy to provide any additional info that would be useful.

该提问来源于开源项目:rubygems/bundler

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

6条回答

  • weixin_39598941 weixin_39598941 4月前

    Can you please add the output from head -1 $(bundle exec which rake)?

    点赞 评论 复制链接分享
  • weixin_39738152 weixin_39738152 4月前

    Output from the MRI project:

    
    $ chruby
       jruby-1.7.4
     * ruby-1.9.3-p448
    $ head -1 $(bundle exec which rake)
    #!/usr/bin/env jruby
    
    点赞 评论 复制链接分享
  • weixin_39856208 weixin_39856208 4月前

    Your bundle command is probably hardcoded to use jRuby. Check with head -1 $(which bundle).

    On Aug 8, 2013, at 7:16 AM, Reid Gillette notifications.com wrote:

    Output from the MRI project:

    $ chruby jruby-1.7.4 - ruby-1.9.3-p448 $ head -1 $(bundle exec which rake) #!/usr/bin/env jruby — Reply to this email directly or view it on GitHub.

    点赞 评论 复制链接分享
  • weixin_39738152 weixin_39738152 4月前

    Here's that output. Was kinda expecting that to point to Jruby...

    
    $ chruby
       jruby-1.7.4
     * ruby-1.9.3-p448
    $ head -1 $(which bundle)
    #!/opt/rubies/ruby-1.9.3-p448/bin/ruby
    

    I have tried removing the dirs as listed in the troubleshooting section as well as tried reinstalling rubies/gems short of a full on nuke-and-pave. I did just switch to chruby from RVM, could there be some sort of remnants of that getting confused.

    (Also, sorry for the chruby lines in the output. I've been including them to keep me honest so I can be sure I am using the correct dir.)

    点赞 评论 复制链接分享
  • weixin_39598941 weixin_39598941 4月前

    The output from head -1 $(bundle exec which rake) indicates that rake has jruby hardcoded, so even when bundle is running under MRI, rake is still trying to launch JRuby.

    I think you'll be able to solve that by reinstalling Rake (or removing it with gem uninstall rake and then reinstalling via bundle install). Then the question is, how did it get that way in the first place? Are your JRuby gems and MRI gems installing to the same directory? Do you know how GEM_HOME is getting set to /Users/Reid/.gem/ruby/1.9.3?

    点赞 评论 复制链接分享
  • weixin_39738152 weixin_39738152 4月前

    That was it. Uninstalling rake (which I thought I had tried already) and then bundling got it.

    I'm not sure how it got into this state in the first place. I switched from RVM to chruby because of some strange behavior with RVM and jruby so perhaps this was left over from that problem. Regardless, thanks for your help troubleshooting, and

    点赞 评论 复制链接分享

相关推荐