Post_install not working

Is post_install supposed to work in dfx 0.11.0?

Here’s my dfx.json:

    "canisters": {
        "icrc_1": {
            "type": "custom",
            "build": "npx azle icrc_1",
            "root": "src",
            "ts": "src/index.ts",
            "candid": "src/index.did",
            "wasm": "target/wasm32-unknown-unknown/release/icrc_1.wasm",
            "declarations": {
                "output": "test/dfx_generated/icrc_1"
            "post_install": [
                "dfx generate",
                "scripts/ test/dfx_generated"

I can’t ever get the post_install scripts to run, I’ve put them in different locations in the dfx.json and nothing so far has worked.

I’ve been using the following commands, I assume post_install will run after any dfx canister install command.

dfx canister install --argument "($argument)" --wasm target/wasm32-unknown-unknown/release/icrc_1.wasm.gz icrc_1

dfx canister install --mode upgrade --argument "($argument)" --wasm target/wasm32-unknown-unknown/release/icrc_1.wasm.gz icrc_1

Yes, it looks like when using the --wasm flag, dfx canister install does not run the post-install scripts.

The --wasm flag is meant as a way to install arbitrary wasm into an arbitrary canister. It’s subtle, but the help for the option mentions this:

Specifies a particular WASM file to install, bypassing the dfx.json project settings.

In your case, since the wasm field matches the canister definition, if you remove the --wasm parameter from the command you’re running, dfx will still install the same wasm, but also run the post-install scripts.