Explanation of a line of code involving popen, split, merge and append

project
ruby

#1

I'm new to ruby, but not to programming in general. I am following the Spree Developer Getting Started Guide. I was able to install all the needful things, create a rails project, add Spree to it, and start the rails server. However, when going to http://localhost:300, there is an error. Top of the stack trace is a popen failure. I'm trying to figure out why the following line of code fails:

io = IO.popen(binary.split(' ') << filename, @popen_options.merge({err: [:child, :out]}))

I understand what most of the individual bits and pieces here mean, but I have a few questions. First, some information:

binary = cscript //E:jscript //Nologo //U
filename = some generated file name, e.g. execjs20160323-13236-1ub6xpdjs

Is it correct that this is trying to create the following command?

cscript //E:jscript //Nologo //U execjs20160323-13236-1ub6xpdjs

Or is it attempting to add the contents of the file to the end of that command via append? I'm not quite sure of the context of << in this usage.

The popen fails; error output is only a stacktrace, no specifics as to the nature of the failure, at least none that I can suss :slight_smile: I thought perhaps the file wasn't being generated, but "File.exist? filename" returns true. Anything else I could do in debugging to figure out the exact nature of the error?