Can't use Jruby with Rbenv on Snow-Leopard - jruby

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

Related

how can i install jruby alongside ruby

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.

How to have an old version of Ruby on Cloud9

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.

jruby-lint gem installed but no jrlint available?

I've recently started exploring JRuby using Joe Kutner's book "Deploying with JRuby", but I've hit an issue when trying to install the jruby-lint gem. Below is the output from my attempts, including the version numbers of Java, JRuby, and my OS.
I don't understand the output, especially why nokogiri wouldn't install as a jruby-lint dependency, but would install ok on its own. While the jruby-lint gem is now reported as having installed correctly, it has not delivered a jrlint executable/script to use, and I don't know where to go from here. Any ideas?
C:\Dev\repos\twitalytics>jruby --version
jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_21-b11 [Windows 7-amd64]
C:\Dev\repos\twitalytics>jruby -S gem install jruby-lint
Building native extensions. This could take a while...
ERROR: Error installing jruby-lint:
ERROR: Failed to build gem native extension.
C:/Dev/jruby-1.7.3/bin/jruby.exe extconf.rb
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS or modify .jrubyrc to enable.
(root) at C:/Dev/jruby-1.7.3/lib/ruby/shared/mkmf.rb:8
require at org/jruby/RubyKernel.java:1027
(root) at C:/Dev/jruby-1.7.3/lib/ruby/shared/rubygems/custom_require.rb:1
(root) at extconf.rb:5
Gem files will remain installed in C:/Users/Owen/.gem/jruby/1.8/gems/nokogiri-1.6.0.rc1 for inspection.
Results logged to C:/Users/Owen/.gem/jruby/1.8/gems/nokogiri-1.6.0.rc1/ext/nokogiri/gem_make.out
C:\Dev\repos\twitalytics>set JRUBY_OPTS=--1.8
C:\Dev\jruby-1.7.3>jruby --version
jruby 1.7.3 (ruby-1.8.7p370) 2013-02-21 dac429b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_21-b11 [Windows 7-amd64]
C:\Dev\repos\twitalytics>jruby -S gem install jruby-lint
ERROR: Error installing jruby-lint:
nokogiri requires Ruby version >= 1.9.2.
C:\Dev\repos\twitalytics>jruby -S gem install nokogiri
Fetching: nokogiri-1.5.9-java.gem (100%)
Successfully installed nokogiri-1.5.9-java
1 gem installed
C:\Dev\repos\twitalytics>jruby -S gem install jruby-lint
Fetching: jruby-lint-0.4.1.gem (100%)
Successfully installed jruby-lint-0.4.1
1 gem installed
C:\Dev\repos\twitalytics>jrlint
'jrlint' is not recognized as an internal or external command,
operable program or batch file.
I ran into a very similar issue, also while working through this book. Updating Rubygems solved it for me. Perhaps try:
jruby -S gem update --system
It's interesting that it tries to install the Ruby(not JRuby) version of Nokogiri cause it tries to install C extensions.
I think if you install the same version required by jruby-lint which is nokogiri-1.6.0.rc1, problem will be solved.
Neither solution here works for me on Windows. jruby -S gem install nokogiri
installs nokogiri-1.6.0-java
If I download the gem from https://github.com/jruby/jruby-lint and build it myself it leaves the gem folder empty at jruby\lib\ruby\gems\shared\gems\jruby-lint-0.4.1
And it won't make a bat file for running it in the /bin dir. I don't think this gem is ready for windows. Could it be that I'm trying to install it on BitNami stack? I haven't tried it with a regular install of JRuby.
In case updating Rubygems doesn't work, try:
gem install nokogiri
This will install nokogiri-1.6.0-java
then again:
gem install jruby-lint
and you're good to go.

Specifying 1.9 mode with JRuby and rbenv

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]

RVM, JRuby setting specific java environment

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)