diff --git a/e2e/tests-dfx/deploy.bash b/e2e/tests-dfx/deploy.bash index 709f912f8e..b93b129292 100644 --- a/e2e/tests-dfx/deploy.bash +++ b/e2e/tests-dfx/deploy.bash @@ -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 diff --git a/src/dfx/src/commands/deploy.rs b/src/dfx/src/commands/deploy.rs index 78751a62de..d3ab482693 100644 --- a/src/dfx/src/commands/deploy.rs +++ b/src/dfx/src/commands/deploy.rs @@ -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,