Unable to install rails with jRuby

前端 未结 3 582
挽巷
挽巷 2020-12-17 00:12

I am trying to install the rails with jRuby with the following command

jruby -S gem install rails -v 3.0.6

But stuck with the e

相关标签:
3条回答
  • 2020-12-17 00:41

    I had this problem just a bit ago, but it was with rspec. Try this:
    jruby --1.9 -S gem install rails -v 3.0.6

    This tells jruby to use the ruby 1.9 interpreter.

    0 讨论(0)
  • 2020-12-17 00:47

    This bug has been fixed in JRuby 1.6.2.

    Workaround for JRuby 1.6.1 on the command line (Windows):

    set JRUBY_OPTS=--1.9
    # in your specific case
    gem install rails   
    
    # this is where I got the error (Rails 3 with Bundler)
    bundle update
    
    0 讨论(0)
  • 2020-12-17 00:48

    This bug can happen with some versions of the gem you're installing, but not others. This is because the YAML error is due to the date field in the YAML file, as mentioned in this comment for bug 5581.

    For example, version 1.4.2 of the bio gem caused the exception for me.

    Instructions for how to get the metadata are from Shaving a YAML Yak, except I substituted gunzip and less for gzcat

    gem fetch bio --version 1.4.2
    tar xvf bio-1.4.2.gem
    gunzip metadata.gz
    less metadata | grep date
    date: 2011-08-26 00:00:00.000000000 Z
    
    YAML.load("date: 2011-08-26 00:00:00.000000000 Z") # Causes exception
    

    whereas for version 1.4.1 of bio

    gem fetch bio --version 1.4.1
    tar xvf bio-1.4.1.gem
    gunzip metadata.gz
    less metadata | grep date
    date: 2010-10-22 00:00:00 +09:00
    
    YAML.load("date: 2010-10-22 00:00:00 +09:00") # Doesn't cause an exception
    

    So doing sudo jruby -S gem install bio --version 1.4.1 worked for me.

    If you want the latest and greatest, then you could fetch the gem and modify its metadata, or build the gem yourself, but the above was Good Enough™ for me.

    0 讨论(0)
提交回复
热议问题