Skip to content

Instantly share code, notes, and snippets.

@databus23
Created November 18, 2013 17:22
Show Gist options
  • Save databus23/7531670 to your computer and use it in GitHub Desktop.
Save databus23/7531670 to your computer and use it in GitHub Desktop.
IO.read fails to return complete file content on windows ruby 1.9.3p448
IO.read length: 1778
IO.binread length: 2395
next character after read_string: "\x1A"
context after read_string: "TI\"\x0FC:\\Windows\x06;\x00TI\"\x1Awindows_tracing_fla"
test.rb:60:in `load': marshal data too short (ArgumentError)
from test.rb:60:in `<main>'
# encoding: utf-8
config = {
"argv"=>"git fetch",
"env"=>{
"LC_ALL"=>"C",
"APPDATA"=>"C:\\Windows\\system32\\config\\systemprofile\\AppData\\Roaming",
"CommonProgramFiles"=>"C:\\Program Files (x86)\\Common Files",
"CommonProgramFiles(x86)"=>"C:\\Program Files (x86)\\Common Files",
"CommonProgramW6432"=>"C:\\Program Files\\Common Files",
"COMPUTERNAME"=>"MO-FA64184F8",
"ComSpec"=>"C:\\Windows\\system32\\cmd.exe",
"FP_NO_HOST_CHECK"=>"NO",
"HOME"=>"C:/Windows/system32/config/systemprofile",
"LOCALAPPDATA"=>"C:\\Windows\\system32\\config\\systemprofile\\AppData\\Local",
"NUMBER_OF_PROCESSORS"=>"4",
"OS"=>"Windows_NT",
"Path"=>"C:\\Program Files (x86)\\Git\\Cmd;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin;",
"PATHEXT"=>".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC",
"PROCESSOR_ARCHITECTURE"=>"x86",
"PROCESSOR_ARCHITEW6432"=>"AMD64",
"PROCESSOR_IDENTIFIER"=>"Intel64 Family 6 Model 47 Stepping 2, GenuineIntel",
"PROCESSOR_LEVEL"=>"6",
"PROCESSOR_REVISION"=>"2f02",
"ProgramData"=>"C:\\ProgramData",
"ProgramFiles"=>"C:\\Program Files (x86)",
"ProgramFiles(x86)"=>"C:\\Program Files (x86)",
"ProgramW6432"=>"C:\\Program Files",
"PSModulePath"=>"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\",
"PUBLIC"=>"C:\\Users\\Public",
"SystemDrive"=>"C:",
"SystemRoot"=>"C:\\Windows",
"TEMP"=>"C:\\Windows\\TEMP",
"TMP"=>"C:\\Windows\\TEMP",
"USER"=>"MO-FA64184F8$",
"USERDOMAIN"=>"WORKGROUP",
"USERNAME"=>"MO-FA64184F8$",
"USERPROFILE"=>"C:\\Windows\\system32\\config\\systemprofile",
"windir"=>"C:\\Windows",
"windows_tracing_flags"=>"3",
"windows_tracing_logfile"=>"C:\\BVTBin\\Tests\\installpackage\\csilogfile.log",
"GIT_SSH"=>"C:/blafasel/git_ssh.bat",
"SYSTEMU_TURD"=>"X"
},
"cwd"=>"/var/lib/blafasel/repos/devel/mcollective",
"stdin"=>"C:/Windows/Temp/systemu_mo-fa64184f8_540_3960_0.1555892908668568_1/stdin",
"stdout"=>"C:/Windows/Temp/systemu_mo-fa64184f8_540_3960_0.1555892908668568_1/stdout",
"stderr"=>"C:/Windows/Temp/systemu_mo-fa64184f8_540_3960_0.1555892908668568_1/stderr",
"program"=>"C:/Windows/Temp/systemu_mo-fa64184f8_540_3960_0.1555892908668568_1/program"
}
open('dump', 'wb') {|f|Marshal.dump config, f}
read_string = IO.read('dump')
binread_string = IO.binread('dump')
puts "IO.read length: #{read_string.length}"
puts "IO.binread length: #{binread_string.length}"
puts "next character after read_string end: #{binread_string[read_string.length].inspect}"
puts "context around read_string end: #{binread_string[read_string.length-20,40].inspect}"
Marshal.load IO.read('dump')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment