dfinity / vscode-motoko

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

extension does not recognize canister alias when project is in subdirectory #186

Closed letmejustputthishere closed 1 year ago

letmejustputthishere commented 1 year ago

consider the following structure

my-monorepo/
  |- package.json
  |- yarn.lock
  |- workspaces/
      |- canister/
          |- Cargo.toml
          |- src/
      |- proxy/
          |- package.json
          |- src/

when importing a canister using the canister:canister_name syntax, when i launch vscode from within the my-monorepo folder, the following error appears

Screenshot 2023-03-08 at 15 45 13

when launching vscode from within the canister folder, everything works as expected.

rvanasa commented 1 year ago

Thank you for all these bug reports! I will include this in the backlog for the next time I get a chance to improve the extension (currently juggling a lot of projects).

If anyone else encounters this issue, please feel free to +1 this issue so I can get a sense for how this should be prioritized. Thanks!

ZenVoich commented 1 year ago

Probably same issue, but I get different error: image

dfx.json:

{
  "version": 1,
  "canisters": {
    "staging": {
      "type": "motoko",
      "main": "src/main.mo",
      "declarations": {
        "output": "declarations/main"
      },
      "dependencies": [
        "ledger"
      ]
    },
    "ledger": {
      "type": "custom",
      "wasm": "./declarations/ledger/ledger.wasm",
      "candid": "./declarations/ledger/ledger.private.did",
      "remote": {
        "candid": "./declarations/ledger/ledger.public.did",
        "id": {
          "ic": "ryjl3-tyaaa-aaaaa-aaaba-cai"
        }
      }
    },
    "production": {
      "type": "motoko",
      "main": "src/main.mo",
      "dependencies": [
        "ledger"
      ]
    }
  },
  "defaults": {
    "build": {
      "packtool": "vessel sources",
      "args": "--trap-on-call-error"
    }
  }
}

dfx deploy works well

letmejustputthishere commented 1 year ago

@rvanasa seems like the .dfx/local/lsp files don't get updated when you deploy a canister using --mode reinstall. steps to reproduce:

  1. deploy ledger with private did
  2. update dfx.json to public did
  3. deploy ledger dependent canister with --mode reinstall
  4. above error message is shown
rvanasa commented 1 year ago

Thanks for the repro; this appears to be directly caused by the issue tracked in https://github.com/dfinity/sdk/issues/2996, https://github.com/dfinity/sdk/issues/2969, and SDK-1019. Would it be okay if I closed this to help consolidate the conversation?

letmejustputthishere commented 1 year ago

sure :)