Skip to content

Commit

Permalink
fix: custom canisters with a read-only wasm no longer fail to build w…
Browse files Browse the repository at this point in the history
…ith a permissions error (#4066)

Fixes: https://dfinity.atlassian.net/browse/SDK-1848
  • Loading branch information
ericswanson-dfinity authored Jan 24, 2025
1 parent 3fb8553 commit 455cd63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ This affects the following commands:
Canisters with Motoko's Enhanced Orthogonal Persistence feature require `wasm_memory_persistence = Keep` when they get installed.
Previously, when `dfx` attempted to install canisters with EOP enabled to a playground it didn't set `wasm_memory_persistence` properly.

### fix: custom canisters with a read-only wasm no longer fail to build with a permissions error

### chore: improve `dfx deploy` messages.

If users run `dfx deploy` without enough cycles, show additional messages to indicate what to do next.
Expand Down
14 changes: 14 additions & 0 deletions e2e/tests-dfx/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ teardown() {
standard_teardown
}

@test "build custom canister succeeds even if input wasm is read-only" {
install_asset custom_canister
install_asset wasm/identity
chmod u-w main.wasm

dfx_start
dfx canister create --all
assert_command dfx build custom

jq '.canisters.custom.shrink=true' dfx.json | sponge dfx.json
jq '.canisters.custom.gzip=false' dfx.json | sponge dfx.json
assert_command dfx build custom
}

@test "can build a custom canister with wasm and/or candid from a url" {
install_asset wasm/identity
mkdir -p www/wasm
Expand Down
1 change: 1 addition & 0 deletions src/dfx/src/lib/models/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl Canister {
// If not modified and not set "gzip" explicitly, copy the wasm file directly so that hash match.
if !modified && !info.get_gzip() {
dfx_core::fs::copy(build_output_wasm_path, &wasm_path)?;
dfx_core::fs::set_permissions_readwrite(&wasm_path)?;
return Ok(());
}

Expand Down

0 comments on commit 455cd63

Please sign in to comment.