devenv icon indicating copy to clipboard operation
devenv copied to clipboard

`devenv tasks run` enter the shell even when run from devenv shell

Open landure opened this issue 6 months ago • 6 comments

Describe the bug

When running:

devenv tasks run my-task

The command reload the devenv shell even if called from an active shell.

Please add a condition to prevent this.

En aparté, It might be interesting to add initShell in addition to enterShell:

  • initShell would run tasks required to initialize any devenv shell (setting PATH, ...)
  • enterShell would run tasks needed when entering an interactive shell (starting services, starship, ...).

Version

devenv 1.8.1 (x86_64-linux)

landure avatar Aug 20 '25 06:08 landure

I'm confused what's going on here, besides you can't name a task my-task, it needs a prefix. Can you include task definition in form of devenv.nix?

domenkozar avatar Nov 19 '25 15:11 domenkozar

This isn't a task name issue. It an issue with devenv tasks run that reload the devenv (it runs devenv shell) before running the task, even if the devenv is already loaded.

$ devenv task run 'ci:lint'
• Using Cachix caches: devenv
✓ Building shell in 79.0ms

FYI: I've created a taskfile module for my tasks, feel free to take a look (https://github.com/biapy/devenv-go-task)

landure avatar Nov 19 '25 15:11 landure

Oh I've seen this before, someone on Discord was saying that adding one environment variable makes eval cache work. I'll need to dig up which one it was.

domenkozar avatar Nov 19 '25 15:11 domenkozar

https://discord.com/channels/1036369714731036712/1036369758024650792/1436439286579990722 looks like it's DEVENV_STATE.

domenkozar avatar Nov 19 '25 16:11 domenkozar

See https://github.com/cachix/devenv/pull/2297, needs testing.

domenkozar avatar Nov 19 '25 19:11 domenkozar

This isn't a task name issue. It an issue with devenv tasks run that reload the devenv (it runs devenv shell) before running the task, even if the devenv is already loaded.

$ devenv task run 'ci:lint' • Using Cachix caches: devenv ✓ Building shell in 79.0ms FYI: I've created a taskfile module for my tasks, feel free to take a look (https://github.com/biapy/devenv-go-task)

It looks like it's using cached version of shell, it loads in 80ms so that works as expected.

domenkozar avatar Nov 25 '25 16:11 domenkozar