+++ This bug was cloned from Bug #1172381 +++ The scl-utils package is causing a problem in my rawhide environment. The environment function BASH_FUNC_scl() is set by /etc/profile.d/scl-init.sh and is defined in the bash shell environment as follows: $ env | tail -10 BASH_FUNC_module()=() { eval `/usr/bin/modulecmd bash $*` } BASH_FUNC_scl()=() { local CMD=$1; if [ "$CMD" = "load" -o "$CMD" = "unload" ]; then eval "module $@"; else /usr/bin/scl "$@"; fi } _=/usr/bin/env Bug #1 is the syntax error shown in output below which breaks a local maven build on rawhide (not seen on ubuntu or rhel6.6). I understand sh invocation obeys different rules to bash invocation according to bash(1) man page. $ mvn clean build ... ----------- cut ----------------- [INFO] Creating spec file /home/enoemcl/workspace/litp/<ERIClitpcli/ERIClitpcli_CXP9030420/target/rpm/ERIClitpcli_CXP9030420/SPECS/ERIClitpcli_CXP9030420.spec [WARNING] /bin/sh: scl: line 1: syntax error: unexpected end of file [WARNING] /bin/sh: error importing function definition for `BASH_FUNC_scl' [INFO] Building target platforms: noarch-redhat-linux [INFO] Building for target noarch-redhat-linux [INFO] Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.1vHlC2 [WARNING] /bin/sh: scl: line 1: syntax error: unexpected end of file [WARNING] error: Bad exit status from /var/tmp/rpm-tmp.1vHlC2 (%install) [WARNING] Bad exit status from /var/tmp/rpm-tmp.1vHlC2 (%install) ----------- cut ----------------- Bug #2 is how BASH_FUNC_xxx is not documented. $ man -k BASH_FUNC BASH_FUNC: nothing appropriate. WORKAROUNDS ATTEMPTED ********************** Remove the package solves the issue. # rpm -e scl-utils
See also: https://issues.jboss.org/browse/BYTEMAN-306
(In reply to Noel McLoughlin from comment #0) > The scl-utils package is causing a problem in my rawhide environment. The > environment function BASH_FUNC_scl() is set by /etc/profile.d/scl-init.sh > and is defined in the bash shell environment as follows: In itself, this is not a problem. > [INFO] Creating spec file > /home/enoemcl/workspace/litp/<ERIClitpcli/ERIClitpcli_CXP9030420/target/rpm/ > ERIClitpcli_CXP9030420/SPECS/ERIClitpcli_CXP9030420.spec > [WARNING] /bin/sh: scl: line 1: syntax error: unexpected end of file > [WARNING] /bin/sh: error importing function definition for `BASH_FUNC_scl' > [INFO] Building target platforms: noarch-redhat-linux > [INFO] Building for target noarch-redhat-linux > [INFO] Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.1vHlC2 > [WARNING] /bin/sh: scl: line 1: syntax error: unexpected end of file > [WARNING] error: Bad exit status from /var/tmp/rpm-tmp.1vHlC2 (%install) > [WARNING] Bad exit status from /var/tmp/rpm-tmp.1vHlC2 (%install) What does the RPM spec file look like?
Created attachment 1123278 [details] RPM SPEC See attached.
What seems to have happened here is that something has truncated the definition of the BASH_FUNC_scl() pseudo-environment variable to the first line. Somewhere, there is code in your environment which incorrectly serializes those environment variables. I don't see such code in scl-utils, so I suspect it's some thing else on your system.
Here is some debug output from Maven. I am not sure how Maven invokes execution of the following command but the truncation occurs when Maven executes the command by invoking /bin/sh for *this package*. [DEBUG] About to execute '/bin/sh -c cd /home/enoemcl/workspace/litp/ERIClitpcli/ERIClitpcli_CXP9030420/target/rpm/ERIClitpcli_CXP9030420/SPECS && rpmbuild -bb --buildroot /home/enoemcl/workspace/litp/ERIClitpcli/ERIClitpcli_CXP9030420/target/rpm/ERIClitpcli_CXP9030420/buildroot --define '_topdir /home/enoemcl/workspace/litp/ERIClitpcli/ERIClitpcli_CXP9030420/target/rpm/ERIClitpcli_CXP9030420' --target noarch-redhat-linux ERIClitpcli_CXP9030420.spec' [WARNING] /bin/sh: scl: line 1: syntax error: unexpected end of file [WARNING] /bin/sh: error importing function definition for `BASH_FUNC_scl' [INFO] Building target platforms: noarch-redhat-linux [INFO] Building for target noarch-redhat-linux [INFO] Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.BDOiWD [WARNING] /bin/sh: scl: line 1: syntax error: unexpected end of file [INFO] [INFO] [INFO] RPM build errors: [WARNING] error: Bad exit status from /var/tmp/rpm-tmp.BDOiWD (%install) [WARNING] Bad exit status from /var/tmp/rpm-tmp.BDOiWD (%install) .... When I remove scl-utils package from Fedora the issue disappers. [DEBUG] About to execute '/bin/sh -c cd /home/enoemcl/workspace/litp/ERIClitpcli/ERIClitpcli_CXP9030420/target/rpm/ERIClitpcli_CXP9030420/SPECS && rpmbuild -bb --buildroot /home/enoemcl/workspace/litp/ERIClitpcli/ERIClitpcli_CXP9030420/target/rpm/ERIClitpcli_CXP9030420/buildroot --define '_topdir /home/enoemcl/workspace/litp/ERIClitpcli/ERIClitpcli_CXP9030420/target/rpm/ERIClitpcli_CXP9030420' --target noarch-redhat-linux ERIClitpcli_CXP9030420.spec' [INFO] Building target platforms: noarch-redhat-linux [INFO] Building for target noarch-redhat-linux [INFO] Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.5kXnov [WARNING] + umask 022 I will try more troubleshooting as it seems some specific circumstance triggers the issue on certain maven packaging plugins. I have commented on https://issues.jboss.org/browse/BYTEMAN-306 as same error is seen.
Some software cannot serialize environment containing variables which have the following format during parsing. XXXXXXX()=() { xxxxxxxxxxxx ; For example, the maven-rpm-plugin and maven-javadoc-plugin (BYTEMAN-206) are not able to serialize exported functions presented as follows. BASH_FUNC_scl()=() { local CMD=$1; <== ';' causes warnings .... BASH_FUNC_bob()=() { local a=b; <== ';' causes warnings ... Experimenting with removing the trailing ';' seems to help. In my specific case, the command 'mvn clean package' now works correctly. BASH_FUNC_scl()=() { if [ "$1" = "load" -o "$1" = "unload" ]; then BASH_FUNC_bob()=() { local a=b Reviewing https://github.com/scopatz/xonsh/issues/208 there is some focus on the ';' character although they claim the bash syntax is incorrect. BTW, I can replicate xone cash issue 208 on my system regardless of the name of the exported function. BASH_FUNC_xxx()=() { local a=b; <== ';' causes warnings Some software appears to lack test coverage with exported functions.
Typo correction: I can replicate xonsh issue 208 on my system.
Also, Bash seems to be truncating single-line exported functions when imported into the running shell environment. This appears to be separate bug. $ head -3 /usr/share/Modules/init/sh module() { eval `/usr/bin/modulecmd sh $*`; } <== ';' is defined. $ which module module () { eval `/usr/bin/modulecmd bash $*` <= ';' truncated. } $ env ... BASH_FUNC_module()=() { eval `/usr/bin/modulecmd bash $*` <= ';' truncated }
(In reply to Noel McLoughlin from comment #8) > Also, Bash seems to be truncating single-line exported functions when > imported into the running shell environment. This appears to be separate bug. > $ env > ... > BASH_FUNC_module()=() { eval `/usr/bin/modulecmd bash $*` <= ';' truncated > } env does not properly encode environment variables when printing them: abc="$(printf 'ab\nc\n')" env | head -2 abc=ab c $ env is not a shell built-in, so this is not the shell's fault. bash does it correctly: $ abc="$(printf 'ab\nc\n')" bash -c set | tail -1 abc=$'ab\nc' $
Created attachment 1129070 [details] Sample maven rpm package to replicate issue on Fedora Investigation suggests MAVEN or JAVA-JDK is truncating BASH_FUNC_scl(). DISCUSSION The 'getSystemEnvVars()' method in MAVEN CommandLineUtils class might be at fault: https://github.com/sonatype/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/cli/CommandLineUtils.java#L240 However, MAVEN domentation implicates 'System.getenv()' method in JAVA OPENJDK: https://maven.apache.org/shared/maven-shared-utils/apidocs/org/apache/maven/shared/utils/cli/CommandLineUtils.html#getSystemEnvVars%28%29 This garbled variable is mostly an irritation for Maven builds (see BYTEMAN-306). However, if the POM file for RPM packaging specifies a softlinke (see: http://www.mojohaus.org/rpm-maven-plugin/source-params.html#softlinkSource) then the buildroot environment is corrupted (http://rpm5.org/docs/api/buildroot.html) and rpm building fails. REPLICATE ISSUE: Issue is easy to replicate with attached sample rpm maven package. 1. Install Fedora Server 23 or rawhide. 2. yum install maven rpm-build -y 3. useradd bob && password bob && su - bob 4. Extract attached demo_mvn_myapp.tar.bz2 file in $HOME 4. cd $HOME/myapp && maven clean package # works fine. 5. su - root && yum install scl-utils -y && exit 6. cd $HOME/myapp && maven clean package # fails, garbled scl() Need some input from Maven developers as I'm a bit rusty on Maven/Java/Bash.
(In reply to Noel McLoughlin from comment #10) > The 'getSystemEnvVars()' method in MAVEN CommandLineUtils class might be at > fault: > https://github.com/sonatype/plexus-utils/blob/master/src/main/java/org/ > codehaus/plexus/util/cli/CommandLineUtils.java#L240 I think it's more likely that whatever writes out the script which contains these environment variables serializes them incorrectly. I checked, and OpenJDK does not garble the value. It's likely there is a function somewhere which does something like this: out.print(e.getKey()); out.print("=\""); out.print(e.getValue()); out.println('"'); That's quite incorrect even for environment variables which are plain strings.
I agree. The maven properties string is not garbled (below). --- DEBUG properties used { java.vendor=Oracle Corporation, .... etc ... , env.BASH_FUNC_scl()=() { local CMD=$1; if [ "$CMD" = "load" -o "$CMD" = "unload" ]; then eval "module $@"; else /usr/bin/scl "$@"; fi }, ..... etc ..... --- So I think maven-shared-utils is likely culprit.
I don't think that RPM Maven plugin is packaged in Fedora, so I assume you are using upstream version. In this case you should report this issue in upstream bug tracker at https://github.com/mojohaus/rpm-maven-plugin/issues/
Thanks Mikolaj, Florian. I raised https://github.com/sonatype/plexus-utils/issues/21 as I think the issue lies there, not rpm maven plugin.
Just out of curiosity, which version of RPM Maven plugin are you using Noel?
From attached reproducer it looks like it's 2.1-alpha-1 (latest version is 2.1.5).
Yes, Mikolaj is correct.
Hmm... version 2.1-alpha-1 was released on 25-May-2010. Could you please try with latest version of the plugin?
After fresh install of fedora, the first invocation of 'maven' pulls down the configured plugins from repos. So it is default behaviour to use 2.1-alpah-1
Is there a correct way to update maven plugins? Or do I manually download and update $HOME/.m2/repository/ with later plugin? Mvn manpage is not helpful and '-up' (update plugins) is depreciated.
(In reply to Noel McLoughlin from comment #20) > Is there a correct way to update maven plugins? Or do I manually download > and update $HOME/.m2/repository/ with later plugin? In your POM file (myapp/mytest/pom.xml) you specified plugin version as 2.1-alpha-1. You can change it to 2.1.5 to use the latest version.
Hi Mikolaj, Great, that is the root cause. I updated pom.xml to specify 2.1.5 and added the following line to fix an error. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> My colleagues use ubuntu with maven so did not see this issue & I do not know maven well so did not see this. thanks Noel