Skip to content

Commit

Permalink
fix: remind to build before install
Browse files Browse the repository at this point in the history
  • Loading branch information
lwshang committed Nov 16, 2023
1 parent e91c27c commit e92b479
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions e2e/tests-dfx/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,10 @@ teardown() {
assert_command_fail dfx canister install --all --argument '()'
assert_contains "error: the argument '--all' cannot be used with '--argument <ARGUMENT>'"
}

@test "remind to build before install" {
dfx_start
dfx canister create --all
assert_command_fail dfx canister install e2e_project_backend
assert_contains "The canister must be built before install. Please run \`dfx build\`."
}
8 changes: 6 additions & 2 deletions src/dfx/src/lib/operations/canister/install_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,13 @@ pub async fn install_canister(
let wasm_path: PathBuf = if let Some(wasm_override) = wasm_path_override {
wasm_override.into()
} else {
canister_info
let build_wasm_path = canister_info
.map(|info| info.get_build_wasm_path())
.context("Failed to find wasm")?
.context("Failed to find wasm")?;
if !build_wasm_path.exists() {
bail!("The canister must be built before install. Please run `dfx build`.");
}
build_wasm_path
};
let wasm_module = std::fs::read(&wasm_path)
.with_context(|| format!("Failed to read {}.", &wasm_path.display()))?;
Expand Down

0 comments on commit e92b479

Please sign in to comment.