After upgrade to dfx 0.9.2, can not deploy to existing motoko canister

This is due to recent changes in DFX (since version 0.9.0).

Some explanations :

  • When using dfx you are talking to the IC using an identity, you can check the principal associated with this identity with dfx identity get-principal.

    You also have a cycle-wallet (which is a canister as only canisters can hold cycles), you can check the canister id of the canister that acts as your cycle wallet using dfx identity --network ic get-wallet. The cycle wallet is used to deploy canisters as you need to spend cycles and only the wallet can do it for you :money_with_wings: so in reality when you run dfx deploy you are asking the cycle wallet to deploy for you.

  • All canisters have controllers, the controllers are the only people authorized to redeploy a new code on an existing canisters.

  • In older versions of dfx (< 0.9.0) : at the moment a new canister was created it was only possible to assign one controller and by default it was the cycle wallet (since it’s him that deployed the canister).

    All further calls to the deployed canister using dfx were forwarded to the cycle wallet by default because it was the default controller.
    If you wanted to use your identity directly without proxying to the cycle wallet you needed to add the --no-wallet flag to all commands.

  • In new versions of dfx (>= 0.9.0) : it is now possible to assign multiple controllers to a deployed canister, so both your cycle wallet and your identity are automatically assigned as controller when you deploy a fresh canister.
    There is no need to forward calls using the cycle wallet anymore so the --no-wallet flag has disappeared.

To fix you issue, you need to upgrade to DFX 0.9.2 and add your identity as controller, you’ll then be able to redeploy.
You can do so by running the following commands.

dfx wallet --network ic upgrade
dfx canister --network ic --wallet "$(dfx identity --network ic get-wallet)" update-settings --all --add-controller "$(dfx identity get-principal)" 

More informations :

16 Likes