error: lock file
phamminh0811 opened this issue · 8 comments
Hi! I'm stuck trying to optimize a smart contract.
When I run rust-optimizer in the root folder of a clean copy of https://github.com/InterWasm/cw-template I get this problem:
docker run --rm -v "$(pwd)":/code --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry cosmwasm/rust-optimizer:0.12.10
Info: RUSTC_WRAPPER=sccache
Info: sccache stats before build
Compile requests 0
Compile requests executed 0
Cache hits 0
Cache misses 0
Cache timeouts 0
Cache read errors 0
Forced recaches 0
Cache write errors 0
Compilation failures 0
Cache errors 0
Non-cacheable compilations 0
Non-cacheable calls 0
Non-compilation calls 0
Unsupported compiler calls 0
Average cache write 0.000 s
Average cache read miss 0.000 s
Average cache read hit 0.000 s
Failed distributed compilations 0
Cache location Local disk: "/root/.cache/sccache"
Cache size 0 bytes
Max cache size 10 GiB
Building contract in /code ...
Updating crates.io index
error: the lock file /code/Cargo.lock needs to be updated but --locked was passed to prevent this
If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
Can somebody help me please?
My rustup and cargo:
Default host: x86_64-unknown-linux-gnu
rustup home: /home/anhminh/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
1.56.0-x86_64-unknown-linux-gnu
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.65.0 (897e37553 2022-11-02)
I think the problem is that optimize.sh file has the RUSTFLAGS='-C link-arg=-s' cargo build --release --lib --target wasm32-unknown-unknown --locked
command, but I don't know how to fix it
cw-template
cannot be used directly. You need to generate a project from the template first using cargo-generate. Did you do that?
cw-template
cannot be used directly. You need to generate a project from the template first using cargo-generate. Did you do that?
Yes, I do use cargo-generate, but not work.
okay. Then you probably need to run cargo build
to update the Cargo.lock before running rust-optimizer.
okay. Then you probably need to run
cargo build
to update the Cargo.lock before running rust-optimizer.
Not work, either. It's still the same error
You have to run cargo update
. This will update all crates assuming SemVer compatibility /a.k.a. will update only minor and patch versions/ on behalf of the crates.
Awesome, problem is fixed. Thanks so much