I've got a problem I don't fully understand. I keep wanting to call it a bug, but it may be that I'm handling this wrongly.<br><br>During my attempt to compile and install a module from code, it seems I've managed to break the Erlang VMs I'm installing into. My gut instinct is that my namespaced module sc.file is somehow conflicting with the real module file. This is frustrating, because after my compile process it appears to work as expected; sc.file is treated differently than file, all package calls are resolved appropriately, etc. But, on next start, one gets the following error:<br>
<br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace; color: rgb(51, 51, 153);">Erlang (BEAM) emulator version 5.6.4 [smp:2] [async-threads:0]</span><br style="font-family: courier new,monospace; color: rgb(51, 51, 153);">
<br style="font-family: courier new,monospace; color: rgb(51, 51, 153);"><span style="font-family: courier new,monospace; color: rgb(51, 51, 153);">{"init terminating in do_boot",{undef,<br> [{file,path_eval,[[".","C:\Users\John Haugeland"],".erlang"]},<br>
{c,f_p_e,2},{init,eval_script,7},{init,do_boot,3}]}}</span><br style="font-family: courier new,monospace; color: rgb(51, 51, 153);"><br style="font-family: courier new,monospace; color: rgb(51, 51, 153);"><span style="font-family: courier new,monospace; color: rgb(51, 51, 153);">Crash dump was written to: erl_crash.dump</span><br style="font-family: courier new,monospace; color: rgb(51, 51, 153);">
<span style="font-family: courier new,monospace; color: rgb(51, 51, 153);">init terminating in do_boot ()</span><br style="font-family: courier new,monospace; color: rgb(51, 51, 153);"><br style="font-family: courier new,monospace; color: rgb(51, 51, 153);">
<span style="font-family: courier new,monospace; color: rgb(51, 51, 153);">Abnormal termination</span><br></div><br>(Formatted that a little to make it fit email)<br><br>And I mean, that kind of looks like that's the Erlang VM saying "I have no function path_eval in module file", and as stupid as it sounds, the back of my mind is screaming "it's because sc.file overrides real .file".<br>
<br>I have replicated this on Windows Vista HP-32 5.6.4, Windows Vista HP-32 5.5.5 and Centos4-32 5.6.4. All I have to do is run my install process, where everything appears to go kosher, then restart the Erlang VM.<br><br>
So, my method of "installing" is to take the source root directory and call .compile:file() progressively on each source file. Then I use .code:get_object_code() to get the binary and the filename, which I pass with the module name as an atom to .code:load_binary() to load the actual code (since :load.module() doesn't seem to understand package names). I'm actually going to show my install process twice, because there's a much shorter version and a much longer version. The shorter version is used to compile my string module, which contains utilities that the installer uses, so that it can turn around and install everything else. As such, it's a single special case and shows my expectation of The Right Way to do this in a very short space; that way if I'm just taking a numbskulled approach someone can point out my fool fault with little effort. Then I'm posting the long version, in case it's somehow importantly different than the string special case.<br>
<br>But frankly, here's how this seems to me: I think the packaged modules are conflicting at boot time with the real thing. I can't imagine any other reason for do_boot to complain that a function that's part of the standard library is unavailable.<br>
<br>If for whatever reason this code is unreadable, it can be gotten at <a href="http://scutil.com/">http://scutil.com/</a> from /src/sc/installer.erl . I would recommend installing it on an isolated VM; calling the installer will prevent that VM from booting again.<br>
<br>The short one (note that get_object_code seems only to work with the "un-packaged" name, which I worry is part of the problem):<br><br><div style="margin-left: 40px; font-family: courier new,monospace; color: rgb(0, 102, 0);">
.compile:file(From++"/src/sc/string.erl"),<br>{_, Bin, FileName} = .code:get_object_code(string),<br>.code:load_binary('sc.string', FileName, Bin),<br></div><br>The long one:<br><br><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);">compile_all(From, Options) -></span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ReportOnCompile = fun</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ( Module, error) -> { error, Module };</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ( Module, {error, ErrorList, WarningList}) -> { error, Module, ErrorList, WarningList };</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> (_Module, {ok,AtomName}) -> AtomName;</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> (_Module, {ok,AtomName, Warnings}) -> { AtomName, Warnings }</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> end,</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> IsFailureCase = fun</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ({ error,_Module }) -> true;</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ({ error,_Module,_ErrorList,_WarningList }) -> true;</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> (_) -> false</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> end,</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> IsWarningCase = fun</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ({_ModuleAtom, [] }) -> false;</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ({_ModuleAtom,_Warnings }) -> true</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> end,</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ToFilename = fun</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> (List) when is_list(List) -> .sc.string:implode("/", [ atom_to_list(Item) || Item <- List ]) ++ ".erl";</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> (Atom) when is_atom(Atom) -> atom_to_list(Atom) ++ ".erl"</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> end,</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> Report = [ ReportOnCompile(From ++ ToFilename(File), .compile:file(From ++ ToFilename(File), Options)) ||</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> File <- contained_modules()</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> ],</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> { Fail, PassWarn } = .lists:partition(IsFailureCase, Report),</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> { Warn, Pass } = .lists:partition(IsWarningCase, PassWarn),</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> LoadFile = fun(Passed) -></span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> [LastPiece|_] = .lists:reverse(.sc.string:explode(".", atom_to_list(Passed))),</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> {_, Bin, FileName} = .code:get_object_code(list_to_atom(LastPiece)),</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> .code:load_binary(Passed, FileName, Bin)</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> end,</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> [ LoadFile(Passed) || {Passed,[]} <- Pass ],</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<br style="font-family: courier new,monospace; color: rgb(102, 102, 0);"><span style="font-family: courier new,monospace; color: rgb(102, 102, 0);"> { { pass, Pass }, { warn, Warn }, { fail, Fail } }.</span><br style="font-family: courier new,monospace; color: rgb(102, 102, 0);">
<br>I know it's a lot to ask, but I could use some help sorting this out; these parts of the standard library aren't well documented, and I wouldn't want to think one could break an erlang install by compiling and loading modules containing correct code under a name which should not but does conflict. I really want there to be a stupid mistake on my part here. <br>
<br>Any help would be greatly appreciated.<br>