Home / Docs / Diagnostics

U7012: A dependency the root may not use as written

Release v0.4.0

A package of edition 0.4 uses a dependency only on terms its root states (ADR 0122, spec/30). U7012 reports, at the root's need, a dependency the root may not use as written: a package from a local path whose name a registry may hold, without accept name under the need, so a local package never silently takes the place of a published one; and a dependency of a later edition than the package. The repair is to accept the name, after checking that the path is the package meant, or to use an earlier version.

The repair at a glance

ita.unadiff
  ita demo
    version 0.1.0
    edition 0.4

  needs
    util from path "deps/util"
+     accept name
src/demo.unadiff
  module demo

- pub one() -> Int = 1
+ import util.text (shout)
+
+ pub greet() -> Text = shout("hello")

Failing example

ita.unauna
ita demo
  version 0.1.0
  edition 0.4

needs
  util from path "deps/util"
ita.lockuna
lock 1

solver
  encoding "una-smt-1"
  name "z3"
  version "5.1.0"
  logic "QF_UFLIA"
  steps 5000000
  seed 0

package util 0.1.0
  from path "deps/util"
  digest "sha256:0000000000000000000000000000000000000000000000000000000000000000"
deps/util/ita.unauna
ita util
  version 0.1.0
  edition 0.4
deps/util/src/text.unauna
module text

pub shout(word: Text) -> Text = word
src/demo.unauna
module demo

pub one() -> Int = 1

Fixed example

ita.unauna
ita demo
  version 0.1.0
  edition 0.4

needs
  util from path "deps/util"
    accept name
ita.lockuna
lock 1

solver
  encoding "una-smt-1"
  name "z3"
  version "5.1.0"
  logic "QF_UFLIA"
  steps 5000000
  seed 0

package util 0.1.0
  from path "deps/util"
  digest "sha256:0000000000000000000000000000000000000000000000000000000000000000"
deps/util/ita.unauna
ita util
  version 0.1.0
  edition 0.4
deps/util/src/text.unauna
module text

pub shout(word: Text) -> Text = word
src/demo.unauna
module demo

import util.text (shout)

pub greet() -> Text = shout("hello")