Skip to content

Combining Java, Install and Jar builders can cause "AttributeError : DirNodeInfo instance has no attribute 'csig'" #2550

Closed

Description

@bdbaddog

This issue was originally created at: 2010-01-09 07:48:44.
This issue was reported by: knute.

knute said at 2010-01-09 07:48:44

If you have a Java source tree with two directories: "src" (with at least one java source file) and "resources" (with at least one file), and the following SConstruct file:

Java('classes', 'src')
Install('classes', 'resources')
Jar('test.jar', 'classes', JARCHDIR='classes')

Running "scons test.jar" twice now produces the following output:

$ scons test.jar
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
javac -d classes -sourcepath src src/org/boblycat/Whatever.java
Install directory: "resources" as "classes/resources"
jar cf test.jar -C classes .
scons: done building targets.
 
$ scons test.jar 
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: *** [test.jar] AttributeError : DirNodeInfo instance has no attribute 'csig'
scons: building terminated because of errors.

Simply running "scons" does not reproduce the error, you have to run "scons test.jar". Seen with scons 1.2.0 on Ubuntu.

gregnoel said at 2010-02-03 14:21:40

Bug party triage.

russel said at 2010-02-12 06:40:37

Adding self to CC list

gregnoel said at 2010-03-10 01:23:15

Bug party annotation. Despite the "research" milestone, issues for 2.0 have higher priority.

gregnoel said at 2010-07-21 16:59:28

Bug party triage. Bump the priority of this issue.

gregnoel said at 2010-11-14 18:41:57

Promote issue so it will be reviewed at next bug party.

dirkbaechle said at 2010-12-02 11:12:49

Hi,

I can reproduce the error with the attached testcase, on my Ubuntu 10.0 (64bit) machine running r5189 (trunk).

When changing the destination of the "resources" Install() to "inst" (see prepared comment line in the SConscript), things work fine...no error/exception.

The problem seems to be, that the Install() target is also the source dir for the JAR file build. When calling SCons with scons -n --tree=derived test.jar I get

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
javac -d classes -sourcepath src src/Test.java
Install directory: "resources" as "classes/resources"
jar cf test.jar -C classes .
+-test.jar
  +-classes
  | +-classes/Test.class
  | +-classes/resources
  |   +-resources
  +-classes/Test.class
  +-classes/resources
    +-resources
scons: done building targets.

as output. Behind the curtains, the node "classes/resources" of type "Entry" (created in the InstallBuilderWrapper, install.py: l. 207) is added to the list of implicit dependencies (self.implicit) for the Dir node "classes".

Later, SCons runs into an exception at:

  get_contents [FS.py:1751]
  get_text_contents [FS.py:1745]
  jarFlags [jar.py:83]
  expand [Subst.py:689]
  substitute [Subst.py:725]
  expand [Subst.py:678]
  substitute [Subst.py:723]
  expand [Subst.py:678]
  substitute [Subst.py:723]
  expand [Subst.py:698]
  substitute [Subst.py:725]
  expand [Subst.py:678]
  substitute [Subst.py:723]
  scons_subst_list [Subst.py:845]
  subst_list [Environment.py:532]
  get_implicit_deps [Action.py:826]
  get_implicit_deps [Action.py:901]
  get_implicit_deps [Executor.py:535]
  scan [Executor.py:484]
  scan_sources [Executor.py:451]
  scan [__init__.py:637]
  children [__init__.py:975]
  get_all_children [Executor.py:261]
  _find_next_ready_node [Taskmaster.py:780]
  next_task [Taskmaster.py:912]
  start [Job.py:193]
  run [Job.py:111]
  _build_targets [Main.py:1260]
  _main [Main.py:1066]
  _exec_main [Main.py:1302]
  main [Main.py:1338]

Here, get_contents() loops over all children

    def get_contents(self):
        """Return content signatures and names of all our children
        separated by new-lines. Ensure that the nodes are sorted."""
        contents = []
        for node in sorted(self.children(), key=lambda t: t.name):
            contents.append('%s %s\n' % (node.get_csig(), node.name))
        return ''.join(contents)

and tries to retrieve their signatures. When the Entry node "classes/resources" has its turn, get_csig() tries to write into ninfo.csig

    def get_csig(self):
        try:
            return self.ninfo.csig
        except AttributeError:
            ninfo = self.get_ninfo()
            ninfo.csig = SCons.Util.MD5signature(self.get_contents())
            return self.ninfo.csig

which doesn't exist. Kaboom.

I have no idea about how to properly resolve this (filtering out Entry nodes in get_contents()? mark it as INVALID?), but I hope my comments are helpful somehow.

Best regards,

Dirk

dirkbaechle said at 2010-12-02 11:13:48

Created an attachment (id=822) Simple testcase

blundeln said at 2011-02-02 07:09:02

Scons version, running on Arch Linux: v2.0.1.r5134

I have run into the same issue, getting this exception when I create a jar file under a similar SCons script.

I have a very simple work-around that seems to work for me but, not having looked at the SCons architecture in depth as of yet, I'm not sure of the negative implications of it.

My fix is as follows in line ~760 of Node/init.py:

Original: ninfo.csig = SCons.Util.MD5signature(self.get_contents())
Modified: self.ninfo.csig = SCons.Util.MD5signature(self.get_contents())

As far as I can understand, this ensures that the signature at least gets set based on the contents of the Dir node.

Can anyone comment on this solution, which I know is not ideal?

Thank you,

Nick

wblevins001 said at 2014-07-22 17:57:31

More bug details:

  1. Only occurs if this Node appears as a dependency of another Node.
  2. Example: A depends on B and B has resource files.
  3. Occurs with resource files installed via Install and Copy.

dirkbaechle attached javaprj.tgz at 2010-12-02 11:13:48.

Simple testcase

Activity

  1. added this to the milestone on Jan 2, 2018
  2. added
    Java
    on May 14, 2019
  3. mwichmann commented on Nov 9, 2026

    @mwichmann
    Collaborator

    No longer reproducible, closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavaOp Sys: UNIX-likeVersion: 1.2.0bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions