E06265: more than one package declared in the same directory

Category: E06xxx Type hierarchy checks · Classification: TWO_PACKAGE_BEARING_MAINS_IN_ONE_DIRECTORY · All error codes

What went wrong

Two top-level '.ek9' files in the same directory each declare their own 'defines package' block. 'ek9.lock' and the project's dependency copy ('.ek9/deps/') are per DIRECTORY, while the compiled artefact, 'build.key' and the package properties file are per MAIN SOURCE - so two package-bearing mains sharing a directory would take turns rewriting the one lock and the one copy every time either was built, silently discarding whichever resolution ran last. 'ek9 -Dp' (and every build that resolves: 'ek9 -c', '-C', '-t', packaging) refuses with exit code 17 before touching the library, the lock or the copy, naming both files. A directory with ONE package-bearing file and any number of package-LESS siblings (ordinary programs with no 'defines package' block of their own) is unaffected - that case already compiles without touching the package-bearing file's lock.

How to fix it

  1. Keep only ONE package declaration per directory: move the other main source (and anything that belongs with it) into its own directory with its own 'ek9.lock'.
  2. If the two files were meant to share one package and one set of dependencies, remove the second file's package declaration - a plain main source with no package block of its own builds against its directory's single sealed package without declaring dependencies again.
  3. If they are genuinely unrelated single-file examples that happen to sit in one folder, give each its own directory before either declares dependencies.

Common causes

  • Two sample programs copied into one folder, each still carrying its own package declaration from wherever it was copied from
  • Splitting a project's main source in two without removing the package declaration from the copy
  • A generated or templated project that stamped a package declaration into more than one starter file

See also

Examples

No compiled example of E06265 is held in the error catalogue yet; the explanation above is the rich message the compiler shows for it (ek9 -h E06265).

Found a problem?

If EK9 reported E06265 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.