I used the jruby zip executable to install 1.6.2, but it looks like they have released 1.6.4. How should I migrate from 1.6.2 to 1.6.4, should I have to re-install or is there a different command.
Mostly all you need to do is reinstall gems on the newly-unpacked JRuby (recommended), or migrate your existing gem installs by copying the lib/ruby/gems/* over to the new location. There's no automated update tool for JRuby itself right now.
Unpack new Jruby
export JRUBY_HOME=/path/to/jruby
export PATH=$PATH:$JRUBY_HOME/bin
Maybe even push the above to .bashrc
Add a list of required Gems to your Gemfile.
To reinstall Gems if needed the best way to do it is as follows
Jruby -S gem install bundler
Cd to /path/to/Gemfile
bundle install
Related
i first installed jruby using the sudo apt-get install jruby command, which succeeded but it did gave me 1.5.6 version when i wanted a later version. So i uninstalled it and used rvm install jruby command and i was able to install jruby version 1.7.19 but after installing it, my ruby applications,which were funtioning right started producing errors complaining of missing gems like mysql2 gem missing,run bundle install. i run bundle install but nothing i did seemed to help, i was getting nowhere.
When i asked for the ruby version, i was receiving the jruby version instead, its lyk jruby over shadowing ruby,,,, So i decided to uninstall jruby, reinstall ruby and now ruby is functioning as well as before.
Can anyone help me with the ubuntu commands which can help me install jruby alongside ruby, so that both work well without any errors???
Am requesting for serious help please
I usually prefer rbenv over rvm for running multiple versions of Ruby on the same machine. Here is sample install/usage steps:
Install rbenv git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
Install ruby-build git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
Modify your .bashrc echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
Restart your shell
Install rubies. e.g. rbenv install jruby-1.7.20
Rehash (create new rbenv shims. You'll need to run this anytime you install a gem that adds a command) rbenv rehash
You can list the Ruby versions available to install with rbenv install -l
You can set the default global ruby version with rbenv global jruby-1.7.20.
You can also pass "system" instead of an installed Ruby if you want the default to be the OS installed version of Ruby.
You can change Ruby version on the fly with rbenv shell 1.9.3-p551
See here (https://github.com/sstephenson/rbenv#command-reference) for a lot more detail and documentation.
Edit: I was assuming you're using Ubuntu, hence the edit of .bashrc. If you're using another OS you may need to change that to .bash_profile
Thanks for that answer. I have also found out that it is soo possible to have jruby and ruby installed concurrently using rvm. After installing the various versions or languages say ruby and jruby, only the default language and version is running in the terminal as current so you have to run the command 'rvm list' to show you the various installed versions after which you run 'rvm use language-X.X.XX' say rvm use jruby-1.7.20.1 to make jruby-1.7.20.1 run as the current in that terminal.
You can also run another version in a different terminal concurrently but please note, you have to run the command rvm use every time you open up a new terminal, else you make that version default.
Does Nitrous.io support JRuby?
Installing it with RVM seems to attempt to run a sudo apt-get update, which it won't allow...
Thanks.
First you will need to update RVM.
rvm get head
From there you can install jruby:
rvm install jruby
Next, set RVM to use jruby.
rvm use jruby
Next, add jruby to your PATH.
export PATH=$PATH:/opt/jruby/bin
From there you should be able to check that jruby is working with the following command:
jruby --version
So, installing a jruby binary seems to work fine, but still cant figure out how to get RVM to do the install...
So, I just manually moved jruby into the .rvm folder...I put a copy of the binary in the .rvm/rubies directory, made a symlink from the binaries' "jruby" executable to a "ruby" executable in the .rvm/rubies bin folder, made related empty folders for jruby in the .rvm/gems directory for the version of jruby, and did "rvm jruby-1.7.8 do rvm gemset create" and now I can do "rvm use jruby"...things seem to work fine.
I have a bad feeling about this tho. But I always do when using RVM...
I don't know if it will actually require any additional packages (so this might not work), but you could try running rvm with --autolibs=0 so it doesn't attempt to install any packages; see https://rvm.io/rvm/autolibs for details.
I installed JRuby 1.7.4 using Rbenv. I've installed several gems using gem install GEMNAME from a shell where jruby-1.7.4 was set as the active ruby-- I confirmed after installation that the gems are in fact present in ~/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems. But, when I try to require most of my installed gems from jruby, I get an error. Inspection shows that their lib directories are not on the $LOAD_PATH. Shouldn't all the lib dirs in the gem directories I specified above automatically be there? If not, how do I get them to show up there?
I'm using capistrano to deploy a rails app, and it uses bundle install --deployment to put the gems in shared/bundle. I've put the appropriate platform :ruby and platform :jruby blocks in my gemfile, my question is if I switch rvm to jruby and then go to my app root directory and do another bundle install --deployment, will that mess with any of the existing gems there and replace them with jruby ones? Will I be able to switch back to mri and run the app like I always have? Will both platform's gems be in there, and then what about gems like nokogiri that have java versions, will that overwrite the mri version? Will I be able to just switch rvm versions and run the app via mri or jruby as I please at that point?
Turns out mri gems are installed in shared/bundle/ruby and jruby gems in /shared/bundle/jruby, so totally safe to switch to jruby, install your gems, and try it out
I've been having a tough time getting jRuby on Rails 3 deployed on Tomcat 6. I got it to work exactly once.
I modified my database.yaml and Gemfile to check for jRuby, something like this:
if defined?(JRUBY_VERSION)
gem 'jdbc-mysql'
#gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcmysql-adapter'
#gem 'activerecord-jdbcsqlite3-adapter'
gem 'jruby-openssl'
gem 'jruby-rack'
gem 'warbler'
else
gem 'mysql'
gem "mongrel"
gem 'ruby-debug'
end
Some environment settings:
$ rvm -v
rvm 1.0.14
$ jruby -v
jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java]
When I run jruby -S bundle install everything goes smoothly.
It's when I try to do something like rake db:migrate, jruby -S rake db:migrate or warble that I get 50 DEPRECATION WARNINGs and an eventual stackoverflow.
I solved this issue by deleting the warbler plugin, it did not like the line Warbler::Task.new
Next, I ran warble config to give me a config/warbler.rb file.
And finally, warble to create my .war file. So far so good.
Now I move the .war file to my Tomcat webapps. Everything works fine except for an error:
Oct 10, 2010 1:34:46 AM org.apache.catalina.core.ApplicationContext log
SEVERE: Application Error
org.jruby.rack.RackInitializationException:
http://github.com/plataformatec/devise.git (at master) is not checked out.
Please run 'bundle install'
I solved this problem once and only once by going into my webapps/myapp/WEB-INF and running jruby -S bundle install
It no longer works and I have no idea what is going on.
I believe this can be called a bug in the current version of Warbler. Using git repositories in your Gemfile don't quite get staged properly in the war file and Bundler is still looking for a checked out repository on disk.
A future version of Warbler will probably do something along the lines of bundle --deployment when you create the war file.
For now, to work around, you might have to vendor the devise code.
The current version of warbler (1.3.6) will also exhibit this behavior if you build a war file with warbler war. I've found that building with the following command works:
warbler compiled war
Hopefully future versions will address this more completely.