Rust-analyzer inside of an fhsenv

I’m doing Rust + webpack development inside of an FHS environment, and most everything is great. However, the code is also large enough that RLS is just excruciatingly slow, and all of my co-workers want me to switch to rust-analyzer.

Which I’ve tried, however rust-analyzer crashes inside of the FHS environment, and the backtrace is really uninformative:

[env] savanni@garnet:~/s/a/core $ rust-analyzer
Segmentation fault (core dumped)
[env] savanni@garnet:~/s/a/core $ gdb
GNU gdb (GDB) 8.3.1
...
(gdb) core core.14516 
[New LWP 14516]
Core was generated by `/nix/store/6737cq9nvp4k5r70qcgf61004r0l2g3v-bash-4.4-p23/bin/bash -e /usr/bin/r'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fff67dfde06 in getcpu ()
(gdb) backtrace
#0  0x00007fff67dfde06 in getcpu ()
#1  0x00007f74145f5f07 in ?? ()
#2  0x0000000000000000 in ?? ()
(gdb) 

This is going to be a little long, but this is my FHS bundle:

    fhsEnv = pkgs.buildFHSUserEnv {
        name = "project-fhs";
        targetPkgs = pkgs: [
            pkgs.alsaLib
            pkgs.at-spi2-atk
            pkgs.at-spi2-core
            pkgs.atk
            pkgs.binutils
            pkgs.cairo
            pkgs.cairo.dev
            pkgs.clang
            pkgs.cups
            pkgs.curl
            pkgs.glibc
            pkgs.dbus
            pkgs.dbus.dev
            pkgs.dpkg
            pkgs.expat
            pkgs.gcc
            pkgs.gdb
            pkgs.gdk-pixbuf
            pkgs.git
            pkgs.glib
            pkgs.glib.dev
            pkgs.gnumake
            pkgs.gtk3
            pkgs.gtk3-x11
            pkgs.jq
            pkgs.lcov
            pkgs.libdrm
            pkgs.llvm_10
            pkgs.lsb-release
            pkgs.mesa
            pkgs.nodejs-12_x
            pkgs.nspr
            pkgs.nss
            pkgs.openssl
            pkgs.openssl.dev
            pkgs.pango
            pkgs.pkgconfig
            pkgs.python3
            pkgs.python3Packages.pip
            pkgs.rustup
            pkgs.stdenv.cc
            pkgs.udev
            pkgs.unzip
            pkgs.vim
            pkgs.xorg.libX11
            pkgs.xorg.libxcb
            pkgs.xorg.libXcomposite
            pkgs.xorg.libXcursor
            pkgs.xorg.libXdamage
            pkgs.xorg.libXext
            pkgs.xorg.libXfixes
            pkgs.xorg.libXi
            pkgs.xorg.libXrandr
            pkgs.xorg.libXrender
            pkgs.xorg.libXScrnSaver
            pkgs.xorg.libXtst
            pkgs.yarn
            pkgs.zip
            pkgs.zlib
            pkgs.zlib.dev
            rust.rust
            rust.rust-src
            unstable.rust-analyzer
            unstable.wasm-pack
        ];

        runScript = "bash --init-file /etc/profile";
        ...

What should I add in? In the past, say when Electron crashed, I was able to finally trace it to a missing library that was being loaded dynamically. But getcpu is a system call and I have no idea how to include that.

An alternative is to just give up and install rust-analyzer globally, but then I get file collisions between rust-src and rustlib that I don’t really want to resolve at the moment.

I don’t have any good suggestions, but for what it’s worth, I’ve also experienced weird segfaults in a builduserfhsenv. I also couldn’t get a good stack trace. I was never able to figure out the underlying problem. Although I was running the Haskell build tool stack.

I’ve also heard of other people experiencing weird segfaults, but I’ve never heard of anyone figuring out the reason.

I was able to figure it out here for an Electron app. In that case I had simply not known about a dynamic library that Electron needed (and which doesn’t get listed with ldd). I was hoping it was something similar here.

1 Like

At this point, I’ve run into the getcpu crash with a variety of applications, including vim, and in some setups with Electron as well.

Would desperately love help. Can share damn near any .nix file I have. I either need to be able to do development with rust-analyzer and vim inside of an fhsEnv (and have it work Every Single Day), or I need to break Electron (installed by npm) out of the fhsEnv. Either one will do.

1 Like

While I don’t have any good advice for you, I’m also interested in seeing this problem solved.

Since some Nix users don’t look at discourse.nixos.org, maybe you could create an issue about it on Nixpkgs? It might also be a good idea to create a post about it on one of the NixOS reddits.