New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

So Rails Rake Tasks Don't work? Preview 1 - 9.0.0.0 #2497

Closed
AdamKyle opened this Issue Jan 22, 2015 · 7 comments

Comments

Projects
None yet
4 participants
@AdamKyle

AdamKyle commented Jan 22, 2015

So I might be on drugs, but I hope not. So I have a Rails 4.2 project with Jruby 9.0.0.0.-pre1 installed and being used by the project.

I then have the following task:

desc "Create an Api Key assuming one doesn't exist."
task :create_api_key, [:name] => :enviroment do  | t, args |
  if !ApiKey.find_by_application_name(args[:name])
    if ApiKey.new(name: args[:name], api_key: SecureRandom.hex(32)).save!
      puts "Your key is: " + ApiKey.find_by_application_name(args[:name]).api_key
    else
      puts "Could not create the api key, you might be missing an argument: Application Name."
    end
  else
    puts "This application already contains an api key."
  end
end

Running: bin/rake create_api_key aisis_platform Gives me:

rake aborted!
SyntaxError: /Users/Adam/Documents/Rails-Projects/BlackBird/lib/tasks/create_api_key.rake:5: syntax error, unexpected tCONSTANT
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:1:in `(root)'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `__script__'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `run_tasks_blocks'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `run_tasks_blocks'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/application.rb:438:in `run_tasks_blocks'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:453:in `load_tasks'
/Users/Adam/Documents/Rails-Projects/BlackBird/Rakefile:6:in `(root)'
(See full trace by running task with --trace)

Now what makes me think this is a bug is because I posted the issue here on stack Thinking I didnt know basic ruby. But the one comment there states that there is no errors.

So .....

Am I on something or does jruby just fail? or do we not support rails?

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Jan 22, 2015

Member

Wow, that's surprising. We do test Rails periodically and did so again immediately before the release on multiple platforms. This seems like something missed in the parser.

I'll try to reproduce. Is this the entire, exact contents of create_api_key.rake?

Member

headius commented Jan 22, 2015

Wow, that's surprising. We do test Rails periodically and did so again immediately before the release on multiple platforms. This seems like something missed in the parser.

I'll try to reproduce. Is this the entire, exact contents of create_api_key.rake?

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Jan 22, 2015

Member

The task as given appears to parse successfully in JRuby. There's something else at play here, perhaps with how activesupport is loading the file?

Member

headius commented Jan 22, 2015

The task as given appears to parse successfully in JRuby. There's something else at play here, perhaps with how activesupport is loading the file?

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Jan 22, 2015

Member

Can you run this same command but with JRUBY_OPTS="-Xbacktrace.style=raw -Xjit.threshold=0" and --trace passed to rake, please? I need more information about where this is coming from.

Member

headius commented Jan 22, 2015

Can you run this same command but with JRUBY_OPTS="-Xbacktrace.style=raw -Xjit.threshold=0" and --trace passed to rake, please? I need more information about where this is coming from.

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Jan 22, 2015

Member

We run Rails + Rake we before we release so we are at least loading enough to run a database migration. I sometimes see misreported lines in backtraces when a subfile fails and Rails also uses Autoload which could possibly fire off a load which is failing?

Member

enebo commented Jan 22, 2015

We run Rails + Rake we before we release so we are at least loading enough to run a database migration. I sometimes see misreported lines in backtraces when a subfile fails and Rails also uses Autoload which could possibly fire off a load which is failing?

@AdamKyle

This comment has been minimized.

Show comment
Hide comment
@AdamKyle

AdamKyle Jan 22, 2015

@headius The entire contents of the rake file is:

desc "Create an Api Key assuming one doesn't exist."
task :create_api_key, [:name] => :enviroment do  | t, args |
  if !ApiKey.find_by_application_name(args[:name])
    if ApiKey.new(name: args[:name], api_key: SecureRandom.hex(32)).save!
      puts "Your key is: " + ApiKey.find_by_application_name(args[:name]).api_key
    else
      puts "Could not create the api key, you might be missing an argument: Application Name."
    end
  else
    puts "This application already contains an api key."
  end
end

desc "Finds a key based on application name."
task :find_api_key, [:name] => :enviroment do | t, args |
  if ApiKey.find_by_application_name(args[:name])
    puts ApiKey.find_by_application_name(args[:name]).api_key
  else
    puts "There is no application key with that name."
  end
end

desc "Get all API Keys."
task :all_keys do
  ApiKey.all.each do | key |
    puts "Application Name: " + key.application_name
    puts "Application Key: " + key.api_key
    puts "-----------------------------------------"
  end
end

desc "Delete an Api Key."
task :delete_key, [:name] => :enviroment do | t, args |
  if ApiKey.find_by_application_name(args[:name])
    if ApiKey.find_by_application_name(args[:name]).destroy!
      puts "Key Destroyed."
    else
      puts "Something went wrong with deleting the key. We found it, we just can't delete it oO."
    end
  else
    puts "No key was found by that application name."
  end
end

I haven't been able to test every other rake task, so there might be issues aside from jruby issues. But the one I have tested is the create_api_key task - which is throwing these issues.

The model for these tasks:

class ApiKey < ActiveRecord::Base
  validates :application_name, presence: true, uniqueness: true
end

There is no controller.

People in stack are stating that SecureRandom and ApiKey are considered constants and that they cannot reproduce this on there versions of Jruby. SecureRandom and ApiKey are both valid classes, one is a model class - which is tested with Rspec 3.1.0 and the other is a Ruby Class (Java also has a version of this class, could they be conflicting?).

Running the command you asked, with the additional params:

Adams-Mac-mini:BlackBird Adam$ JRUBY_OPTS="-Xbacktrace.style=raw -Xjit.threshold=0" bin/rake create_api_key aisis_platform --trace

rake aborted!
SyntaxError: /Users/Adam/Documents/Rails-Projects/BlackBird/lib/tasks/create_api_key.rake:5: syntax error, unexpected tCONSTANT
java/lang/Thread.java:1588:in `getStackTrace'
org/jruby/runtime/backtrace/TraceType.java:175:in `getBacktraceData'
org/jruby/runtime/backtrace/TraceType.java:39:in `getBacktrace'
org/jruby/RubyException.java:227:in `prepareBacktrace'
org/jruby/exceptions/RaiseException.java:215:in `preRaise'
org/jruby/exceptions/RaiseException.java:194:in `preRaise'
org/jruby/exceptions/RaiseException.java:110:in `<init>'
org/jruby/Ruby.java:3978:in `newRaiseException'
org/jruby/Ruby.java:3757:in `newSyntaxError'
org/jruby/parser/Parser.java:135:in `parse'
org/jruby/parser/Parser.java:89:in `parse'
org/jruby/Ruby.java:2691:in `parseFileAndGetAST'
org/jruby/Ruby.java:2650:in `parseFile'
org/jruby/Ruby.java:2637:in `parseFile'
org/jruby/Ruby.java:2860:in `loadFile'
org/jruby/runtime/load/LibrarySearcher.java:249:in `loadScript'
org/jruby/runtime/load/LibrarySearcher.java:237:in `load'
org/jruby/runtime/load/LibrarySearcher.java:35:in `load'
org/jruby/runtime/load/LoadService.java:326:in `load'
org/jruby/RubyKernel.java:977:in `loadCommon'
org/jruby/RubyKernel.java:969:in `load19'
org/jruby/ir/runtime/IRRuntimeHelpers.java:871:in `unresolvedSuper'
org/jruby/ir/instructions/ZSuperInstr.java:40:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:324:in `processCall'
org/jruby/ir/interpreter/Interpreter.java:551:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:639:in `INTERPRET_BLOCK'
org/jruby/runtime/InterpretedIRBlockBody.java:74:in `commonYieldPath'
org/jruby/runtime/IRBlockBody.java:84:in `yieldSpecific'
org/jruby/runtime/Block.java:116:in `yieldSpecific'
org/jruby/ir/runtime/IRRuntimeHelpers.java:450:in `yieldSpecific'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/activesupport_minus_4_dot_2_dot_0/lib/active_support//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:106:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:115:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:272:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:78:in `callBlock'
org/jruby/runtime/callsite/CachingCallSite.java:82:in `call'
org/jruby/ir/instructions/CallBase.java:388:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:320:in `processCall'
org/jruby/ir/interpreter/Interpreter.java:551:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:654:in `INTERPRET_METHOD'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:147:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `run_tasks_blocks_CLOSURE_1__run_tasks_blocks_0'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/railties_minus_4_dot_2_dot_0/lib/rails//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `run_tasks_blocks_CLOSURE_1__run_tasks_blocks_0'
org/jruby/runtime/CompiledIRBlockBody.java:66:in `commonYieldPath'
org/jruby/runtime/IRBlockBody.java:145:in `doYield'
org/jruby/runtime/BlockBody.java:82:in `yield'
org/jruby/runtime/Block.java:147:in `yield'
org/jruby/RubyArray.java:1569:in `each'
org/jruby/runtime/callsite/CachingCallSite.java:138:in `callBlock'
org/jruby/runtime/callsite/CachingCallSite.java:144:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/railties_minus_4_dot_2_dot_0/lib/rails//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:106:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:115:in `call'
org/jruby/ir/runtime/IRRuntimeHelpers.java:833:in `instanceSuper'
org/jruby/ir/runtime/IRRuntimeHelpers.java:826:in `instanceSuperSplatArgs'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/application.rb:438:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/railties_minus_4_dot_2_dot_0/lib/rails//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/application.rb:438:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:138:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:145:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:453:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/railties_minus_4_dot_2_dot_0/lib/rails//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:453:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:106:in `call'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:118:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:198:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:292:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:130:in `call'
org/jruby/ir/interpreter/Interpreter.java:308:in `processCall'
org/jruby/ir/interpreter/Interpreter.java:551:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:619:in `INTERPRET_ROOT'
org/jruby/ir/interpreter/Interpreter.java:100:in `execute'
org/jruby/ir/interpreter/Interpreter.java:28:in `execute'
org/jruby/ir/IRTranslator.java:39:in `execute'
org/jruby/Ruby.java:844:in `runInterpreter'
org/jruby/Ruby.java:2867:in `loadFile'
org/jruby/runtime/load/LibrarySearcher.java:249:in `loadScript'
org/jruby/runtime/load/LibrarySearcher.java:237:in `load'
org/jruby/runtime/load/LibrarySearcher.java:35:in `load'
org/jruby/runtime/load/LoadService.java:326:in `load'
org/jruby/RubyKernel.java:977:in `loadCommon'
org/jruby/RubyKernel.java:969:in `load19'
org/jruby/internal/runtime/methods/DynamicMethod.java:210:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:138:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:145:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:690:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:690:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:198:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:292:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:130:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:94:in `load_rakefile_CLOSURE_1__load_rakefile_1'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:94:in `load_rakefile_CLOSURE_1__load_rakefile_1'
org/jruby/runtime/CompiledIRBlockBody.java:66:in `commonYieldPath'
org/jruby/runtime/IRBlockBody.java:84:in `yieldSpecific'
org/jruby/runtime/Block.java:116:in `yieldSpecific'
org/jruby/ir/runtime/IRRuntimeHelpers.java:450:in `yieldSpecific'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:302:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:140:in `callBlock'
org/jruby/runtime/callsite/CachingCallSite.java:144:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:93:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:93:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:198:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:292:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:130:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:77:in `run_CLOSURE_1__run_1'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:77:in `run_CLOSURE_1__run_1'
org/jruby/runtime/CompiledIRBlockBody.java:66:in `commonYieldPath'
org/jruby/runtime/IRBlockBody.java:84:in `yieldSpecific'
org/jruby/runtime/Block.java:116:in `yieldSpecific'
org/jruby/ir/runtime/IRRuntimeHelpers.java:450:in `yieldSpecific'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:302:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:140:in `callBlock'
org/jruby/runtime/callsite/CachingCallSite.java:144:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:198:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:292:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:130:in `call'
org/jruby/ir/interpreter/Interpreter.java:308:in `processCall'
org/jruby/ir/interpreter/Interpreter.java:551:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:619:in `INTERPRET_ROOT'
org/jruby/ir/interpreter/Interpreter.java:100:in `execute'
org/jruby/ir/interpreter/Interpreter.java:28:in `execute'
org/jruby/ir/IRTranslator.java:39:in `execute'
org/jruby/Ruby.java:844:in `runInterpreter'
org/jruby/Ruby.java:2867:in `loadFile'
org/jruby/runtime/load/LibrarySearcher.java:249:in `loadScript'
org/jruby/runtime/load/LibrarySearcher.java:237:in `load'
org/jruby/runtime/load/LibrarySearcher.java:35:in `load'
org/jruby/runtime/load/LoadService.java:326:in `load'
org/jruby/RubyKernel.java:977:in `loadCommon'
org/jruby/RubyKernel.java:969:in `load19'
org/jruby/internal/runtime/methods/DynamicMethod.java:210:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
bin/rake:16:in `__script__'
bin/bin/rake:16:in `__script__'
java/lang/invoke/MethodHandle.java:599:in `invokeWithArguments'
org/jruby/ir/Compiler.java:112:in `load'
org/jruby/Ruby.java:817:in `runScript'
org/jruby/Ruby.java:810:in `runScript'
org/jruby/Ruby.java:761:in `runNormally'
org/jruby/Ruby.java:569:in `runFromMain'
org/jruby/Main.java:405:in `doRunFromMain'
org/jruby/Main.java:300:in `internalRun'
org/jruby/Main.java:227:in `run'
org/jruby/Main.java:199:in `main'

My conclusion from this is that Because Java has a SecureRandom class and Ruby has the same class that they are conflicting?

@enebo

Do you guys run the rails test suite? I also upgrade rails regularly, so if a new update comes out I usually upgrade, Security or other wise.

AdamKyle commented Jan 22, 2015

@headius The entire contents of the rake file is:

desc "Create an Api Key assuming one doesn't exist."
task :create_api_key, [:name] => :enviroment do  | t, args |
  if !ApiKey.find_by_application_name(args[:name])
    if ApiKey.new(name: args[:name], api_key: SecureRandom.hex(32)).save!
      puts "Your key is: " + ApiKey.find_by_application_name(args[:name]).api_key
    else
      puts "Could not create the api key, you might be missing an argument: Application Name."
    end
  else
    puts "This application already contains an api key."
  end
end

desc "Finds a key based on application name."
task :find_api_key, [:name] => :enviroment do | t, args |
  if ApiKey.find_by_application_name(args[:name])
    puts ApiKey.find_by_application_name(args[:name]).api_key
  else
    puts "There is no application key with that name."
  end
end

desc "Get all API Keys."
task :all_keys do
  ApiKey.all.each do | key |
    puts "Application Name: " + key.application_name
    puts "Application Key: " + key.api_key
    puts "-----------------------------------------"
  end
end

desc "Delete an Api Key."
task :delete_key, [:name] => :enviroment do | t, args |
  if ApiKey.find_by_application_name(args[:name])
    if ApiKey.find_by_application_name(args[:name]).destroy!
      puts "Key Destroyed."
    else
      puts "Something went wrong with deleting the key. We found it, we just can't delete it oO."
    end
  else
    puts "No key was found by that application name."
  end
end

I haven't been able to test every other rake task, so there might be issues aside from jruby issues. But the one I have tested is the create_api_key task - which is throwing these issues.

The model for these tasks:

class ApiKey < ActiveRecord::Base
  validates :application_name, presence: true, uniqueness: true
end

There is no controller.

People in stack are stating that SecureRandom and ApiKey are considered constants and that they cannot reproduce this on there versions of Jruby. SecureRandom and ApiKey are both valid classes, one is a model class - which is tested with Rspec 3.1.0 and the other is a Ruby Class (Java also has a version of this class, could they be conflicting?).

Running the command you asked, with the additional params:

Adams-Mac-mini:BlackBird Adam$ JRUBY_OPTS="-Xbacktrace.style=raw -Xjit.threshold=0" bin/rake create_api_key aisis_platform --trace

rake aborted!
SyntaxError: /Users/Adam/Documents/Rails-Projects/BlackBird/lib/tasks/create_api_key.rake:5: syntax error, unexpected tCONSTANT
java/lang/Thread.java:1588:in `getStackTrace'
org/jruby/runtime/backtrace/TraceType.java:175:in `getBacktraceData'
org/jruby/runtime/backtrace/TraceType.java:39:in `getBacktrace'
org/jruby/RubyException.java:227:in `prepareBacktrace'
org/jruby/exceptions/RaiseException.java:215:in `preRaise'
org/jruby/exceptions/RaiseException.java:194:in `preRaise'
org/jruby/exceptions/RaiseException.java:110:in `<init>'
org/jruby/Ruby.java:3978:in `newRaiseException'
org/jruby/Ruby.java:3757:in `newSyntaxError'
org/jruby/parser/Parser.java:135:in `parse'
org/jruby/parser/Parser.java:89:in `parse'
org/jruby/Ruby.java:2691:in `parseFileAndGetAST'
org/jruby/Ruby.java:2650:in `parseFile'
org/jruby/Ruby.java:2637:in `parseFile'
org/jruby/Ruby.java:2860:in `loadFile'
org/jruby/runtime/load/LibrarySearcher.java:249:in `loadScript'
org/jruby/runtime/load/LibrarySearcher.java:237:in `load'
org/jruby/runtime/load/LibrarySearcher.java:35:in `load'
org/jruby/runtime/load/LoadService.java:326:in `load'
org/jruby/RubyKernel.java:977:in `loadCommon'
org/jruby/RubyKernel.java:969:in `load19'
org/jruby/ir/runtime/IRRuntimeHelpers.java:871:in `unresolvedSuper'
org/jruby/ir/instructions/ZSuperInstr.java:40:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:324:in `processCall'
org/jruby/ir/interpreter/Interpreter.java:551:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:639:in `INTERPRET_BLOCK'
org/jruby/runtime/InterpretedIRBlockBody.java:74:in `commonYieldPath'
org/jruby/runtime/IRBlockBody.java:84:in `yieldSpecific'
org/jruby/runtime/Block.java:116:in `yieldSpecific'
org/jruby/ir/runtime/IRRuntimeHelpers.java:450:in `yieldSpecific'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/activesupport_minus_4_dot_2_dot_0/lib/active_support//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:106:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:115:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:272:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:78:in `callBlock'
org/jruby/runtime/callsite/CachingCallSite.java:82:in `call'
org/jruby/ir/instructions/CallBase.java:388:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:320:in `processCall'
org/jruby/ir/interpreter/Interpreter.java:551:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:654:in `INTERPRET_METHOD'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:147:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `run_tasks_blocks_CLOSURE_1__run_tasks_blocks_0'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/railties_minus_4_dot_2_dot_0/lib/rails//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `run_tasks_blocks_CLOSURE_1__run_tasks_blocks_0'
org/jruby/runtime/CompiledIRBlockBody.java:66:in `commonYieldPath'
org/jruby/runtime/IRBlockBody.java:145:in `doYield'
org/jruby/runtime/BlockBody.java:82:in `yield'
org/jruby/runtime/Block.java:147:in `yield'
org/jruby/RubyArray.java:1569:in `each'
org/jruby/runtime/callsite/CachingCallSite.java:138:in `callBlock'
org/jruby/runtime/callsite/CachingCallSite.java:144:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/railties_minus_4_dot_2_dot_0/lib/rails//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:658:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:106:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:115:in `call'
org/jruby/ir/runtime/IRRuntimeHelpers.java:833:in `instanceSuper'
org/jruby/ir/runtime/IRRuntimeHelpers.java:826:in `instanceSuperSplatArgs'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/application.rb:438:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/railties_minus_4_dot_2_dot_0/lib/rails//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/application.rb:438:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:138:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:145:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:453:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/railties_minus_4_dot_2_dot_0/lib/rails//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/railties-4.2.0/lib/rails/engine.rb:453:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:106:in `call'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:118:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:198:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:292:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:130:in `call'
org/jruby/ir/interpreter/Interpreter.java:308:in `processCall'
org/jruby/ir/interpreter/Interpreter.java:551:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:619:in `INTERPRET_ROOT'
org/jruby/ir/interpreter/Interpreter.java:100:in `execute'
org/jruby/ir/interpreter/Interpreter.java:28:in `execute'
org/jruby/ir/IRTranslator.java:39:in `execute'
org/jruby/Ruby.java:844:in `runInterpreter'
org/jruby/Ruby.java:2867:in `loadFile'
org/jruby/runtime/load/LibrarySearcher.java:249:in `loadScript'
org/jruby/runtime/load/LibrarySearcher.java:237:in `load'
org/jruby/runtime/load/LibrarySearcher.java:35:in `load'
org/jruby/runtime/load/LoadService.java:326:in `load'
org/jruby/RubyKernel.java:977:in `loadCommon'
org/jruby/RubyKernel.java:969:in `load19'
org/jruby/internal/runtime/methods/DynamicMethod.java:210:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:138:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:145:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:690:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:690:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:198:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:292:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:130:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:94:in `load_rakefile_CLOSURE_1__load_rakefile_1'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:94:in `load_rakefile_CLOSURE_1__load_rakefile_1'
org/jruby/runtime/CompiledIRBlockBody.java:66:in `commonYieldPath'
org/jruby/runtime/IRBlockBody.java:84:in `yieldSpecific'
org/jruby/runtime/Block.java:116:in `yieldSpecific'
org/jruby/ir/runtime/IRRuntimeHelpers.java:450:in `yieldSpecific'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:302:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:140:in `callBlock'
org/jruby/runtime/callsite/CachingCallSite.java:144:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:93:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:93:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:198:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:292:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:130:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:77:in `run_CLOSURE_1__run_1'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:77:in `run_CLOSURE_1__run_1'
org/jruby/runtime/CompiledIRBlockBody.java:66:in `commonYieldPath'
org/jruby/runtime/IRBlockBody.java:84:in `yieldSpecific'
org/jruby/runtime/Block.java:116:in `yieldSpecific'
org/jruby/ir/runtime/IRRuntimeHelpers.java:450:in `yieldSpecific'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:302:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:140:in `callBlock'
org/jruby/runtime/callsite/CachingCallSite.java:144:in `call'
/Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in `__script__'
Users/Adam/Documents/Rails_minus_Projects/BlackBird/$_dot_bundle/gems/gems/rake_minus_10_dot_4_dot_2/lib/rake//Users/Adam/Documents/Rails-Projects/BlackBird/.bundle/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in `__script__'
org/jruby/internal/runtime/methods/CompiledIRMethod.java:122:in `call'
org/jruby/internal/runtime/methods/InterpretedIRMethod.java:130:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:198:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:292:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:130:in `call'
org/jruby/ir/interpreter/Interpreter.java:308:in `processCall'
org/jruby/ir/interpreter/Interpreter.java:551:in `interpret'
org/jruby/ir/interpreter/Interpreter.java:619:in `INTERPRET_ROOT'
org/jruby/ir/interpreter/Interpreter.java:100:in `execute'
org/jruby/ir/interpreter/Interpreter.java:28:in `execute'
org/jruby/ir/IRTranslator.java:39:in `execute'
org/jruby/Ruby.java:844:in `runInterpreter'
org/jruby/Ruby.java:2867:in `loadFile'
org/jruby/runtime/load/LibrarySearcher.java:249:in `loadScript'
org/jruby/runtime/load/LibrarySearcher.java:237:in `load'
org/jruby/runtime/load/LibrarySearcher.java:35:in `load'
org/jruby/runtime/load/LoadService.java:326:in `load'
org/jruby/RubyKernel.java:977:in `loadCommon'
org/jruby/RubyKernel.java:969:in `load19'
org/jruby/internal/runtime/methods/DynamicMethod.java:210:in `call'
org/jruby/internal/runtime/methods/DynamicMethod.java:206:in `call'
org/jruby/runtime/callsite/CachingCallSite.java:312:in `cacheAndCall'
org/jruby/runtime/callsite/CachingCallSite.java:162:in `call'
bin/rake:16:in `__script__'
bin/bin/rake:16:in `__script__'
java/lang/invoke/MethodHandle.java:599:in `invokeWithArguments'
org/jruby/ir/Compiler.java:112:in `load'
org/jruby/Ruby.java:817:in `runScript'
org/jruby/Ruby.java:810:in `runScript'
org/jruby/Ruby.java:761:in `runNormally'
org/jruby/Ruby.java:569:in `runFromMain'
org/jruby/Main.java:405:in `doRunFromMain'
org/jruby/Main.java:300:in `internalRun'
org/jruby/Main.java:227:in `run'
org/jruby/Main.java:199:in `main'

My conclusion from this is that Because Java has a SecureRandom class and Ruby has the same class that they are conflicting?

@enebo

Do you guys run the rails test suite? I also upgrade rails regularly, so if a new update comes out I usually upgrade, Security or other wise.

@rtyler rtyler added the JRuby 9000 label Jan 22, 2015

@AdamKyle

This comment has been minimized.

Show comment
Hide comment
@AdamKyle

AdamKyle Jan 22, 2015

After comparing with some of my rails friends, to make sure I wasn't on drugs it does seem to be a parser error.

AdamKyle commented Jan 22, 2015

After comparing with some of my rails friends, to make sure I wasn't on drugs it does seem to be a parser error.

@enebo enebo added this to the JRuby 9.0.0.0 milestone Jul 15, 2015

@enebo enebo added the parser label Jul 15, 2015

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Jul 15, 2015

Member

I cannot see the issue this is in our tracker but I fixed this bug 2-3 weeks ago with a ton of other mixed hash + {} and [] sorts of bugs.

@AdamKyle If I really did not fix this then re-open but I would bet some cash I did...

Member

enebo commented Jul 15, 2015

I cannot see the issue this is in our tracker but I fixed this bug 2-3 weeks ago with a ton of other mixed hash + {} and [] sorts of bugs.

@AdamKyle If I really did not fix this then re-open but I would bet some cash I did...

@enebo enebo closed this Jul 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment