-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
[Windows][9.1.6.0] Script output redirection fails #4550
Comments
interesting and quite a piece gone wrong, @PanDar1 any chance you test out 9.1.9 if its still there? |
I tried on 9.1.8.0, still present... do not currently have a 9.1.9 installed... |
@PanDar1 thanks, how about the other part I have asked for (we do not know what's in the script) :
|
Ok, I'm able to replicate the error with this: require 'rubygems' the error arise with the last line contents of database.yml follows: datasource: Error: Unhandled Java exception: java.lang.NullPointerException: charset invokeWithArguments at java/lang/invoke/MethodHandle:-1 load at org/jruby/ir/Compiler.java:111 runScript at org/jruby/Ruby.java:846 runNormally at org/jruby/Ruby.java:761 runNormally at org/jruby/Ruby.java:779 runFromMain at org/jruby/Ruby.java:592 doRunFromMain at org/jruby/Main.java:425 internalRun at org/jruby/Main.java:313 run at org/jruby/Main.java:242 main at org/jruby/Main.java:204 |
@PanDar1 That helps! It seems to be breaking inside psych. I'll have a look at that. |
Ok, so the basic problem is that it's trying to get a charset from the IO you pass in, via This combination of encodings causes a similar result:
So a short term fix for you might be to specify encodings here that we know work. I assume your YAML file is in UTF-8 (or simply 7-bit US-ASCII) so try doing this in your code:
I will file the Psych issue over there and see about fixing it. |
Well, I have worked around the bug by removing the redirection completely and writing on a file from the script, using this method... def to_log(msg) but I will give your workaround a try, thanks! |
You can also read the yaml content completely and pass the string to YAML.load, to avoid the IO/encoding dance. |
This is fixed in ruby/psych#319 and once there's a psych release we'll roll it into JRuby. |
Environment
jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) Client VM 23.3-b01 on 1.7.0_07-b10 +jit [mswin32-x86]
Using rails 5.0.1
Behaviour
Launching a script from command line and redirecting the output to a file give the following error:
C:\jrails4_update\applications\datawarehouse>jruby import_accounts.rb > ppp.txt
LoadError: load error: ./config/config -- java.lang.NullPointerException: charset
at import_accounts.rb:5require at org/jruby/RubyKernel.java:959
require at C:/jrails4_update/jruby-9.1.6.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55
Without redirection the script works as expected
The text was updated successfully, but these errors were encountered: