Dfx.json ENV var for absolute path names

Is there any way to find out the directory of dfx.json and pass that as a environment variable? Our issue is that when you do dfx build you have to be in a specific directory and it’s annoying to have to move to the top level directory every time.

What we want is something like :

"build": "bash -c '$DFX_JSON_DIR/backend/scripts/app/build.sh game'",

I did this to get the ENV vars at build time…

"game_config": {
"type": "custom",
"candid": ".dfx/local/canisters/game_config/game_config.did",
"build": "printenv",

but nothing that’s really useful

Executing 'printenv'
OLDPWD=/home/adam/projects/dragginz
CANISTER_CANDID_PATH=/home/adam/projects/dragginz/.dfx/local/canisters/game_config/game_config.did
PWD=/home/adam/projects/dragginz/backend

It never was an issue before but something changed a few months ago.

I’ve added an internal ticket about this. Ideally the dfx.json directory should always be the CWD of executed scripts.

Thanks! Yeah, the other two paths (candid, wasm) are absolute but the build directive is relative. I don’t think it used to be that way.