You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by glenn opdycke-hansen <gl...@gmail.com> on 2006/01/16 14:27:38 UTC

error msg for incorrect jar/basedir value

We have seen a cryptic error message from the jar task.  If the
basedir directory does not exist, ant writes the following message

BUILD FAILED
C:\src\ant-jar-filespec-prob\build.xml:49:
C:\src\ant-jar-filespec-prob\bad-base-dir-not-exists not found.

Total time: 0 seconds

However if the basedir value is set to an existing directory with a
space character appended, ant writed the following message

BUILD FAILED
C:\src\ant-jar-filespec-prob\build.xml:99: IO error scanning directory
C:\src\ant-jar-filespec-prob\jar-root

Total time: 2 seconds

I plan to create a bug report, since the "IO error scanning" error
message is hard to understand.
Comments?

--glenn

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by glenn opdycke-hansen <gl...@gmail.com>.
Yes, I was running on windows.  We build on windows and deploy to unix.
I just tested it on aix 5.2 and got the following msgs

     [echo] jar destfile="output/out2.jar"
     [echo]   basedir="jar-root "

BUILD FAILED
/app/tibcoems/deployment/ant-jar-filespec-prob/build-basedir-space.xml:67:
/app/tibcoems/deployment/ant-jar-filespec-prob/jar-root  not found.
        at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:349)
        at org.apache.tools.ant.taskdefs.Zip.grabResources(Zip.java:949)

Finally, some sanity!
I believe that this will be a challenge to fix or improve on.  This
can be very confusing to users.

On 1/16/06, Matt Benson <gu...@yahoo.com> wrote:
> Are you running on windows?  Testing on windows I do
> see the same problem, but it appears to me that
> directories with trailing spaces are clipped at the OS
> level. Nothing we can do here... if you or anyone else
> has a nice idea of where in the manual we could make
> mention of this little tidbit that's great.
>
> Thanks,
> Matt
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by Matt Benson <gu...@yahoo.com>.
Are you running on windows?  Testing on windows I do
see the same problem, but it appears to me that
directories with trailing spaces are clipped at the OS
level. Nothing we can do here... if you or anyone else
has a nice idea of where in the manual we could make
mention of this little tidbit that's great.

Thanks,
Matt

--- glenn opdycke-hansen <gl...@gmail.com> wrote:

> Ant script to recreate problem is attached.
> > <project name="jar-filespec-prob"
> default="create-jar-basedir-space">
> 
> <!-- root dir of files to be jarred -->
> <property name="jar.root.dir" value="jar-root"/>
> 
> <!-- recreate the jar root directory -->
> <delete dir="${jar.root.dir}"/>
> <mkdir dir="${jar.root.dir}"/>
> 
> <!-- nb root dir with appended space in dir name 
> -->
> <property name="jar.root.dir.space" value="jar-root
> "/>
> 
> <property name="out.dir" value="output"/>
> <property name="out.jar" value="out.jar"/>
> <property name="out1.jar" value="out1.jar"/>
> <property name="out2.jar" value="out2.jar"/>
> 
> <!--
>
======================================================
>      target create-jar-basedir-space
>  -->
> <target name="create-jar-basedir-space">
> 
> <available property="jar.root.dir.exists"
>   file="${jar.root.dir}" type="dir"/>
> 
> <available property="jar.root.dir.dir1.exists"
>   file="${jar.root.dir}/dir1" type="dir"/>
> 
> <echo>
> jar.root.dir.exists=${jar.root.dir.exists}
> jar.root.dir.dir1.exists=${jar.root.dir.dir1.exists}
> 
> jar destfile="${out.dir}/${out1.jar}"
>   basedir="${jar.root.dir}"
> </echo>
> 
> <jar destfile="${out.dir}/${out1.jar}"
>   basedir="${jar.root.dir}">
> </jar>
> 
> <available property="jar.root.dir.space.exists"
>   file="${jar.root.dir.space}" type="dir"/>
> 
> <available property="jar.root.dir.space.dir1.exists"
>   file="${jar.root.dir.space}/dir1" type="dir"/>
> 
> <available property="jar.root.dir.space.dot.exists"
>   file="${jar.root.dir.space}/." type="dir"/>
> 
> <echo>
> 
>
jar.root.dir.space.exists=${jar.root.dir.space.exists}
>
jar.root.dir.space.dot.exists=${jar.root.dir.space.dot.exists}
>
jar.root.dir.space.dir1.exists=${jar.root.dir.space.dir1.exists}
> jar destfile="${out.dir}/${out2.jar}"
>   basedir="${jar.root.dir.space}"
> 
> </echo>
> 
> <jar destfile="${out.dir}/${out2.jar}"
>   basedir="${jar.root.dir.space}">
> </jar>
> 
> </target>
> 
> </project>
> 
> >
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
user-help@ant.apache.org


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by glenn opdycke-hansen <gl...@gmail.com>.
Ant script to recreate problem is attached.

Re: error msg for incorrect jar/basedir value

Posted by Matt Benson <gu...@yahoo.com>.
--- glenn opdycke-hansen <gl...@gmail.com> wrote:

> I did make a modification to DirectoryScanner.java.
> The additional output confirms that File.exists()
> thinks that the
> directory with an extra space exists.  The change
> that could help is
> to quote the directory name so the space is more
> promentent.  See
> below:
> 
>       [jar] go-get abs path
> abspath="C:\src\ant-jar-filespec-prob\jar-root "
>       [jar] go-test abs path absfile.exists='true'
> 
> BUILD FAILED
>
C:\src\ant-jar-filespec-prob\build-basedir-space.xml:58:
> IO error
> scanning directory
> dir='C:\src\ant-jar-filespec-prob\jar-root '
> 
> Total time: 1 second
> 
> Comments?

No problems here.  What would be great is a working
example that triggers this situation; optimally a
single buildfile that creates such a directory
structure, then exhibits the breakage.  In any event,
quoting the directory here is probably a good idea.

Thanks,
Matt

> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by Matt Benson <gu...@yahoo.com>.
I already committed to HEAD the change to quote the
directory name in the log message.  The problem is
with Windows.  e.g. see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp

-Matt

--- glenn opdycke-hansen <gl...@gmail.com> wrote:

> I have a copy of DirectoryScanner.  I do not see any
> calls to trim in that code.
> I will prepare a patch that quotes the directory
> name in question. 
> This might help others that get the error.  I do
> know think it would
> be safe to modify the file name, I would not want to
> break something
> else.
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by glenn opdycke-hansen <gl...@gmail.com>.
Document the dirname/windows "feature".  If this cannot be resolved,
it would be good to document the behavior.  Can the following be
considered for the Ant user manual?

http://ant.apache.org/manual/CoreTasks/jar.html

Note that if the basedir value has space character(s) appended to it,
then some operating systems, e.g. Windows, will report an error on the
jar or other tasks that uses the dirname.
If the basedir without the space exists, then if the basedir value has
appended space(s), the error message "IO error scanning directory" can
be reported.
Also, it is possible that ant available task would that the directory
name with the space exists.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by Ken Gentle <j....@acm.org>.
At 16:30 2006-01-16, you wrote:
>I have a copy of DirectoryScanner.  I do not see any calls to trim 
>in that code.
>I will prepare a patch that quotes the directory name in question.
>This might help others that get the error.  I do know think it would
>be safe to modify the file name, I would not want to break something
>else.

No, no, don't modify the file name.  That was not what I meant to 
suggest at all.  I wasn't clear.

Looking at the SVN Head for DirectoryScanner, this looks like a bug 
in java.io.File to me (and apparently to the person who put the test 
for a null list in, too!)

         Ken


>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by glenn opdycke-hansen <gl...@gmail.com>.
I have a copy of DirectoryScanner.  I do not see any calls to trim in that code.
I will prepare a patch that quotes the directory name in question. 
This might help others that get the error.  I do know think it would
be safe to modify the file name, I would not want to break something
else.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by Ken Gentle <j....@acm.org>.
It sounds like either Ant Core or Java is performing a "trim" in one 
path of execution that is not being performed on the other. (On a 
second read, sounds like java.io.File is ignoring the trailing blank 
while DirectoryScanner thinks it is significant).

I don't have this source in front of me at the moment, but perhaps 
retrieving the file name from File to use in directory scanning is 
the way to go.  This would push any platform dependent behavior back 
onto the JRE.

The additional information in the error message is handy; However, I 
don't think it is the root problem.

FWIW

         Ken


At 12:04 2006-01-16, you wrote:
>I did make a modification to DirectoryScanner.java.
>The additional output confirms that File.exists() thinks that the
>directory with an extra space exists.  The change that could help is
>to quote the directory name so the space is more promentent.  See
>below:
>
>       [jar] go-get abs path abspath="C:\src\ant-jar-filespec-prob\jar-root "
>       [jar] go-test abs path absfile.exists='true'
>
>BUILD FAILED
>C:\src\ant-jar-filespec-prob\build-basedir-space.xml:58: IO error
>scanning directory dir='C:\src\ant-jar-filespec-prob\jar-root '
>
>Total time: 1 second
>
>Comments?
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by glenn opdycke-hansen <gl...@gmail.com>.
I did make a modification to DirectoryScanner.java.
The additional output confirms that File.exists() thinks that the
directory with an extra space exists.  The change that could help is
to quote the directory name so the space is more promentent.  See
below:

      [jar] go-get abs path abspath="C:\src\ant-jar-filespec-prob\jar-root "
      [jar] go-test abs path absfile.exists='true'

BUILD FAILED
C:\src\ant-jar-filespec-prob\build-basedir-space.xml:58: IO error
scanning directory dir='C:\src\ant-jar-filespec-prob\jar-root '

Total time: 1 second

Comments?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by glenn opdycke-hansen <gl...@gmail.com>.
This is going to be a challenge to patch.
The error is
BUILD FAILED
C:\src\ant-jar-filespec-prob\build-basedir-space.xml:58: IO error
scanning directory C:\src\ant-jar-filespec-prob\jar-root
	at org.apache.tools.ant.DirectoryScanner.scandir(DirectoryScanner.java:1038)
	at org.apache.tools.ant.DirectoryScanner.checkIncludePatterns(DirectoryScanner.java:836)

The DirectoryScanner.java code at 1038 is at the throw stmt below:
        String[] newfiles = dir.list();

        if (newfiles == null) {
            /*
             * two reasons are mentioned in the API docs for File.list
             * (1) dir is not a directory. This is impossible as
             *     we wouldn't get here in this case.
             * (2) an IO error occurred (why doesn't it throw an exception
             *     then???)
             */
            throw new BuildException("IO error scanning directory "
                                     + dir.getAbsolutePath());

The code had already executed the following checks:
        if (dir == null) {
            throw new BuildException("dir must not be null.");
        } else if (!dir.exists()) {
            throw new BuildException(dir + " doesn't exists.");
        } else if (!dir.isDirectory()) {
            throw new BuildException(dir + " is not a directory.");
        }

The puzzling part is that the dir name has an extra space.  With the
space it does not exist and is not a directory.  Without the space it
does exist and is a directory.

So, should the error msg be changed?

Perhaps to the following:
            throw new BuildException("IO error scanning directory dir="""
                                     + dir.getAbsolutePath())+"""";


Note that this has caused days of lost time for the build, so a change
would be in order here.

--glenn

On 1/16/06, Jeffrey E Care <ca...@us.ibm.com> wrote:
> If you are going to submit a bug report I would advise you to submit a
> patch along with it.
>
> --
> Jeffrey E. Care (carej@us.ibm.com)
> WebSphere v7 Release Engineer
> WebSphere Build Tooling Lead (Project Mantis)
>
>
> glenn opdycke-hansen <gl...@gmail.com> wrote on 01/16/2006 08:27:38 AM:
>
> > We have seen a cryptic error message from the jar task.  If the
> > basedir directory does not exist, ant writes the following message
> >
> > BUILD FAILED
> > C:\src\ant-jar-filespec-prob\build.xml:49:
> > C:\src\ant-jar-filespec-prob\bad-base-dir-not-exists not found.
> >
> > Total time: 0 seconds
> >
> > However if the basedir value is set to an existing directory with a
> > space character appended, ant writed the following message
> >
> > BUILD FAILED
> > C:\src\ant-jar-filespec-prob\build.xml:99: IO error scanning directory
> > C:\src\ant-jar-filespec-prob\jar-root
> >
> > Total time: 2 seconds
> >
> > I plan to create a bug report, since the "IO error scanning" error
> > message is hard to understand.
> > Comments?
> >
> > --glenn
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: error msg for incorrect jar/basedir value

Posted by Jeffrey E Care <ca...@us.ibm.com>.
If you are going to submit a bug report I would advise you to submit a 
patch along with it.

-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)


glenn opdycke-hansen <gl...@gmail.com> wrote on 01/16/2006 08:27:38 AM:

> We have seen a cryptic error message from the jar task.  If the
> basedir directory does not exist, ant writes the following message
> 
> BUILD FAILED
> C:\src\ant-jar-filespec-prob\build.xml:49:
> C:\src\ant-jar-filespec-prob\bad-base-dir-not-exists not found.
> 
> Total time: 0 seconds
> 
> However if the basedir value is set to an existing directory with a
> space character appended, ant writed the following message
> 
> BUILD FAILED
> C:\src\ant-jar-filespec-prob\build.xml:99: IO error scanning directory
> C:\src\ant-jar-filespec-prob\jar-root
> 
> Total time: 2 seconds
> 
> I plan to create a bug report, since the "IO error scanning" error
> message is hard to understand.
> Comments?
> 
> --glenn
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>