Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for projects without Cargo.toml #8818

Closed
boehs opened this issue May 13, 2021 · 11 comments
Closed

Support for projects without Cargo.toml #8818

boehs opened this issue May 13, 2021 · 11 comments

Comments

@boehs
Copy link

boehs commented May 13, 2021

I have been using rust-script for some small projects. Unfortunately, rust-analyzer won't work because it can't find cargo.toml. Is there a work around for this?

@memoryruins
Copy link
Contributor

Check out https://rust-analyzer.github.io/manual.html#non-cargo-based-projects for how to setup r-a to work without cargo.

@boehs
Copy link
Author

boehs commented May 13, 2021

Check out https://rust-analyzer.github.io/manual.html#non-cargo-based-projects for how to setup r-a to work without cargo.

Solved! Thank you!

@boehs boehs closed this as completed May 13, 2021
@boehs
Copy link
Author

boehs commented May 13, 2021

hey @memoryruins, I feel really silly but I just can't for the life of me get any form of autocomplete working with my noncargo project. I put rust-project.json in the project root and in it I have

{
    "sysroot_src": "C:/Users/ebrob/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library",
    "crates": [
        {
            "root_module": "src/main.rs",
            "edition": "2018",
            "deps": []
        }
    ]
}

No errors appear, it seems like it would work, and yet the only source of autocomplete is from tabnine, not fun.

Its surely a silly mistake on my end.

@boehs boehs reopened this May 13, 2021
@lf-
Copy link
Contributor

lf- commented May 13, 2021

hey @memoryruins, I feel really silly but I just can't for the life of me get any form of autocomplete working with my noncargo project. I put rust-project.json in the project root and in it I have

{
    "sysroot_src": "C:/Users/ebrob/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library",
    "crates": [
        {
            "root_module": "src/main.rs",
            "edition": "2018",
            "deps": []
        }
    ]
}

No errors appear, it seems like it would work, and yet the only source of autocomplete is from tabnine, not fun.

Its surely a silly mistake on my end.

Huh. I have working completion with this one, which looks to be the same as yours:

{
    "sysroot_src": "/home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library",
    "crates": [
        {
            "root_module": "src/main.rs",
            "edition": "2015",
            "deps": []
        }
    ]
}

Try setting RA_LOG and seeing what you can find, here's one that is not too spammy. Add the below snippet into your JSON settings for your editor, then look in the output view for the R-A language server. It is in :CocCommand workspace.showOutput in coc.nvim, and the Output tab next to the terminal with the dropdown "Rust Analyzer Language Server" in VSCode. I hope this will get you some logs that might be useful.

    "rust-analyzer.server.extraEnv": {
        "RA_LOG": "info,salsa::derived::slot=warn,rust_analyzer::main_loop=warn,project_model=debug"
    }

@boehs
Copy link
Author

boehs commented May 13, 2021

o/ @lf- , if I did everything right I should be getting output, here it is as a paste (I, unfortunately, could not find anything odd) https://pastie.io/vmjaqb.sql

I can't imagine there is a conflict somewhere, the normal Rust extension function(ed) fine, until I uninstalled it in favor of rust-analyzer

@boehs
Copy link
Author

boehs commented Jun 7, 2021

I was hoping the lastest PR's would fix this, but not. I have tried

  1. Reinstalling RA for vscode
  2. Running rustup update
  3. Switching to RA nightly

I also am having this issue:

It works wonderfully in cargo projects. Please help!

@boehs
Copy link
Author

boehs commented Jun 10, 2021

The RA server trace in vscode says

[ERROR rust_analyzer] failed to find any projects in [AbsPathBuf("c:\\Users\\snip\\PersonalFiles\\Code\\stuff\\random\\rust")]

@metaclips
Copy link

Hello, so I also need to use rust-project.json to detect my rust projects but slightly for a different case as my projects have a cargo.toml.

Here's my architecture.

Dir
rust-project.json
named folder

project one which is a library
project two which is a library

Code here.
Is it possible to indicate project 1 and 2 as crates (where rust-analyzer sees the cargo.toml)?
Can we have interdependencies where a crate(project) depends on the other?

@flodiebold
Copy link
Member

You probably just want the linkedProjects setting. rust-project.json means you're not using Cargo at all.

@metaclips
Copy link

You probably just want the linkedProjects setting. rust-project.json means you're not using Cargo at all.

Love and light. Thanks.

@boehs
Copy link
Author

boehs commented Jul 25, 2021

Closed as partial support has been added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants