Home / Docs / Configure a package

Path dependencies

What it does

A package may use another package from a directory of its own repository or machine: a path dependency. The needs section names it, with from path and the directory, relative to the package. Its modules are then imported under its local name, the last segment of its name: the module text of the dependency util is util.text in the package. una check checks the package and its dependencies as one program.

A local package carries a name that a registry may also hold, so the package accepts it by name, with accept name under the need. That way a local directory never takes the place of a published package by accident.

ita.unauna
ita shop
  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.2.0
  from path "deps/util"
  digest "sha256:0000000000000000000000000000000000000000000000000000000000000000"
deps/util/ita.unauna
ita util
  version 0.2.0
  edition 0.4
deps/util/src/text.unauna
module text

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

import util.text (shout)

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

Forms

text
needs
  <name> [as <local>] from path "<dir>"
    accept name
    may <Capability>[<op>, ...], ...

Examples

Without accept name, the dependency is not used (U7012):

ita.unauna
-- fails with U7012
ita shop
  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.2.0
  from path "deps/util"
  digest "sha256:0000000000000000000000000000000000000000000000000000000000000000"
deps/util/ita.unauna
ita util
  version 0.2.0
  edition 0.4
deps/util/src/text.unauna
module text

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

pub one() -> Int = 1

A module of the package whose path starts with a local name could be taken for the dependency's: U1010.

ita.unauna
ita shop
  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.2.0
  from path "deps/util"
  digest "sha256:0000000000000000000000000000000000000000000000000000000000000000"
deps/util/ita.unauna
ita util
  version 0.2.0
  edition 0.4
deps/util/src/text.unauna
module text

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

pub one() -> Int = 1
src/util.unauna
-- fails with U1010
module util

pub two() -> Int = 2

Edge cases

Diagnostics

Edition

Edition 0.4 and later, a preview.

Normative source