intellij-rust / intellij-rust

Rust plugin for the IntelliJ Platform
https://intellij-rust.github.io
MIT License
4.53k stars 380 forks source link

Bundled debugger cannot find Rust std libraries #1100

Open lilianmoraru opened 7 years ago

lilianmoraru commented 7 years ago

I tried to run the debugger(tried with the one bundled 7.11.1 and with gdb 7.12.1 - since it is Rust friendly since 7.12) on RLS and it fails because it cannot find Rust std libraries:

/home/lilian/Git/rls/target/debug/rls: error while loading shared libraries: librustc_driver-0f4024af7b82b2df.so: cannot open shared object file: No such file or directory

I want to note that running gdb rls gives the same result(tried after I started opening this issue). So, it's just a setup issue. I tried setting set solib-search-path and it still didn't work for some reason. I used this little script to obtain the command:

unset search_paths
toolchain="$(rustup toolchain list | grep default | cut -d " " -f 1 | cut -d "-" -f 2-)"
for folder in $(find $(rustc --print sysroot) -type d -name "lib"); do
    path_="$(echo ${folder:?} | grep "${toolchain:?}/lib$")"
    test -n "${path_}" && search_paths="${path_}:${search_paths}"
done

echo "set solib-search-path .:${search_paths}"
lilianmoraru commented 7 years ago

set sysroot on rustc --print sysroot didn't work either...

lilianmoraru commented 7 years ago

My mistake. These are for debugging...

I did:

set env LD_LIBRARY_PATH [the same paths from the script]

and it worked(in the terminal but not in CLion)

lilianmoraru commented 7 years ago

I temporarily put set env LD_LIBRARY_PATH [the same paths from the script] inside .gdbinit and it now works from CLion. I could not find where I can configure the debugger from CLion...

matklad commented 7 years ago

I have not checked this, but my theory is that Cargo passes custom LD_LIBRARY_PATH when you do cargo run which we can't get hold of yet. This should be fixed by https://github.com/rust-lang/cargo/pull/3866 which will cause Cargo to print LD_LIBRARY_PATH.