Remove bash invocation on Windows in rebar_utils:sh/2

Jan Klötzke jan.kloetzke at freenet.de
Fri Sep 30 10:18:53 EDT 2011


Hi,

The following applies to rebar on Windows only!

I've recently submitted a pull request to remove the bash invocation on 
Windows in rebar_utils:sh/2 (see https://github.com/basho/rebar/pull/142). 
It's not intended for immediate merging but rather than to be *tested* by some 
folks who use rebar on Windows, preferably with one of the less commonly used 
features.

So, if you are using rebar on Windows then I would appreciate any feedback.

== Rationale ==

Currently rebar_utils:sh/2 will invoke all commands through bash.exe if found. 
Otherwise the command will be executed directly. Despite the fact that the 
caller cannot know if the command is executed with Unix or Windows semantics 
it leads to the following problem:

The rebar_file_utils module (namely rm_rf/1, cp_r/2 and mv/2) is not working 
as expected on Windows when MSYS is installed. These functions call cmd.exe 
with some options (e.g. /c) and native path names. There are two problems with 
this: first any backslashes would have to be escaped (easy to fix) and options 
like '/c' are expanded to 'C:\' by the MSYS automatic path name translation.

You can observe this automatic path name translation by trying the following: 
open a MSYS bash and type:

 $ cmd /c /q @echo foo

Instead of just seeing 'foo' being printed you end up on the cmd.exe prompt. 
Now type

 > echo %CMDCMDLINE%

to see what actually got executed (e.g. "c:\WINDOWS\system32\cmd.exe C:/ 
C:/Programme/Git/q echo foo" in my case).

Probably, though I haven't checked, the following problems are also affected 
by using bash on Windows: 

http://lists.basho.com/pipermail/rebar_lists.basho.com/2011-
September/001045.html

http://lists.basho.com/pipermail/rebar_lists.basho.com/2011-
September/001058.html

== Conclusion ==

Don't use bash on Windows to get a consistent behavior and to avoid the 
peculiarities of MSYS's automatic path conversion.

== Impact ==

Basically all rebar_utils:sh/2 calls are affected on Windows.

I did test the following rebar commands and they are working as expected 
AFAICT:

 * clean
 * compile (*.erl, *.app.src, *.c)
 * create
 * *-deps
 * generate

and additionally the rebar_file_utils eunit test suite.

What _may_ not work anymore are the following modules, even if MSYS is 
installed, because they use e.g. 'grep' and output redirection:

 * rebar_neotoma_compiler
 * rebar_erlydtl_compiler
 * rebar_ct

If anybody uses these features on Windows then I'd love to get some testing 
feedback...

Regards,
Jan



More information about the rebar mailing list