Skip to content
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

mkdir -p doesn't work as expected on windows #2027

Closed
ajmh opened this issue Jan 11, 2012 · 15 comments
Closed

mkdir -p doesn't work as expected on windows #2027

ajmh opened this issue Jan 11, 2012 · 15 comments

Comments

@ajmh
Copy link

ajmh commented Jan 11, 2012

The mkdir -p call in the writeJs() method in lib/coffee-script/command.js does not work as expected on Windows when using the coffee compiler on a source tree with sub-directories - it will actually create a new directory -p in the current working directory of the console environment instead.

Here is the code from the current master branch causing the problem:

return exec("mkdir -p " + jsDir, compile);

The recursive path creation behavior desired is natively available in Windows with mkdir if Command Extensions are enabled (which they are by default). Here is the MS documentation for mkdir on WinXP (seems to apply for Win7+ as well).

Perhaps this could check the process.platform flag (nodejs docs) for the Windows platform and omit the -p flag?

// ... somewhere early on - pre-set flag use for local platform
var mkdirFlag = '-p';
// Check for windows platform to vet flag
if (process.platform.substr(0,3) === 'win') {
  mkdirFlag = '';
}
// ... code ...
return exec("mkdir " + mkdirFlag + " " + jsDir, compile);
@jashkenas
Copy link
Owner

Ha -- with the release of Node 0.6, the Windows support struggle begins...

There are probably a number of places where we shell out in the compiler's helper scripts that we should be proofreading for this kind of thing.

@michaelficarra
Copy link
Collaborator

Yeah, I vote for changing this to a general "support windows" ticket.

@ajmh
Copy link
Author

ajmh commented Jan 11, 2012

I've been trying to do some heavy testing on windows since I want to use it in a client environment - this is the first oddity I've hit, but I'll feedback any other spots as I find them. Awesome package - props to everyone working on it.

@tylorr
Copy link

tylorr commented Sep 23, 2012

I am still getting this problem on windows. I am using coffee-script 1.3.3.

@rstehwien
Copy link

Still occurs in 1.4.0

@Philipp15b
Copy link

I also get this on 1.4.0. Are there any news on this? Why don't just use a plain JS solution, for example wrench has this.

@yazla
Copy link

yazla commented Mar 5, 2013

1.6.1 also has this issue.

@hickford
Copy link
Contributor

hickford commented Apr 2, 2013

@Philipp15b right pure Javascript would work more reliably than platform-dependant system calls. See https://github.com/ryanmcgrath/wrench-js/blob/master/lib/wrench.js#L356 or https://github.com/substack/node-mkdirp/blob/master/index.js

@katanacrimson
Copy link

This is constantly causing the directory -p to be created in the roots of my projects, this is an annoying bug and can be fixed with node-mkdirp and kin...

@vendethiel
Copy link
Collaborator

or with a real mkdir utility

@xixixao
Copy link
Contributor

xixixao commented Jun 7, 2013

+1 to fix this

@danielkcz
Copy link
Contributor

I am wondering, why that PR #2091 has been rejected. It works correctly at least on Windows 7. I removed -p argument locally and have no issues with directory creation whatsoever even deep ones.

Anyway there is no reason for the holdup as older Windows cannot create deep directories even with -p argument. I think it's better to support at least some Windows and not to bother everyone with odd directory created all the time.

I tried another approach (#3101) using node-mkdirp as @damianb noted above.

@Philipp15b
Copy link

Since #3101 is merged, this can finally be closed now. Thanks @FredyC and @jashkenas!

@katanacrimson
Copy link

Awesome. I take it we can expect this in coffeescript 1.6.4?

@hickford
Copy link
Contributor

hickford commented Aug 2, 2013

@damianb if you can't wait

npm install -g git+https://github.com/jashkenas/coffee-script.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests