You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Scott Kurz (Jira)" <ji...@apache.org> on 2022/11/16 23:57:00 UTC

[jira] [Commented] (MWRAPPER-83) mvnw fails in zsh due to empty MAVEN_OPTS variable

    [ https://issues.apache.org/jira/browse/MWRAPPER-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17635041#comment-17635041 ] 

Scott Kurz commented on MWRAPPER-83:
------------------------------------

Under [https://maven.apache.org/wrapper/#supported-systems] it seems to imply that using zsh is a legitimate use case.

I think it will work normally with zsh using an interactive shell. 

For the case I mentioned running the shell from another process, turning on the SH_WORD_SPLIT seems to fix the problem. 

$ zsh -o shwordsplit mvnw validate

 

> mvnw fails in zsh due to empty MAVEN_OPTS variable
> --------------------------------------------------
>
>                 Key: MWRAPPER-83
>                 URL: https://issues.apache.org/jira/browse/MWRAPPER-83
>             Project: Maven Wrapper
>          Issue Type: Bug
>          Components: Maven Wrapper Scripts
>    Affects Versions: 3.1.1
>            Reporter: Scott Kurz
>            Priority: Major
>
> Running mvnw in zsh, I get:
> {quote}*Error: Could not find or load main class*
> *Caused by: java.lang.ClassNotFoundException:*
> {quote}
> h4. Recreate Instructions
>  # docker run -it ubuntu:focal-20221019   # next instructions are within Docker container
>  #  apt update; apt install default-jdk maven zsh -y        # still have to interactively make a location selection
>  #  export JAVA_HOME=/usr
>  # mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-simple -DarchetypeVersion=1.4 -DgroupId=demo -DartifactId=app -Dversion=1.0
>  # cd app
>  # mvn org.apache.maven.plugins:maven-wrapper-plugin:3.1.1:wrapper
>  # bash mvnw validate   # good, works
>  # zsh mvnw validate     # bad, recreates problem
>  
> {*}Thoughts{*}{*}{*}
> The problem centers around the different behavior of bash, zsh (at least with the versions in this recreate) in interpreting the expansion of the "empty" MAVEN_OPTS variable.  With *bash* this gets resolved to nothing whereas in *zsh* this is resolved to a ' ' string, which the *java* executable seems to treat as the main class argument, and thus fails.
> Maybe someone more familiar with shell options knows a workaround, but given this seems to happen with the default options in the above environment, it seems worth addressing in the script.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)