Skip to content

Commit

Permalink
Improve the error message for 'dfx deploy'.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-dfinity committed Oct 29, 2024
1 parent 064e4ff commit bca9672
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions e2e/tests-dfx/deploy.bash
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ teardown() {
assert_contains "Creating a wallet canister"
}

@test "deploy without starting returns the correct error message" {
assert_command_fail dfx deploy
assert_contains "Failed to fetch the root key, did you run 'dfx start' to start the local replica?"
}

@test "can deploy gzip wasm" {
jq '.canisters.hello_backend.gzip=true' dfx.json | sponge dfx.json
dfx_start
Expand Down
4 changes: 3 additions & 1 deletion src/dfx/src/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ pub fn exec(env: &dyn Environment, opts: DeployOpts) -> DfxResult {
let call_sender = CallSender::from(&opts.wallet, env.get_network_descriptor())
.map_err(|e| anyhow!("Failed to determine call sender: {}", e))?;

runtime.block_on(fetch_root_key_if_needed(&env))?;
// This is where we try to talk to replica first.
runtime.block_on(fetch_root_key_if_needed(&env))
.map_err(|e| anyhow!("Failed to fetch the root key, did you run 'dfx start' to start the local replica?\n{}", e))?;

runtime.block_on(deploy_canisters(
&env,
Expand Down

0 comments on commit bca9672

Please sign in to comment.