aya-rs / aya-template

A cargo-generate template for Rust eBPF Projects using Aya
81 stars 41 forks source link

{{project-name}}-ebpf Rust's ebpf module does not support code jumps and code hints on vscode #114

Closed liuxuzxx closed 3 months ago

liuxuzxx commented 3 months ago
  1. I use the following command to generate aya's ebpf program project
    cargo generate --name myapp -d program_type=xdp https://github.com/aya-rs/aya-template
  2. When I open the project using vscode the myapp-ebpf module does not support code jumps and code hints on vscode, but other generated modules work fine on vscode

My environment is:

  1. Vscode Version: 1.91.1 Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:08:12.169Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 6.8.0-39-generic
  2. OS Ubuntu 24.04
  3. Vscode plugin: rust-analyzer v0.3.2045
liuxuzxx commented 3 months ago

But when I use vscode to open {{projectName}}-ebpf alone, vscode's code prompts and jumps are normal, which means rust-analyzer works.

liuxuzxx commented 3 months ago

I found this configuration to be invalid

{
  "rust-analyzer.linkedProjects": [
    "Cargo.toml",
    "tracepoint-hello-ebpf/Cargo.toml",
    "liuxu-found/Cargo.toml"
  ]
}
liuxuzxx commented 3 months ago

I resolved the problem, Look: https://github.com/rust-lang/rust-analyzer/issues/17664 .It is a bug of rust-analyzer

liuxuzxx commented 3 months ago

rust-analyzer: v0.3.2053

So You must modify the path to (Use the absolute path):

{
  "rust-analyzer.linkedProjects": [
    "Cargo.toml",
    "/xx/xxxxx/tracepoint-hello-ebpf/Cargo.toml",
    "/xx/xxxxx/liuxu-found/Cargo.toml"
  ]
}

如果使用的最近基本版本的rust-analyzer,那么就需要使用绝对地址来解决

liuxuzxx commented 3 months ago

Or use this:

{
  "rust-analyzer.linkedProjects": [
    "${workspaceFolder}/Cargo.toml",
    "${workspaceFolder}/tracepoint-hello-ebpf/Cargo.toml"
  ]
}