Rust-analyzer failed to load workspace - rust

rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.tml file /home/eth/Downloads/testing/Cargo.toml, cargo 1.33.0-nightly (0d1f1bbea 2018-12-19): Failed to run '"cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/eth/Downloads/testing/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu"': 'cargo metadata' exited with an error: error: Found argument '--filter-platform' which wasn't expected, or isn't valid in this context
I needed to reinstall my OS few days back, and when I installed and configured my plugins in NeoVim - CoC is being used for code suggestion -, that error came out. I believe that's not a NeoVim/CoC problem, that's why I tagged it so. I don't have much experience dealing with that kinda stuff, so I don't even know what else information I could provide...

Update Rust.
rust-analyzer invokes the command cargo metadata with the flag --filter-platform. This flag was added in Rust 1.41.0. Since you're using an older Rust version (1.33.0), Cargo complains.

Related

Rust-Analyzer failed to load workspace, failing because of dependencies

[ERROR rust_analyzer::reload] failed to switch workspaces:
rust-analyzer failed to load workspace:
Failed to read Cargo metadata from Cargo.toml file
/home/supreetsingh/Documents/SavedPrograms/Rust/remind-me/Cargo.toml,
cargo 1.57.0-nightly (7fbbf4e8f 2021-10-19): Failed to run `cargo metadata --manifest-path
/home/supreetsingh/Documents/SavedPrograms/Rust/remind-me/Cargo.toml`: `cargo metadata` exited with an error: Updating crates.io index error: failed to select a version for the requirement `phf = "^0.11"`
candidate versions found which didn't match: 0.10.1, 0.10.0, 0.9.0, ... location searched: crates.io index required by package `tokio-postgres v0.7.7` ... which satisfies dependency `tokio-postgres = "^0.7.7"` (locked to 0.7.7) of package `postgres v0.19.4` ... which satisfies dependency `postgres = "^0.19.4"` (locked to 0.19.4) of package `remind-me v0.1.0 (/home/supreetsingh/Documents/SavedPrograms/Rust/remind-me)
So this problem is just arising in one rust project of mine. Cargo is in the path and this problem arose when I added one new dependency to my project and now I am stuck with this.
I have tried looking for the answer on the internet and did not find success yet, I do not know what else to try next.
cargo metadata --manifest-path <path to the file>
Works in the console I do not know why is this not working right now.
I am running this on Manjaro and my text editor is Vim with YouCompleteMe being used for AutoComplete.
If someone can point out what is wrong with the dependencies, I would be very thankful.
Thanks.
phf 0.11 requires Rust 1.60. You need to either update your Rust compiler to at least that version, or follow the chain of dependencies and downgrade the postgres crate so that you don't require phf 0.11.

cargo version 2021 required on Solana anchor build

I am trying to run anchor build and am receiving the following response:
BPF SDK: /root/.local/share/solana/install/releases/1.8.0/solana-release/bin/sdk/bpf
Running: rustup toolchain list -v
Running: cargo +bpf build --target bpfel-unknown-unknown --release
error: failed to download `solana-frozen-abi v1.9.4`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/root/.cargo/registry/src/github.com-1ecc6299db9ec823/solana-frozen-abi-1.9.4/Cargo.toml`
Caused by:
feature `edition2021` is required
consider adding `cargo-features = ["edition2021"]` to the manifest
PS: I have already tried suggestions at: Unable to specify `edition2021` in order to use unstable packages in Rust
It looks like your solana install is quite out of date. I would install either 1.8.11 or just run solana-install update
At times, also consider downloading to like in my case I had to change from 2021 in my Cargo.toml file to 2018 and this has worked

Cannot use cargo uninstall to uninstall packages in ~/.cargo: package id specification matched no package

I'm having trouble uninstalling Cargo-installed packages from my system.
There are packages like rand-0.3.22 that are obviously installed under $HOME/.cargo
ls ~/.cargo/registry/src/github.com-1ecc6299db9ec823/ra
racer-2.0.14/ rand-0.3.22/ rand-0.4.2/
rand-0.4.3/ rand-0.5.5/ rand_core-0.2.1/
rawpointer-0.1.0/ rayon-1.0.2/ rayon-core-1.4.1/
This can also be verified by using cargo pkgid
cargo pkgid -p rand
error: There are multiple `rand` packages in your project, and the specification `rand` is ambiguous.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
rand:0.5.5
rand:0.4.3
rand:0.3.22
However, I'm unable to remove that package with cargo uninstall. None of these seem to work:
cargo uninstall rand
cargo uninstall -- rand:0.4.3
cargo uninstall https://github.com/rust-lang/crates.io-index#rand:0.4.3
For any of the commands above I get:
error: invalid package id specification: <name-of-package-i-specified>
This seems like a rather basic operation so I suspect it's something fundamental to how cargo-uninstall is to be used.
Any pointers?
cargo uninstall undoes the effect of cargo install. You did not cargo install rand, because it is just a library, not an executable program. That means it was not installed.
The ~/.cargo/registry is just a cache of build dependencies. Feel free to wipe it anytime; cargo will re-download and re-build whatever it needs when it does.
Yes, it is wrong. Cargo should be using .local, .config and .cache as appropriate; then it would be obvious what you can just clean up. Using arbitrary dot-dirs is an insult at this day and age. It was reported, several times probably. Nobody got around to fixing it yet.

Error in attempting to create a new Stack project with GHCJS compiler

I am attempting to set up a new Stack project on NixOS with GHCJS as the compiler following the instructions at http://docs.haskellstack.org/en/stable/ghcjs.html
I have included in my stack.yaml file the following lines of code (all on one line because tab spaces seem to give issues):
# Compiler specifying the GHCJS compiler for this project (using improved base).
compiler: ghcjs-0.2.0.20151230.3_ghc-7.10.2
compiler-check: match-exact
setup-info:
ghcjs: source:
ghcjs-0.2.0.20151230.3_ghc7.10.2:
url: "https://github.com/nrolland/ghcjs/releases/download/v.0.2.0.20151230.3/ghcjs-0.2.0.20151230.3.tar.gz"
and I have retrieved the following error message when I ran stack setup
Could not parse '/home/lorkaan/pandocJS/stack.yaml':
InvalidYaml (Just (YamlParseException {yamlProblem = "mapping values are not allowed in this context", yamlContext = "", yamlProblemMark = YamlMark {yamlIndex = 487, yamlLine = 12, yamlColumn = 17}}))
See https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md.
Additionally, I tried removing the setup-info field because Stack was complaining about it, leaving my stack.yaml file like:
# Compiler specifying the GHCJS compiler for this project (using improved base).
compiler: ghcjs-0.2.0.20151230.3_ghc-7.10.2
compiler-check: match-exact
which produces this output with the stack setup command:
Warning: /home/lorkaan/pandocJS/stack.yaml: Unrecognized field in ProjectAndConfigMonoid: compiler
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
The following executables are missing and must be installed: make
Does anybody have any idea why this would be happening?
the first error is because of a basic syntax error in your YAML configuration. The correct version would be:
setup-info:
ghcjs:
source:
ghcjs-0.2.0.20151230.3_ghc7.10.2:
url: "https://github.com/nrolland/ghcjs/releases/download/v.0.2.0.20151230.3/ghcjs-0.2.0.20151230.3.tar.gz"
The second error is because of exactly what it says: you are lacking the make utility. You need to use your Linux distribution's package management system to install make. Since I don't know which distribution you are on, I can only recommend simply executing the $ make command and seeing if the environment is smart enough to point out which package it can be found in. Ubuntu typically does that. Then it's only a matter of apt-get install-ing the package, or possibly yum install-ing on e.g. CentOS and Fedora, etc.
P.S. questions like yours normally get a downvote for not having shown sufficient effort in diagnosing the problem (or for putting 2 totally separate problems under a single question) but I'm giving you the benefit of the doubt and just hoping you'll be tidier next time.

Haxe: rebuild hxcpp failed with Error: Could not find build target "std"

Trying to rebuild hxcpp failed with the cryptic error message:
Error: Could not find build target "std"
Some users report this hint (I swear I didn't see it when I hit the issue, unless I'm just blind):
Have you tried rebuilding the hxcpp.n and build.n scripts?
This is done by running haxe in the tools/hxcpp and tools/build directories.
Hence:
cd hxcpp/tools/hxcpp
haxe compile.hxml
cd ../build
haxe compile.hxml
Fixes it.
Also note that nightly hxcpp builds are available from nmehost.com and openfl.org if you just need a newer version than what's available via haxelib.

Resources