jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.94k stars 191 forks source link

`{{ .DevboxDirRoot }}` doesn't point to the project root directory #1987

Open mootoday opened 3 months ago

mootoday commented 3 months ago

What happened?

In a plugin, I want to use the {{ .DevboxDirRoot }} placeholder. According to the docs, this placeholder "points to the root folder of their project, where the user's devbox.json is stored."

Instead, it points to <projectRoot>/devbox.d

Steps to reproduce

  1. Init a Devbox environment
  2. Create a plugin that has "cd {{ .DevboxDirRoot }} && pwd" in its init_hook
  3. Include the plugin in the devbox.json
  4. Run devbox shell

Command

shell

devbox.json

devbox.json

{
  "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.4/.schema/devbox.schema.json",
  "include": [
    "path:./.config/plugins/a/plugin.json"
  ],
  "packages": [],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

./.config/plugins/a/plugin.json

{
  "name": "plugin-a",
  "version": "0.0.1",
  "description": "A plugin.",
  "packages": [],
  "shell": {
    "init_hook": [
      "cd {{ .DevboxDirRoot }} && pwd"
    ]
  }
}

Devbox version

0.10.4

Nix version

nix (Nix) 2.19.3

What system does this bug occur on?

macOS (Apple Silicon)

Debug logs

Let me know if you need more output.

2024/04/10 21:01:26 findProjectDir: path is
2024/04/10 21:01:26 finding devbox config in dir: /Users/m/plugin-placeholders
/Users/m/plugin-placeholders/.devbox/gen/scripts/.raw-hooks.sh:cd:1: no such file or directory: /Users/m/plugin-placeholders/devbox.d