So, I have rvm installed on my machine, and I type:
rvm install jruby
Everything looks good at first, but eventually I get:
jruby-1.5.6 - #fetching
jruby-1.5.6 - #extracted to /home/jenny/.rvm/src/jruby-1.5.6 (already extracted)
Building Nailgun
jruby-1.5.6 - #installing to /home/jenny/.rvm/rubies/jruby-1.5.6
jruby-1.5.6 - #importing default gemsets (/home/jenny/.rvm/gemsets/)
Copying across included gems
Exception in thread "main" java.lang.NoClassDefFoundError: org.jruby.Main
at gnu.java.lang.MainThread.run(libgcj.so.9)
Caused by: java.lang.ClassNotFoundException: org.jruby.Main not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.9)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.9)
at java.lang.ClassLoader.loadClass(libgcj.so.9)
at java.lang.ClassLoader.loadClass(libgcj.so.9)
at gnu.java.lang.MainThread.run(libgcj.so.9)
jenny#linux-auvv:~/workspace/pcms_stable>
I have absolutly no context for debugging this... I honestly have no idea what to do...
I'm on OpenSuse, and when I type "java -version", I get:
java version "1.6.0_0"
OpenJDK Runtime Environment (build 1.6.0_0-b11)
OpenJDK Server VM (build 1.6.0_0-b11, mixed mode)
I can't see any references to java requirements for JRuby, though...
As far as RVM, I'm running:
rvm 1.2.4 by Wayne E. Seguin (wayneeseguin#gmail.com) [http://rvm.beginrescueend.com/]
I can install other rubies with RVM (1.9.2, 1.8.7, that sort of thing) with no problem, this is the first issue I've ever found.
It doesn't seem to matter WHICH jruby I install, either. My rvm knows about:
# JRuby
jruby-1.2.0
jruby-1.3.1
jruby-1.4.0
jruby[-1.5.6]
jruby-head
I don't even get the same errors for each one of them:
For 1.2.0, 1.3.1, 1.4.0 I get:
Fatal: GCJ (GNU Compiler for Java) is not supported by JRuby.
Where 1.5.6 and head get me the error I mentioned first.
I WANT to use JRuby with Rails 3, so I'm figuring I want the newest version I can get (which is having the exceptions)
Is there ANYTHING I can do, or am I just doomed to not be able to use RVM for my purposes?
EDIT:
I have confirmed that it's not just RVM, it is JRuby that is to blame. To test, I downloaded JRuby without rvm at all, through the website (I chose version 1.6). I unpacked it as per the instructions, and typed:
bin/jruby -v
in the extracted directory.
I got the exact same error:
jenny#linux-auvv:~/jruby-1.6.0.RC1> bin/jruby -v
Exception in thread "main" java.lang.NoClassDefFoundError: org.jruby.Main
at gnu.java.lang.MainThread.run(libgcj.so.9)
Caused by: java.lang.ClassNotFoundException: org.jruby.Main not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.9)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.9)
at java.lang.ClassLoader.loadClass(libgcj.so.9)
at java.lang.ClassLoader.loadClass(libgcj.so.9)
at gnu.java.lang.MainThread.run(libgcj.so.9)
So, still have no clue what's going on, but at least I know now it's a jruby issue, and not an rvm one (though I still WANT it installed through rvm)
Edit:
So, I tried updating my OpenJDK, and it was no dice, but I found ANOTHER version of OpenJDK (that I didn't have installed) through YAST, and installed THAT one, and suddenly my manually installed jruby works just fine:
jenny#linux-auvv:~/jruby-1.6.0.RC1> bin/jruby -v
jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-10 769f847) (OpenJDK Client VM 1.6.0_0) [linux-i386-java]
When I type java -version, I even get something different:
jenny#linux-auvv:~/jruby-1.6.0.RC1> java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.6.2) (suse-0.1.1-i386)
OpenJDK Server VM (build 14.0-b16, mixed mode)
It even works in RVM, so hooray!
I would try installing the Sun JRE/JDK.
Or perhaps you could reinstall OpenJDK(probably the easiest way to reset it to being the default on your system).
Update:
To change the default java do this. First check which Javas are available:
update-alternatives --list java
To actually change which one you are using do this:
update-alternatives --config java
I think the clue is in this:
Fatal: GCJ (GNU Compiler for Java) is not supported by JRuby.
For whatever reason, your system is configured to fire up GCJ instead of your OpenJDK compiler. Check the docs on your system for how it handles the case where multiple things can provide the same service name (multiple versions of compilers, for example, or multiple interpreters) and see what you can do to have OpenJDK be the default handler for Java compilation and execution.
Related
I have this test code :
require 'mkmf'
puts have_header("iostream.h")
this code throws an error in Jruby like this :
checking for iostream.h... RuntimeError: The compiler failed to generate an executable file. You have to install development tools first.
try_do at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:456
try_cpp at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:587
block in have_header at
/home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:1091
block in checking_for at
/home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:942
block in postpone at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:350
open at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:320
block in postpone at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:350
open at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:320
postpone at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:346
checking_for at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:941
have_header at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:1090
at test.rb:3
I have no idea what does it mean by development tools and I searched the internet without finding anything about this.
I installed Jruby 9.1.6.0 through rvm, this is my java version :
[abd#abd testruby]$ java -version
openjdk version "1.8.0_112"
OpenJDK Runtime Environment (build 1.8.0_112-b15)
OpenJDK 64-Bit Server VM (build 25.112-b15, mixed mode)
I'm using Arch linux here.
The real reason behind my question is that I tried installing gmp gem and native extensions wouldn't build because of the same error, I know the gem is unmaintained but I want to resolve this issue anyway because the above message suggests that my installation is lacking.
By the way I have the jdk, not just the jre.
JRuby C extensions have been deprecated [and possibly removed already but I'm a bit out of the loop].
Since you're running on the JVM, have you considered the alternatives? i.e. either use Java's BigInteger or BigDecimal if the performance is adequate for your needs, or wrap GMP using JNI / JNA- it looks like somebody has tried already. Check out this SO question for a few more Java alternatives.
Is ObjectSpace still disabled in jruby 9.1.5.0 (2.3.1)?
If it's not just my installation (Arch Linux, up-to-date) having a bug, I get the suspicion that ObjectSpace has changed in recent jruby: Trying to reproduce the behaviour described in jruby's wiki entry about performance, I get the following reaction:
$> jruby -O
jruby: unknown option -O
$> jruby -J-Djruby.objectspace.enabled=false
puts ObjectSpace.each_object(Class).inspect
#<Enumerator: ObjectSpace:each_object(Class)>
$> jruby -v
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 25.102-b14 on 1.8.0_102-b14 +jit [linux-x86_64]
So what is the up-to-date situation? Is it now safe / recommended to use OpenSpace in modern jruby?
it hasn't changed - is the same as in previous JRuby (1.7.x)
ObjectSpace (even while disabled) works for meta-classes ... it is used by Rails and is easy to implement in JRuby without the performance cost.
Per http://jruby.org/2014/01/09/jruby-1-7-10.html, the subject problem is supposed to be fixed in 1.7.10 via https://github.com/jruby/jruby/pull/1252. However, my experience is otherwise, per:
MacbookAir1:javlats palfvin$ jruby -v
jruby 1.7.10 (2.0.0p195) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
MacbookAir1:javlats palfvin$ jruby
(1..2).size
NoMethodError: undefined method `size' for 1..2:Range
(root) at -:1
MacbookAir1:javlats palfvin$
I haven't figured out how to look at the Java code in an installed JRuby version, so I wasn't able to compare the installed Java source code to the version on github, but this seems so basic it's hard to believe there's anything in my environment that is messing it up. I Googled to see if anyone else had encountered this, but didn't find anything.
Any ideas?
If my git-fu is right, I don't think this commit was included in 1.7.10. Indeed, it looks to only be in master:
$ git show -s --oneline 01be8f85522e4da8df3968e622fa2c947ea6712c
01be8f8 Add a size method to RubyRange to resolve #1252
$ git branch -r --contains 01be8f85522e4da8df3968e622fa2c947ea6712c
upstream/master
upstream/unbox_opts
$ git tag --contains 01be8f85522e4da8df3968e622fa2c947ea6712c
Perhaps there was a confusing merge somewhere in JRuby land?
I am trying to migrate from windows 7 to mac osx .
I have installed the following
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
mysql Ver 14.14 Distrib 5.1.56, for apple-darwin10.3.0 (i386) using
readline 5.1
After a lot of pain I installed my sql gem by :
sudo env ARCHFLAGS="-arch x86_64" gem install --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
But still when I run my project in netbeans I get the following error
[4;36;1mUser Columns (31.5ms)[0m
[0;1mSHOW FIELDS FROM users[0m
[4;35;1mSQL (1.2ms)[0m [0mSHOW
TABLES[0m /!\ FAILSAFE /!\ Wed May
04 09:53:16 +0530 2011 Status: 500
Internal Server Error undefined
method `where' for
Can anyone tell me what am I doing wrong ?
The database migrations are working perfectly.
You stopped copying the stack trace right at the point where it was about to tell you where the error occurs. Look down the stack trace for the first mention of any code from your app (as opposed to the gems or the vendor folder) and it should point you to the problem line.
It's unfortunate that you've having such a time installing the MySQL gem, but this can be complicated if you're loading it on a from-scratch machine that's missing the development headers, something required to compile the extension, and your path does not include /usr/local/mysql/bin which is common.
You can fix that by creating a file /etc/paths.d/mysql with the following:
/usr/local/mysql/bin
Generally you should just have to list mysql in your Gemfile after that, and it should install conventionally with bundle install.
As for the error, it looks like something deeper in your application that's blowing a gasket. When you say "run your project in netbeans," but do you mean run unit tests? It looks like you're calling where on something that doesn't support it.
This looks like an application error. The server is bailing with a 500 when it fails to evaluate the method 'where', somewhere likely in your code.
Modern Mac operating systems (forget which was the first) come with ruby and rails pre-installed - not sure if this is related to your setup.
What happens when you run
rails server
from the console (from within the directory of the app) ?
where is a ActiveRecord 3 AREL class method used for conditions.
First things first, do you have XCode installed? thats a prerequisite to installing any native gems. You can download XCode 3 from the apple site or buy XCode 4 from the app store.
More of the stack trace is required.
Ideally though, once you have installed XCode, you should take a look at https://rvm.io - it's the preferred way for managing rubies on Unixy systems.
Thanks guys.. I finally found the error was with the authlogic gem
I had installed 3.0.2
and the application requires an older version 2.x
Ubuntu 10.04LTS
Netbeans 6.9.1 (with embedded JRuby 1.5.1)
JDK6u17 (installed in /opt)
GlassFish Gem 1.0.2
I am using a old JDK because of this bug: http://jira.codehaus.org/browse/JRUBY-4785
I want to install RVM and install another instance of JRuby. But i cant find any information how to set JRuby Java environment to JDK6u17(directory /opt).
I would be grateful for the help.
JRuby on default use system Java. So if i change "system" Java, JRuby will use that one.
I have figured two ways to set specific Java environment.
Set JAVA_HOME.
Here is a good one tutorial:
http://vietpad.sourceforge.net/javaonlinux.html
Update java setting from terminal(works only for JVM installed from apt-get or aptitude).
sudo update-alternatives --config java
That JRuby bug is marked as fixed for JRuby 1.6RC1, so you no longer need to use the old JDK.
I am using RVM and JRuby 1.6RC1 on Ubuntu 10.04 LTS just fine. There are instructions on my website for working with this version of Ubuntu, RVM and JRuby.
You don't need all the instructions, but some of the commands might help, if you get stuck.
http://www.scottlowe.eu/deploying-rails-3-with-jruby-daemonized-glass
(It does tell you how to get a modern JDK installed)