Package Details: rust-analyzer 20200224-2

Git Clone URL: https://aur.archlinux.org/rust-analyzer.git (read-only, click to copy)
Package Base: rust-analyzer
Description: An experimental Rust compiler front-end for IDEs.
Upstream URL: https://github.com/rust-analyzer/rust-analyzer
Keywords: lsp rust
Licenses: MIT, Apache
Conflicts: rust-analyzer-bin, rust-analyzer-git, rust-analyzer-vscode-git
Provides: rust-analyzer
Submitter: murlakatamenka
Maintainer: murlakatamenka
Last Packager: murlakatamenka
Votes: 2
Popularity: 0.83
First Submitted: 2020-01-14 20:32
Last Updated: 2020-02-24 21:32

Latest Comments

murlakatamenka commented on 2020-02-24 22:30

God, I'm sorry not for replying to this earlier.

cargo test gotta use all threads by default. But just one thread on single-core machine, interesting. Indeed it fails if run with a single thread:

cargo test --release --locked -- --test-threads 1

I may remove check section, tests are (most likely) run for each release via Github actions anyway, regressions shouldn't slip into tagged releases.


Make dependencies: rustup vs cargo. cargo is used for any rust package I've stumbled upon, it'll stay. Rust package guidelines examples -> ripgrep, for instance.


rust-src component should work as of now - see changelog:

#3206 automatically install rust-src component.

This potential issue is fixed upstream.


That's a good investigation, thank you! It appears editing PKGBUILD is still necessary for building on single-core VPS so far, but to a lesser extent.

ynakao commented on 2020-02-07 13:44

TL;DR - In chroot environment on single-core VPS, check() step failed, and I finally managed to compile rust-analyzer with the following PKGBUILD. What do you think?

diff --git a/PKGBUILD b/PKGBUILD
index 24887b0..43d22e2 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -8,7 +8,7 @@ pkgdesc="An experimental Rust compiler front-end for IDEs."
 arch=('x86_64')
 url="https://github.com/rust-analyzer/rust-analyzer"
 license=('MIT' 'Apache')
-makedepends=('cargo')
+makedepends=('rustup')
 provides=('rust-analyzer')
 conflicts=('rust-analyzer-bin' 'rust-analyzer-git' 'rust-analyzer-vscode-git')
 source=("$pkgname-$_pkgver.tar.gz::$url/archive/$_pkgver.tar.gz")
@@ -16,7 +16,7 @@ md5sums=('55a028ad2fedda26f32b5db1079d92a8')

 check() {
     cd "$pkgname-$_pkgver"
-    cargo test --release --locked
+    cargo test --release --locked -- --test-threads 2
 }

 pkgver() {
@@ -25,6 +25,8 @@ pkgver() {

 build() {
     cd "$pkgname-$_pkgver"
+    rustup update stable
+    rustup component add rust-src
     cargo build --release --locked
 }


Full explanation:

First of all, cargo test runs on a single thread by default on a single-core machine. This behavior affects the tests in ra_cargo_watch test which is using insta crate. You have to specify number of threads(two or more) by adding -- --test-threads 2 to cargo test, so that the tests run concurrently[0]. Error output is shown below. You can reproduce this error by passing -- --test-threads=1 instead on a multi-core machine.

[0] https://github.com/mitsuhiko/insta/issues/94#issuecomment-578546168

     Running target/release/deps/ra_cargo_watch-93180a4190410a65

running 7 tests
test conv::test::snap_clippy_pass_by_ref ... FAILED
test conv::test::snap_handles_macro_location ... FAILED
test conv::test::snap_macro_compiler_error ... FAILED
test conv::test::snap_rustc_incompatible_type_for_trait ... FAILED
test conv::test::snap_rustc_mismatched_type ... FAILED
test conv::test::snap_rustc_unused_variable ... FAILED
test conv::test::snap_rustc_wrong_number_of_parameters ... FAILED

failures:

---- conv::test::snap_clippy_pass_by_ref stdout ----
thread 'main' panicked at 'tests run with disabled concurrency, automatic snapshot name generation is not supported.  Consider using the "backtrace" feature of insta which tries to recover test names from the call stack.', /home/ynakao/.cargo/registry/src/github.com-1ecc6299db9ec823/insta-0.13.1/src/runtime.rs:474:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

---- conv::test::snap_handles_macro_location stdout ----
thread 'main' panicked at 'tests run with disabled concurrency, automatic snapshot name generation is not supported.  Consider using the "backtrace" feature of insta which tries to recover test names from the call stack.', /home/ynakao/.cargo/registry/src/github.com-1ecc6299db9ec823/insta-0.13.1/src/runtime.rs:474:13

---- conv::test::snap_macro_compiler_error stdout ----
thread 'main' panicked at 'tests run with disabled concurrency, automatic snapshot name generation is not supported.  Consider using the "backtrace" feature of insta which tries to recover test names from the call stack.', /home/ynakao/.cargo/registry/src/github.com-1ecc6299db9ec823/insta-0.13.1/src/runtime.rs:474:13

---- conv::test::snap_rustc_incompatible_type_for_trait stdout ----
thread 'main' panicked at 'tests run with disabled concurrency, automatic snapshot name generation is not supported.  Consider using the "backtrace" feature of insta which tries to recover test names from the call stack.', /home/ynakao/.cargo/registry/src/github.com-1ecc6299db9ec823/insta-0.13.1/src/runtime.rs:474:13

---- conv::test::snap_rustc_mismatched_type stdout ----
thread 'main' panicked at 'tests run with disabled concurrency, automatic snapshot name generation is not supported.  Consider using the "backtrace" feature of insta which tries to recover test names from the call stack.', /home/ynakao/.cargo/registry/src/github.com-1ecc6299db9ec823/insta-0.13.1/src/runtime.rs:474:13

---- conv::test::snap_rustc_unused_variable stdout ----
thread 'main' panicked at 'tests run with disabled concurrency, automatic snapshot name generation is not supported.  Consider using the "backtrace" feature of insta which tries to recover test names from the call stack.', /home/ynakao/.cargo/registry/src/github.com-1ecc6299db9ec823/insta-0.13.1/src/runtime.rs:474:13

---- conv::test::snap_rustc_wrong_number_of_parameters stdout ----
thread 'main' panicked at 'tests run with disabled concurrency, automatic snapshot name generation is not supported.  Consider using the "backtrace" feature of insta which tries to recover test names from the call stack.', /home/ynakao/.cargo/registry/src/github.com-1ecc6299db9ec823/insta-0.13.1/src/runtime.rs:474:13


failures:
    conv::test::snap_clippy_pass_by_ref
    conv::test::snap_handles_macro_location
    conv::test::snap_macro_compiler_error
    conv::test::snap_rustc_incompatible_type_for_trait
    conv::test::snap_rustc_mismatched_type
    conv::test::snap_rustc_unused_variable
    conv::test::snap_rustc_wrong_number_of_parameters

test result: FAILED. 0 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '-p ra_cargo_watch --lib'

The next error message appeared from tidy_tests test after fixing the thread issue. I think cargo dependency has to be replaced with rustup and rust toolchain needs to be installed by rustup stable update.

     Running target/release/deps/tidy_tests-b1ec6b3ce66645d4

running 6 tests
test cli::check_code_formatting ... FAILED
test cli::generated_assists_are_fresh ... FAILED
test cli::generated_grammar_is_fresh ... FAILED
test cli::generated_tests_are_fresh ... ok
test cli::no_todo ... ok
test docs::no_docs_comments ... ok

failures:

---- cli::check_code_formatting stdout ----

will run: rustup toolchain install stable
thread 'cli::check_code_formatting' panicked at 'running `rustup toolchain install stable`. Please format the code by running `cargo format`', xtask/tests/tidy-tests/cli.rs:31:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

---- cli::generated_assists_are_fresh stdout ----

will run: rustup toolchain install stable
thread 'cli::generated_assists_are_fresh' panicked at 'running `rustup toolchain install stable`. Please update assists by running `cargo xtask codegen`', xtask/tests/tidy-tests/cli.rs:24:9

---- cli::generated_grammar_is_fresh stdout ----

will run: rustup toolchain install stable
thread 'cli::generated_grammar_is_fresh' panicked at 'running `rustup toolchain install stable`. Please update it by running `cargo xtask codegen`', xtask/tests/tidy-tests/cli.rs:10:9


failures:
    cli::check_code_formatting
    cli::generated_assists_are_fresh
    cli::generated_grammar_is_fresh

test result: FAILED. 3 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '-p xtask --test tidy-tests'
==> ERROR: A failure occurred in check().
    Aborting...

Finally, one more tweak needs to be added in PKGBUILD. Without rustup component add rust-src another error occurs from ra_batch test.

     Running target/release/deps/ra_batch-ca8e98004882c496

running 1 test
test tests::test_loading_rust_analyzer ... test tests::test_loading_rust_analyzer has been running for over 60 seconds
test tests::test_loading_rust_analyzer ... FAILED

failures:

---- tests::test_loading_rust_analyzer stdout ----
thread 'tests::test_loading_rust_analyzer' panicked at 'called `Result::unwrap()` on an `Err` value: "can\'t load standard library from sysroot\n/build/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src\n(discovered via `rustc --print sysroot`)\ntry running `rustup component add rust-src` or set `RUST_SRC_PATH`"', src/libcore/result.rs:1188:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.


failures:
    tests::test_loading_rust_analyzer

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '-p ra_batch --lib'
==> ERROR: A failure occurred in check().
    Aborting...