Error building on Windows #32

Closed
mrlucmorin opened this Issue Jan 9, 2012 · 18 comments

Comments

Projects
None yet
7 participants

Hi,

I'm trying to build the boilerplate without modifications (maybe THAT's the problem), and here's what I get:

luc@STLMDELL /d/dojo-boilerplate (master)
$ ./build.sh
Building application with /d/dojo-boilerplate/src/app/app.profile.js to /d/dojo-boilerplate/dist.
Cleaning old files... Done
error(344) File does not exist. require: d:/dojo-boilerplate/src/util/buildscripts/d:/dojo-boilerplate/src/app/run.js
error(344) File does not exist. profile: d:/dojo-boilerplate/src/util/buildscripts/d:/dojo-boilerplate/src/app/app.profi
le.js
errors on command line; terminating application.

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: process.stdout cannot be closed
at WriteStream. (node.js:284:15)
at Object.exit (build/node/process:13:19)
at build/argv:534:11
at d:\dojo-boilerplate\src\dojo\dojo.js:997:43
at d:\dojo-boilerplate\src\dojo\dojo.js:1123:5
at d:\dojo-boilerplate\src\dojo\dojo.js:1114:12
at d:\dojo-boilerplate\src\dojo\dojo.js:1114:12
at d:\dojo-boilerplate\src\dojo\dojo.js:715:5
at d:\dojo-boilerplate\src\dojo\dojo.js:733:13
at build/main:84:2

luc@STLMDELL /d/dojo-boilerplate (master)
$ node -v
v0.6.7

I'm pretty near sure I followed instructions properly, but who knows...

Anyone can shed light on this ?

Thank you.

Owner

csnover commented Jan 10, 2012

Is this MSYS or cygwin or something else that you are trying to use?

(n.b. The last error about process.stdout is a known issue with the Dojo builder and Node 0.6 and does not affect functionality.)

I'm sorry, I should have mentioned the environment.

I'm using the git bash shell from msysgit.

When you say "does not affect functionality", do you mean that I can still use dojo-boilerplate even if it doesn't build properly ?

I've been trying to understand the build process, and I have to admit that I'm completely lost (I,m new to this stuff).

What I notice is that the path to the "profile" and "require" parameters is wrong:

d:/dojo-boilerplate/src/util/buildscripts/d:/dojo-boilerplate/src/app/run.js
d:/dojo-boilerplate/src/util/buildscripts/d:/dojo-boilerplate/src/app/app.profi
le.js

As you can see, the drive letter is showing up twice in those paths.

I simply added "echo $PROFILE" and "echo $LOADERCONF" to build.sh, and they are good up to that point. It seems that somewhere within dojo.js (or dependents) those paths get mangled.

Any ideas ?

Thanks

casio commented Jan 12, 2012

I'm on Mac OS Lion, node v0.6.6 and also get 'Error: process.stdout cannot be closed' when trying to build the vanilla version of boilerplate.

Even when this is a known issue of the builder, it actually does affect the functionality of build.sh:
index.html isnt processed & copied to /dist.

Is it possible to catch this Error & continue processing?

rhelms commented Jan 13, 2012

I had a look at the build.sh process using node on Windows.
The first problem is that code to recognised windows when running under node has not been complete. See util/build/main.js, and the has.add("is-windows", 0); line. Change that to a 1 (or know enough about node to fill in the proper detection).

The second problem is that the getAbsolutePath function in util/build/fileUtils.js does not take windows into account, and assumes the first character of an absolute path will be /. To fix this, change the if statement to "if (!isAbsolutePath(src)){".

Once that is done, some other problem presents itself:

Building application with /c/Dev/projects/dojo-boilerplate/src/app/app.profile.js to /c/Dev/projects/dojo-boilerplate/dist.
Cleaning old files... Done
processing require resource c:/Dev/projects/dojo-boilerplate/src/app/run.js
processing profile resource c:/Dev/projects/dojo-boilerplate/src/app/app.profile.js
info(107) Package Version: package: dojo; version: 1.7.1
processing profile resource c:/Dev/projects/dojo-boilerplate/src/dojo/dojo.profile.js
info(107) Package Version: package: dijit; version: 1.7.1
processing profile resource c:/Dev/projects/dojo-boilerplate/src/dijit/dijit.profile.js
info(107) Package Version: package: dojox; version: 1.7.1
processing profile resource c:/Dev/projects/dojo-boilerplate/src/dojox/dojox.profile.js
info(107) Package Version: package: app; version: 1.0
processing profile resource c:/Dev/projects/dojo-boilerplate/src/app/app.profile.js
warn(209) Missing or empty package.json. filename: c:/Dev/projects/dojo-boilerplate/src/dbp/package.json
discovering resources...
starting reading resources...
starting processing raw resource content...
starting tokenizing resource...
starting processing resource tokens...
starting parsing resource...
./build.sh: line 57: /c/Dev/projects/dojo-boilerplate/dist/index.html: No such file or directory

At some point, processing drops out and no dist is made. I'll see what I can discover there. Otherwise, it might be better to not build with node under Windows.

darvelo commented Jan 16, 2012

The dojo builder error "process.stdout cannot be closed" might be related to this issue in the node github repository. We can follow that thread in addition to @rhelms suggestions to try to get closer to the solution, I think.

casio commented Jan 16, 2012

For the time being people can also get the build script to finnish successfully by applying this patch to the subrepo in src/util.

➜  util  git diff
diff --git a/build/main.js b/build/main.js
index 4cc4f9e..a895534 100644
--- a/build/main.js
+++ b/build/main.js
@@ -183,7 +183,11 @@ define(["require", "dojo/has"], function(require, has) {
                                                bc.log("discoveryFailed");
                                        }
                                        bc.log("pacify", "Process finished normally.\n\terrors: " + bc.getErrorCount() + "\n\twarnings: " + bc.getWarnCount() + "\n\tbuild time: " + 
-                                       process.exit(bc.exitCode);
+                                       try {
+                                               process.exit(bc.exitCode);
+                                       } catch(e) {
+                                               console.error(e);
+                                       }
                                        // that's all, folks...
                                }
                        };

am-a commented Jan 20, 2012

Carkrass this didn't work for me - Any hints on how to apply the patch properly?

casio commented Jan 20, 2012

@am-a: basically its just wrapping process.exit(...) with a try/catch statement.
For me, this results in an error message being logged but the build process can finnish successfully.
You can just do it by hand or maybe this helps: http://linux.die.net/man/1/git-apply

am-a commented Jan 20, 2012

I did apply the patch manually but it still doesn't finish - this may be related to the changes I made as suggested above or did you also make those changes?

casio commented Jan 20, 2012

@am-a: Nope, I didnt.

am-a commented Jan 20, 2012

I will debug node and see what I get - what version of node are you using - I undid the changes to no avail

casio commented Jan 20, 2012

I just did a new clone of this repo. I'm on Mac OS, node v0.6.6.

Changing line 186 of ./src/util/build/main.js from

process.exit(bc.exitCode);

to

try { process.exit(bc.exitCode); } catch(e) { console.error(e) }

does the trick for me.
At least in terms of the build process itself: after running ./build.sh I have an index.html in ./dist (which is the last step in build.sh).

However, there are some errors from the closue compiler in the build now, but I guess they're not related to the building process.

Owner

csnover commented Jan 22, 2012

Hi everyone,

Issue with stdout crash is reported upstream at http://bugs.dojotoolkit.org/ticket/14260. Issue with paths being busted may be http://bugs.dojotoolkit.org/ticket/14564; I am cross-referencing this ticket there.

I will introduce a hack to allow dbp’s build.sh to work with node 0.6 for the time being as well.

Thanks,

Owner

csnover commented Feb 16, 2012

This should be addressed now with the update to Dojo 1.7.2. Please comment here again if not.

csnover closed this Feb 16, 2012

rhelms commented Feb 22, 2012

Having another crack at this. dojo-boilerplate is at c952e71 "Fix builds with 1.7.2".
The submodule dependencies are at the 1.7.2 tag.
Node is at v0.6.11.
I'm on Windows 7, and am using the Git Bash available in msysgit 1.7.9.

Reuben@REUBEN-PC /c/Dev/projects/dojo-boilerplate (master)
$ git --version
git version 1.7.9.msysgit.0

Reuben@REUBEN-PC /c/Dev/projects/dojo-boilerplate (master)
$ node --version
v0.6.11

Reuben@REUBEN-PC /c/Dev/projects/dojo-boilerplate (master)
$ ./build.sh
Building application with /c/Dev/projects/dojo-boilerplate/src/app/app.profile.j
s to /c/Dev/projects/dojo-boilerplate/dist.
Cleaning old files... Done
error(344) File does not exist. require: c:/Dev/projects/dojo-boilerplate/src/ut
il/buildscripts/c:/Dev/projects/dojo-boilerplate/src/app/run.js
error(344) File does not exist. profile: c:/Dev/projects/dojo-boilerplate/src/ut
il/buildscripts/c:/Dev/projects/dojo-boilerplate/src/app/app.profile.js
errors on command line; terminating application.
./build.sh: line 56: /c/Dev/projects/dojo-boilerplate/dist/index.html: No such f
ile or directory

If I update util/build/main.js, Line 52, to "has.add("is-windows", 1);" so that it can recognise this as being a Window platform (not the ideal solution, but it gets me closer to using node on a windows platform for dojo builds), I get this:

Reuben@REUBEN-PC /c/Dev/projects/dojo-boilerplate (master)
$ ./build.sh
Building application with /c/Dev/projects/dojo-boilerplate/src/app/app.profile.j
s to /c/Dev/projects/dojo-boilerplate/dist.
Cleaning old files... Done
processing require resource c:/Dev/projects/dojo-boilerplate/src/app/run.js
processing profile resource c:/Dev/projects/dojo-boilerplate/src/app/app.profile
.js
info(107) Package Version: package: dojo; version: 1.7.2
processing profile resource c:/Dev/projects/dojo-boilerplate/src/dojo/dojo.profi
le.js
info(107) Package Version: package: dijit; version: 1.7.2
processing profile resource c:/Dev/projects/dojo-boilerplate/src/dijit/dijit.pro
file.js
info(107) Package Version: package: dojox; version: 1.7.2
processing profile resource c:/Dev/projects/dojo-boilerplate/src/dojox/dojox.pro
file.js
info(107) Package Version: package: app; version: 1.0
processing profile resource c:/Dev/projects/dojo-boilerplate/src/app/app.profile
.js
warn(209) Missing or empty package.json. filename: c:/Dev/projects/dojo-boilerpl
ate/src/dbp/package.json
discovering resources...
starting reading resources...
starting processing raw resource content...
starting tokenizing resource...
starting processing resource tokens...
starting parsing resource...
./build.sh: line 56: /c/Dev/projects/dojo-boilerplate/dist/index.html: No such f
ile or directory

That's further than before, but stops prior to the AST processing (from memory).

Just noting here, before I go digging around to see why it's not going all the way. At this point, it's most likely an issue with Dojo doing builds on Windows with node, than dojo-boilerplate. If this needs to be raised as a bug or enhancement with Dojo instead of here, let me know.

rhelms commented Feb 22, 2012

I had a bit more of a play.

The first thing I found, that is not an issue is the "if (--bc.waiting) {" line for the passGate function in util/build/main.js. Due to some cracked logic in my head, I thought things might move along better if it read "if (--bc.waiting > 0) {", since it would only ever evaluate to false if bc.waiting was 1 going in. In my test runs using node, that never seems to happen, and bc.waiting sails from 2 to 0 when passing through that point (or 1 to -1, if you're looking at it post evaluation). Whilst completely wrong, it did lead me to my next discovery.

node on Windows is only supported in cygwin! msysgit does not cut the mustard.

in util/build/transforms/writeOptimized.js, there is an explicit check for the global.process.platform equalling "cygwin". The Git Bash will identify itself as being "win32".

And this brings me back to my wrong headed thought for "if (--bc.waiting) {" in the passGate. There is probably something else that doesn't like being processed under win32, instead of cygwin, and it's failing silently, rather than kicking up a stink.

Now that I've worked this out, I'm off to get cygwin.

Would it be worth supporting node builds under the Windows Git Bash environment? I should think it might be fairly popular for Windows developers using Git that don't want to have to maintain a while separate cygwin environment.

rhelms commented Feb 22, 2012

Now I've got a "default" install of cygwin (1.7.10-1).

With the 'has.add("is-windows", 0);' at the 0 state for host-node (and a dos2unix on the build.sh), I get this:

Reuben@Reuben-PC /cygdrive/c/dev/projects/dojo-boilerplate
$ ./build.sh
Building application with /cygdrive/c/dev/projects/dojo-boilerplate/src/app/app.profile.js to /cygdrive/c/dev/projects/dojo-boilerplate/dist.
Cleaning old files... Done
error(344) File does not exist. require: /cygdrive/c/dev/projects/dojo-boilerplate/src/app/run.js
error(344) File does not exist. profile: /cygdrive/c/dev/projects/dojo-boilerplate/src/app/app.profile.js
errors on command line; terminating application.
./build.sh: line 56: /cygdrive/c/dev/projects/dojo-boilerplate/dist/index.html: No such file or directory

If I enable is-windows to 1, I get this:

Reuben@Reuben-PC /cygdrive/c/dev/projects/dojo-boilerplate
$ ./build.sh
Building application with /cygdrive/c/dev/projects/dojo-boilerplate/src/app/app.profile.js to /cygdrive/c/dev/projects/dojo-boilerplate/dist.
Cleaning old files... Done
error(344) File does not exist. require: C:/dev/projects/dojo-boilerplate/src/util/buildscripts/cygdrive/c/dev/projects/dojo-boilerplate/src/app/run.js
error(344) File does not exist. profile: C:/dev/projects/dojo-boilerplate/src/util/buildscripts/cygdrive/c/dev/projects/dojo-boilerplate/src/app/app.profile.js
errors on command line; terminating application.
./build.sh: line 56: /cygdrive/c/dev/projects/dojo-boilerplate/dist/index.html: No such file or directory

Possibly my cygwin installation is not set up properly, or node can't handle /cygdrive/ in a Windows environment, or I need to compile node from source under cygwin.

Leftium commented Jun 10, 2012

@rhelms You need to do two things:

  1. Apply the patch attached to this Dojo ticket. It gets Node to call the Java bits properly.
  2. Send node file paths it can comprehend. Node doesn't understand filepaths that start with /cygdrive/ (Alternatively, you can use Msys instead of Cgywin. Msys doesn't do the weird cygdrive path thing. The easiest way to install Msys is to install Git for Windows.) There may be a more elegant solution, but I simply hard-coded the paths in build.sh:
LOADERCONF='c:/dropbox/proj/dojo-boilerplate/src/app/run.js'
PROFILE='c:/dropbox/proj/dojo-boilerplate/src/app/app.profile.js'
DISTDIR='c:/dropbox/proj/dojo-boilerplate/dist'
SRCDIR='c:/dropbox/proj/dojo-boilerplate/src'

echo "Building application with $PROFILE to $DISTDIR."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment