Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remind to build before install #3446

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/tests-dfx/build_granular.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ teardown() {
dfx build e2e_project_backend
# validate assets canister wasn't built and can't be installed
assert_command_fail dfx canister install e2e_project_frontend
assert_match "No such file or directory"
assert_match "The canister must be built before install. Please run \`dfx build\`."
}


Expand Down
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
Loading