hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Document how to add dependencies on the Environments page

Open simonw opened this issue 2 years ago • 2 comments

https://hatch.pypa.io/latest/environment/#dependencies currently says this:

Hatch ensures that environments are always compatible with the currently defined project dependencies (if installed and in dev mode) and environment dependencies.

For example, add cowsay as a dependency then try to run it:

$ hatch run cowsay "Hello, world!"

The detail missing there was how to add a dependency.

I eventually tried adding it to dependencies = in the pyproject.toml file:

dependencies = [
  "cowsay"
]

Then I couldn't figure out how to run a command to cause Hatch to install any newly configured dependencies. I was looking for a hatch env update command or similar.

Eventually (after I'd started composing this issue) I realized that running hatch run cowsay -t "Hello, world" installed that dependency since it was missing the first time I ran it.

simonw avatar Oct 30 '23 22:10 simonw

Relevant documentation section: https://github.com/pypa/hatch/blob/02eb8037fde7c7a9f59c332aa9ff091f3b65f748/docs/environment.md#L74-L81

simonw avatar Oct 30 '23 22:10 simonw

Thanks, I will do that tonight!

ofek avatar Oct 30 '23 22:10 ofek