I have 2 applications, one that needs to run JRuby 1.6.5 in 1.8 mode and another that needs to run JRuby 1.6.7 in 1.9 mode. Is it possible to specify within the application that I want the one application to run in 1.9 mode without having to explicitly set the JRUBY_OPTS environment variable. Within .rvmrc, I could do the following:
proj_1_8 version of .rvmrc
unset JRUBY_OPTS
rvm use jruby-1.6.5#proj_1_8
proj_1_9 version of .rvmrc
export JRUBY_OPTS=--1.9
rvm use jruby-1.6.7#proj_1_9
Is there anyway I can automatically get the mode set without having to manually set/unset the environment variable whenever I switch between projects?
As D3mon-1stVFW suggested...
https://github.com/sstephenson/rbenv-vars will help.
$ ruby-app-dir> jruby --version
jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM 1.6.0_33) [darwin-i386-java]
$ ruby-app-dir> ## Install rbenv-vars as indicated in Github
$ ruby-app-dir> cat .rbenv-vars
JRUBY_OPTS=--1.9
$ ruby-app-dir> jruby --version
jruby 1.6.7.2 (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM 1.6.0_33) [darwin-i386-java]
You can do this with chruby.
$ chruby jruby --1.9
$ jruby --version
jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on OpenJDK 64-Bit Server VM 1.7.0_09-icedtea-mockbuild_2012_10_17_15_53-b00 [linux-amd64]
$ chruby jruby --1.8
jruby 1.7.0 (ruby-1.8.7p370) 2012-10-22 ff1ebbe on OpenJDK 64-Bit Server VM 1.7.0_09-icedtea-mockbuild_2012_10_17_15_53-b00 [linux-amd64]
Related
Based on this page on the JRuby wiki and other resources I see the recommendation is
to always use jruby -S.
because
The -S parameter tells JRuby to use its version of the installed binary, as opposed to some other version (such as an MRI version) that might be on your PATH.
Using rbenv and rvm I've had issues when using -S with JRuby (see this question) and my understanding is that both those version managers solve the problem -S attempts to address.
You do not need to run the gem command with jruby -S gem if you are using a Ruby manager such as rbenv or rvm. Those tools manage your command path for you so that the correct Ruby runtime and the correct version of rubygems are used. Similar applies to the rake.
I have a source code that I want to test on Cloud9 hosting (I have premium account). However, the problem is that the source code is bade on Ruby 1.8, mysql-essential-5.0 and other old libraries.
How can I create a plain VM on cloud9 and install ruby and other version by myself ? So far all i see that all vms are pre-configured with ruby 4
Cloud9 IDE comes with rvm preinstalled, so this is nice. Otherwise, all VM are pre-configured with Ruby 2.1.5 (not 4) and Rails 4.1.6
The only thing you have to do in your console is :
# Check your actual Ruby version
ruby -v
# ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
# Install ruby 1.8 (if it's not already done)
rvm install ruby-1.8
# Switch ruby version
rvm use 1.8
For MySQL I would first do an uninstallation of your current version of mysql with sudo apt-get uninstall mysql* and then install it from source. You can check this link for more info.
I just installed jruby using the ruby-build plugin for rbenv.
> rbenv install jruby-1.6.7
Downloading jruby-1.6.7.tar.gz...
-> http://cloud.github.com/downloads/sstephenson/ruby-build-download-mirror/fd1b8d7389aa92da69ea6efb4782e40a
Installing jruby-1.6.7...
Installed jruby-1.6.7
Then set my ruby version to jruby
> rbenv local jruby-1.6.7
Then try to do something with jruby
> jruby
or
> gem list
I keep getting back:
execv failed: Permission denied (13)
The Jruby binary and Java are both executable.
My Java Version:
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-10M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
I added the following to my .zshrc
export JAVACMD=`which java`
Dont quote me on this, but it worked for me.
I had been using https://github.com/flatland/drip which I had installed brew on osx snow leopard.
Warning first: run echo $JAVACMD && echo $JAVA_HOME
and save what those are in case you need them
When I uninstalled drip with brew I was getting the same error... I ran.
unset JAVA_HOME
and
unset JAVACMD
and I was back in business
I know that I can run JRuby with 1.9 compatibility with the --1.9 flag. No problems here.
However, I cannot get Rails3 to run with JRuby 1.6.2 in 1.9 mode on Windows XP. Am I missing something?
Here are my JRuby 1.6.2 version details:
C:\DEV\Jruby\jrails\foobar>jruby -v
jruby 1.6.2 (ruby-1.8.7-p330) (2011-05-26 1.6.2) (Java HotSpot(TM) Client VM 1.6.0_23) [Windows XP-x86-java]
And here's the output when starting up Rails3 with JRuby and the --1.9 flag on:
C:\DEV\Jruby\jrails\foobar>jruby --1.9 -S rails s
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-05-27 00:16:34] INFO WEBrick 1.3.1
[2011-05-27 00:16:34] INFO ruby 1.8.7 (2011-05-27) [java]
[2011-05-27 00:16:34] INFO WEBrick::HTTPServer#start: pid=7160 port=3000
As you can see, Rails3 starts up with ruby 1.8.7.
By the way, I have no problems running Rails3 with JRuby 1.6.2 in 1.9 compatibility mode on FreeBSD, and I reckon it might be OK on Linux as well. Just can't get it to work on Windows.
Could someone tell me why I can't run Rails3 with JRuby 1.6.2 in 1.9 mode?
Bug report JRUBY-5818 reports that Rails started with JRuby in 1.9 mode on Windows will restart in 1.8 mode. This is exactly the problem I am facing. Hope this gets fixed soon.
UPDATE
The JRuby team report that Rails does not recognize command-line arguments when it respawns. The solution is to set 1.9 mode in JRUBY_OPTS or .jrubyc.
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)