You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2010/05/07 21:44:58 UTC

DO NOT REPLY [Bug 49266] New: ant does not work with empty CLASSPATH

https://issues.apache.org/bugzilla/show_bug.cgi?id=49266

           Summary: ant does not work with empty CLASSPATH
           Product: Ant
           Version: 1.8.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Wrapper scripts
        AssignedTo: notifications@ant.apache.org
        ReportedBy: szeder@ira.uka.de


Have a look at the output of ant commands taken from the ant manual's "Check
Installation" section and the ant website's "Having Problems?" page when they
are executed with an empty CLASSPATH variable (which is even suggested by the
"Having Problems?" page!):

$ unset CLASSPATH
$ ant
The -cp argument must be followed by a classpath expression
$ ant -version
Buildfile: build.xml does not exist!
Build failed
$ ant -diagnostics
Buildfile: build.xml does not exist!
Build failed
$ ant -verbose
Buildfile: build.xml does not exist!
Build failed

This is obviously not good; ant does not even print its version.

The problem is at the end of the bin/ant startup script, where the
ant_exec_command variable is assembled.  The -cp "$CLASSPATH" options are
appended to the command line even when the CLASSPATH is empty, resulting in a
command line which looks like 'exec java ... -cp ""'.  Java then sees the -cp
option without a class path or jar file and errors out, or it sees something
like "... -cp -version" and treats that first argument as a class path or jar
file.

The attached patch resolves this issue by checking CLASSPATH's emptyness and
omiting the -cp option in that case.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49266] ant does not work with empty CLASSPATH

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49266

Antoine Levy-Lambert <an...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|1.8.1                       |1.8.2

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49266] ant does not work with empty CLASSPATH

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49266

Jesse Glick <jg...@netbeans.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jglick@netbeans.org

--- Comment #2 from Jesse Glick <jg...@netbeans.org> 2010-05-07 16:26:02 EDT ---
(In reply to comment #0)
> $ unset CLASSPATH
> $ ant
> The -cp argument must be followed by a classpath expression

Does not happen to me. Are you using a custom java launcher wrapper shell
script? Run

file `which java`

and if it is not something like "ELF 32-bit LSB executable", you might have a
buggy launcher - e.g. using $* or $@ rather than "$@" for program arguments.

> The -cp "$CLASSPATH" options are
> appended to the command line even when the CLASSPATH is empty, resulting in a
> command line which looks like 'exec java ... -cp ""'

More like:

exec java -classpath "...antstuff..." -Dant.home=... -D...
org.apache.tools.ant.launch.Launcher -version -cp ""

i.e. three args are passed to main(String[]) in this example: {"-version",
"-cp", ""}, which should be fine.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49266] ant does not work with empty CLASSPATH

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49266

--- Comment #3 from Stefan Bodewig <bo...@apache.org> 2010-05-10 09:38:47 EDT ---
works for me as well (tested on Linux and Windows using cygwin) - I tend
stick with an undefined CLASSPATH and it works.

The -cp argument is a command line argument of the launcher class, not
of the Java virtual machine.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49266] ant does not work with empty CLASSPATH

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49266

--- Comment #1 from szeder@ira.uka.de 2010-05-07 15:48:48 EDT ---
Created an attachment (id=25417)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25417)
Bugfix

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 49266] ant does not work with empty CLASSPATH

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49266

Antoine Levy-Lambert <an...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|1.8.0                       |1.8.1

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.