Cannot run program "scripts\saveVersion.sh"

用Maven 编译hadoop遇到以下错误:

saveVersion.sh script fails in windows/cygwin (hadoop-yarn-common)

,半天是个bug,解决方案如下:

 

Index: hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/scripts/saveVersion.sh
===================================================================
--- hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/scripts/saveVersion.sh	(revision 1304464)
+++ hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/scripts/saveVersion.sh	(working copy)
@@ -20,13 +20,13 @@
 # records the version, revision, branch, user, timestamp, and url
 unset LANG
 unset LC_CTYPE
-unset LC_TIME
-version=$1
-build_dir=$2
-user=`whoami`
-date=`date`
-dir=`pwd`
-cwd=`dirname $dir`
+unset LC_TIME
+version=$1
+build_dir=$2
+user=`whoami | tr '\n\r' '\n'`
+date=`date`
+dir=`pwd`
+cwd=`dirname $dir`
 if git rev-parse HEAD 2>/dev/null > /dev/null ; then
   revision=`git log -1 --pretty=format:"%H" ../`
   hostname=`hostname`
Index: hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/pom.xml
===================================================================
--- hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/pom.xml	(revision 1304464)
+++ hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/pom.xml	(working copy)
@@ -105,14 +105,15 @@
             </goals>
           </execution>
           <execution>
-            <id>generate-version</id>
-            <phase>generate-sources</phase>
-            <configuration>
-              <executable>scripts/saveVersion.sh</executable>
-              <arguments>
-                <argument>${project.version}</argument>
-                <argument>${project.build.directory}</argument>
-              </arguments>
+            <id>generate-version</id>
+            <phase>generate-sources</phase>
+            <configuration>
+              <executable>sh</executable>
+              <arguments>
+                <argument>scripts/saveVersion.sh</argument>
+                <argument>${project.version}</argument>
+                <argument>${project.build.directory}</argument>
+              </arguments>
             </configuration>
             <goals>
               <goal>exec</goal>
这个是patch MAPREDUCE-3540.patch ,修改以上2个文件就可以顺利通过编译了

                            

你可能感兴趣的:(version)