Failed while trying to deploy canisters. error: blob_of_principal: principal too short" and Only controllers of canister [...] can call ic00 method install_code

I am failing whilst deploying my project local.

I have the following information:
dfx build did work

dfx canister status --all
Canister status call result for iclottotest_backend.
Status: Running
Controllers: 2vxsx-fae bnz7o-iuaaa-aaaaa-qaaaa-cai
Memory allocation: 0
Compute allocation: 0
Freezing threshold: 2_592_000
Memory Size: Nat(0)
Balance: 3_092_221_598_423 Cycles
Module hash: None
Canister status call result for iclottotest_frontend.
Status: Running
Controllers: 2vxsx-fae bnz7o-iuaaa-aaaaa-qaaaa-cai
Memory allocation: 0
Compute allocation: 0
Freezing threshold: 2_592_000
Memory Size: Nat(0)
Balance: 3_092_307_388_618 Cycles
Module hash: None

dfx canister info iclottotest_backend
Controllers: 2vxsx-fae bnz7o-iuaaa-aaaaa-qaaaa-cai
Module hash: None

dfx canister info iclottotest_frontend
Controllers: 2vxsx-fae bnz7o-iuaaa-aaaaa-qaaaa-cai
Module hash: None

the errors (whilst using different identity):
dfx canister install --identity default --all
Installing code for canister iclottotest_backend, with canister ID bkyz2-fmaaa-aaaaa-qaaaq-cai
Error: Failed to install wasm module to canister ‘iclottotest_backend’.
Caused by: Failed to install wasm module to canister ‘iclottotest_backend’.
Failed during wasm installation call: The replica returned an HTTP Error: Http Error: status 403 Forbidden, content type “”, content: Only controllers of canister bkyz2-fmaaa-aaaaa-qaaaq-cai can call ic00 method install_code

dfx canister install --identity anonymous --all
Installing code for canister iclottotest_backend, with canister ID bkyz2-fmaaa-aaaaa-qaaaq-cai
Error: Failed to install wasm module to canister ‘iclottotest_backend’.
Caused by: Failed to install wasm module to canister ‘iclottotest_backend’.
Failed during wasm installation call: The Replica returned an error: code 5, message: “Canister bkyz2-fmaaa-aaaaa-qaaaq-cai trapped explicitly: RTS error: blob_of_principal: principal too short”

what do I need to do for solving it?

Thanks in advance

dfx canister status --all works, so the identity you’re currently using (dfx identity whoami) is a controller of your canisters. dfx canister install --identity default --all fails because the identity default is not a controller (see error message).

The RTS error sounds weird. What are your install arguments? It seems to come from here: motoko/principal_id.rs at master · dfinity/motoko · GitHub

Side note: if you use the anonymous identity to control your canisters anybody can hijack them

It’s solved. Was an easy one. As a beginner in Motoko, I didnt know that you can’t have multiple actors in the same canister (project/backend). It has to be a 1-1 relationship. Having multiple Motoko files in the same canister only 1 actor in main.mo is allowed. The other .mo files should be modules of the actor in main.mo

I hope this description fits.

I know the issue is already resolved, but just in case someone has the same error, here I found another cause. There may be other solutions for this specific case of course, but that one occurred to me and since it worked and does not represent any danger I left it :D.