jruby bundle安装不在gem' scrypt'

时间:2015-07-01 21:49:35

标签: ruby-on-rails gem rubygems jruby scrypt

我正在尝试为jruby(Windows)进行捆绑安装,我收到此错误:

C:/jruby-1.7.19/bin/jruby.exe -rubygems C:/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.1.0/bin/rake RUBYARCHDIR=C:/jruby-1.7.19/lib/ruby/gems/shared/extensions/universal-java-1.8/1.9/scrypt-2.0.2 RUBYLIBDIR=C:/jruby-1.7.19/lib/ruby/gems/shared/extensions/universal-java-1.8/1.9/scrypt-2.0.2
io/console not supported; tty will not be manipulated
mkdir -p i386-windows
cc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -fPIC  -o i386-windows/crypto_scrypt-sse.o -c ./crypto_scrypt-sse.c
rake aborted!
Command failed with status (127): [cc -fexceptions -O -fno-omit-frame-pointer...]
org/jruby/RubyProc.java:271:in `call'
org/jruby/RubyProc.java:271:in `call'
org/jruby/RubyArray.java:1613:in `each'
org/jruby/RubyArray.java:1613:in `each'
org/jruby/RubyArray.java:1613:in `each'
org/jruby/RubyArray.java:1613:in `each'
Tasks: TOP => default => i386-windows/scrypt_ext.dll => i386-windows/crypto_scrypt-sse.o
(See full trace by running task with --trace)

rake failed, uncaught signal 1

我已经安装了jruby和JVM。

2 个答案:

答案 0 :(得分:0)

你正试图在java版本的ruby中安装带有原生扩展的gem:通常是一个坏主意......

我在https://github.com/wg/scrypt找到了scrypt算法的纯java实现。

您需要从Maven(http://search.maven.org/remotecontent?filepath=com/lambdaworks/scrypt/1.4.0/scrypt-1.4.0.jar)下载jar文件,将其添加到您的库路径或在您的代码中需要jar。

接下来是编写一个包装器来模仿scrypt行为,将其用作ruby / rails代码中的替代品。

或者,您可以删除scrypt位并直接使用java库。这是在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

答案 1 :(得分:0)

已经很晚了,但我只是wrote一个多平台gem,它将详细信息作为scrypt gem的API替代品替代。

gem install scrypt-ruby -P MediumSecurity