dfinity / vscode-motoko

Motoko language support for VS Code.
Apache License 2.0
42 stars 15 forks source link

management canister did file not found #263

Closed letmejustputthishere closed 4 months ago

letmejustputthishere commented 5 months ago

this canister builds, and .dfx/local/canisters/idl/aaaaa-aa.did is being generated.

import Management "ic:aaaaa-aa";

actor class Main() {
    public func greet(name : Text) : async Text {
        ignore await Management.raw_rand();
        return "Hello, " # name # "!";
    };
};

the vscode extension wants the did in a different path though file "/Users/moritz/projects/icrc7_launchpad/.dfx/local/lsp/aaaaa-aa.did" does not existMotoko(M0009)

dfx 0.16.0 motoko extension v0.14.8

rvanasa commented 5 months ago

Here is a workaround which we use in the base library (source code):

actor class Main() {
    let Management = (actor "aaaaa-aa" : actor {
        raw_rand : () -> async Blob;
    });

    public func greet(name : Text) : async Text {
        ignore await Management.raw_rand();
        return "Hello, " # name # "!";
    };
};

I'll see if there's any way we can solve this within the VS Code extension; otherwise it might be necessary to fix this in dfx or the Motoko compiler.

Update: it sounds as though there are already plans to address this on the replica end. I'll keep an eye on this in case anything else is needed from the extension.

letmejustputthishere commented 5 months ago

thanks for the workaround. another way of solving this without having to rewrite the management canister interface is to simply copy the aaaaa-aa.did to .dfx/local/lsp

ggreif commented 5 months ago

Some projects just check in the IC.mo file like this: https://github.com/sonicdex/motoko-token-canister/blob/main/src/token/Cap.mo#L9

letmejustputthishere commented 5 months ago

yes, but then i have to generate the motoko bindings from the did file which adds friction

rvanasa commented 4 months ago

The extension now uses a default management canister Candid file as of v0.15.0. This should resolve the issue; otherwise, let me know and I'll take another look.

letmejustputthishere commented 4 months ago

hey @rvanasa, i see your hardcoding the management canister did. is there a way to include it via git submodules or smth similar? i just recently opened a PR there to make working with it a bit more convenient

rvanasa commented 4 months ago

Thanks for the link! I set up a script to regenerate the Candid file from this URL before packaging the extension (#265).