Jruby installation for ROR
You can't use 'therubyracer' and 'libv8' gems with JRuby.
Short answer:
Use 'therubyrhino' gem instead (https://github.com/cowboyd/therubyrhino)
Explanation:
There are some gems that can't be used under JRuby, because they are using native (C) extensions - here is a list: https://github.com/jruby/jruby/wiki/C-Extension-Alternatives
Unable to install rails with jRuby
I had this problem just a bit ago, but it was with rspec
. Try this:jruby --1.9 -S gem install rails -v 3.0.6
This tells jruby to use the ruby 1.9 interpreter.
Installing JRuby 1.6.7 + Rails 3 with Ubuntu?
First install rvm:
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
$ source ~/.bash_profile
Once rvm is installed, use it to install jruby:
$ rvm install jruby-1.6.7
You can then use that version:
$ rvm use jruby-1.6.7
Finally, install rails:
$ jruby -S gem install rails
Update
With more recent versions of rvm, installing the latest version of jruby and rails is very straightforward:
$ \curl -L https://get.rvm.io | bash -s stable --autolibs=3 --ruby=jruby --gems=rails
Installing Jruby changes default paths of Ruby and Rails
You don't need jruby
in order to install therubyracer
. You only need to comment out therubyracer
entry in Gemfile
gem 'therubyracer', platforms: :ruby
One another way which doesn't involve therubyracer
is to install node.js.
How to get rails to work with jruby and rvm - ruby version keeps flipping
what is says is definitely worth following :
Your Ruby version is 2.3.3, but your Gemfile specified 2.5.1
if you do a rvm jruby-9.1.17.0 do ruby --version
you will get smt like :
jruby 9.1.17.0 (2.3.3) 2018-04-20 d8b1ff9 Java HotSpot(TM) 64-Bit Server VM 25.171-b11 on 1.8.0_171-b11 +jit [linux-x86_64]
the (2.3.3) part means its Ruby 2.3 so I recommend you use JRuby 9.2 :
rvm install jruby-9.2.8.0
will give you a 2.5(.3) compatible Ruby runtime, update Gemfile accordingly :
"ruby '2.5.3', :engine => 'jruby', :engine_version => '9.2.8.0'"
Specifying JRuby Version in Bundler
as suggested by the comment already linking to RVM reports Gemfile ruby as not installed
RVM's support for resolving a Ruby "engine" from the Gemfile is limited and does not match how Heroku is using (parsing) the directive.
if you really want to have it both in the Gemfile use a comment for RVM e.g.
source "https://rubygems.org"
#ruby=jruby-1.7.12
if ENV["JRUBY"] || RUBY_PLATFORM == "java"
ruby "1.9.3", engine: "jruby", engine_version: "1.7.12"
end
gem "rails", "~> 4.1.1"
# ...
jruby bundle install not working at gem 'scrypt'
You're trying to install a gem with native extensions inside a java version of ruby: usually a bad idea...
I found a pure java implementation of scrypt algorithm at https://github.com/wg/scrypt.
You need to download the jar file from Maven (http://search.maven.org/remotecontent?filepath=com/lambdaworks/scrypt/1.4.0/scrypt-1.4.0.jar), add it to your library path or require the jar in your code.
Next is to write a wrapper to imitate the scrypt behavior to use it as a drop-in replacement in your ruby/rails code.
Alternatively, you could just remove the scrypt bits and use the java library directly. Here's a snippet tested in jirb (1.7.20)...
>> require 'java'
=> true
>> require './scrypt-1.4.0.jar'
=> true
>> java_import 'com.lambdaworks.crypto.SCryptUtil'
=> [Java::ComLambdaworksCrypto::SCryptUtil]
>> passwd,n,r,p = 'secret',16384,8,1
=> ["secret", 16384, 8, 1]
>> hashed_passwd = SCryptUtil.scrypt(passwd,n,r,p)
=> "$s0$e0801$MzcxaOBVz7kaVU6E5HV0cg==$RAx9ADWVeyZE5JRl+J1NpiBSEPNabEcVdR7drddpgMw="
>> SCryptUtil.check(passwd,hashed_passwd)
=> true
>> SCryptUtil.check('wrong password',hashed_passwd)
=> false
Related Topics
"Msvcrt-Ruby18.Dll Was Not Found" with Ruby
Difference Between or and || When Setting Variables
Which Equality Test Does Ruby's Hash Use When Comparing Keys
What Is the Standalone Splat Operator (*) Used for in Ruby
How to Access Cookies from Applicationcontroller (Rails)
How to Solve the 'Object Doesn't Support #Inspect' Error
Trying to Get Content Inside Cdata Tags in Xml File Using Nokogiri
Zero-Length String Being Returned from String#Split
If(!X) VS If(X==False) in Ruby
How to Model a Mutual Friendship in Rails
How to Get the Final Url After Redirects Using Ruby
How to Access the Current Node from a Library in a Chef Cookbook
Consequences of Implementing To_Int and To_Str in Ruby
Converting a Unique Seed String into a Random, Yet Deterministic, Float Value in Ruby