Closed miguelemosreverte closed 4 years ago
For a moment I thought the problem was caused by me by creating the canisters manually, so I deleted them and ran
dfx canister create --all
which what it does is it looks-up the dfx.json file in order to properly load the source files and start the canisters properly.
However... no luck, guys!
$ dfx canister create --all Creating canister "pub"... "pub" canister created with canister id: "6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" Creating canister "sub"... "sub" canister created with canister id: "a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" $ sh test.sh Building canisters... Build failed. Reason: Build step failed for canister 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q with error: Build failed. Reason: Command "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/moc" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo" "-o" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/pub/pub.did" "--idl" "--actor-idl" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/idl/" "--actor-alias" "pub" "6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--actor-alias" "sub" "a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--package" "base" "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/base" returned an error: /home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo:8.1-22.2: type error, an actor or actor class must be the only non-imported declaration in a program (This is a limitation of the current version.)
Installing code for canister pub, with canister_id 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q An error occured: Io( Os { code: 2, kind: NotFound, message: "No such file or directory", }, ) cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
Finally I arrived at the conclusion that the problem could be caused by not running
dfx build
on the pub_sub folder, so I did. But still... no luck on my end!
$ dfx build Building canisters... Build failed. Reason: Build step failed for canister 6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q with error: Build failed. Reason: Command "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/moc" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo" "-o" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/pub/pub.did" "--idl" "--actor-idl" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/idl/" "--actor-alias" "pub" "6ezpl-pyhaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--actor-alias" "sub" "a5gvd-vyiaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--package" "base" "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/base" returned an error: /home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo:8.1-22.2: type error, an actor or actor class must be the only non-imported declaration in a program (This is a limitation of the current version.)
@crusso any idea how to fix this?
The types here: https://github.com/dfinity/examples/blob/96dc5b080fa83d8743e311ea8e8a7e047fc3ab36/motoko/pubsub/src/sub/main.mo#L5
Need to either be moved into the actor definitions, which also means adding a public
to them, or be moved into a common "Types" module that can be imported from both.
Question, how to write tests? If I knew how to write them I could make a fork that uses Github CI and make a PR so that these simple bugs could be found at code review
Hello, I know it does sound like a low effort comment to ask 'how to test', but in the language docs I see no mentions, and if I land over here https://github.com/dfinity/motoko-base/tree/master/test, I would still not know how to run them:
dfx test? Coming from a Scala background I would expect the two keywords to work, as in sbt test
What am I missing? Could you point me to a few links for me to study and come back with results? Results: I firmly want to express my interest on this project and more so on making benchmarks comparisons from one example like pubsub against the exact equivalent using Scala + Akka. Adding tests to this repository is my focus right now.
Is this how it works?
In test/, run
make
Taken from https://github.com/dfinity/motoko-base
PR #52 Fixed this Issue. Closing.
Hello there, I wanted to create a benchmark of this project and landed on the examples which looked promising.
However, this happened. It fails to build!
$ dfx canister create sub Creating canister "sub"... "sub" canister created with canister id: "do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" $ dfx canister create pub Creating canister "pub"... "pub" canister created with canister id: "6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" $ sh test.sh Building canisters... Build failed. Reason: Build step failed for canister 6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q with error: Build failed. Reason: Command "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/moc" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo" "-o" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/pub/pub.did" "--idl" "--actor-idl" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/idl/" "--actor-alias" "pub" "6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--actor-alias" "sub" "do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--package" "base" "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/base" returned an error: /home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo:8.1-22.2: type error, an actor or actor class must be the only non-imported declaration in a program (This is a limitation of the current version.)
Installing code for canister pub, with canister_id 6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q An error occured: Io( Os { code: 2, kind: NotFound, message: "No such file or directory", }, ) cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister 6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister 6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module cannot find method type, dfx will send message with inferred type Replica error (code 3): IC0304: Attempt to execute a message on canister do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module