How to run Ruby 2.0 with JRuby 1.7?
For a specific script, you can use the --2.0
option:
jruby --2.0 -S rails s
For setting 2.0 as the default value, set JRUBY_OPTS
:
export JRUBY_OPTS=--2.0
You can also set the value in ~/.jrubyrc
:
compat.version=2.0
Strange meaning of || and ||= in Ruby (2.0, 1.9.3, jruby 1.7.4)
I don't know if it is desirable, but it comes from how Ruby parses the code. Whenever you have a piece of code that assigns a local variable, that local variable is assigned nil
even if that piece of code is not evaluated. In your code line 2:
baz || baz = 0
the first baz
returned an error because no such variable was assigned. Hence the assignment baz = 0
that follows it was not evaluated, but nevertheless it was parsed, so in the context to follow, a local variable baz
was created, and is initialized to nil
.
With your second code chunk, foo
is not assigned during true if foo
and foo
. After that, foo = (true if foo)
has an assignment to foo
, so even though (true if foo)
is evaluated before assigment of foo
, an error is not raised in that line.
How to make JRuby 1.6 default to Ruby 1.9?
Use the JRUBY_OPTS
environment variable. JRUBY_OPTS
holds a list of arguments that are added to any arguments specified on the command line.
For example (on Linux):
$ jruby -v
jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-10 769f847) (Java HotSp...
$ export JRUBY_OPTS=--1.9
$ jruby -v
jruby 1.6.0.RC1 (ruby 1.9.2 trunk 136) (2011-01-10 769f847) (Java HotSpot(TM...
$ export JRUBY_OPTS=--1.8
$ jruby -v
jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-10 769f847) (Java HotSpo...
Failed to build native gem extension - Rails Install
I solved the problem.
Turns out I was using an outdated version of gems.
Once I upgraded my gems to the latest version it worked fine.
Thanks everyone!
How to build JRuby 1.7.13 on Raspberry Pi with rbenv/ruby-build?
I believe the answer is to compile JFFI on the Raspberry Pi and copy the generated libjffi-1.2.so to /usr/lib. When I now try to install JRuby 1.7.13 using rbenv, I no longer get the missing FFI error but "Cannot allocate memory" errors.
The procedure I followed to compile libjffi was;
cd ~
pi@raspberrypi:~$ git clone git://github.com/jnr/jffi.git jffi.git
cd jffi.git
ant jar
sudo cp libjffi-1.2.so /usr/lib
Related Topics
How to Tell Rubocop to Ignore a Specific Directory or File
Getting Devise Sign_In Form into Twitter Bootstrap Modal
How to Define a Ruby Singleton Method Using a Block
How to Access Firefox Extension I Added in Selenium Webdriver
How to Tokenize This String in Ruby
How to Prevent Pipe Character from Causing a Bad Uri Error in Rails 3/Ruby 1.9.2
Can't Enter Umlauts in Ruby 1.9.3 Irb
Remove "Www", "Http://" from String
Check If String Contains Any Substring in an Array in Ruby
Ruby Convert String to Method Name
How to Get an Empty Temporary Directory in Ruby on Rails
Converting Date Object to Timewithzone