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

Rustc: error while loading shared libraries: librustc_driver--4e7c5e5c.so #24677

Closed
ghost opened this issue Apr 22, 2015 · 18 comments
Closed

Rustc: error while loading shared libraries: librustc_driver--4e7c5e5c.so #24677

ghost opened this issue Apr 22, 2015 · 18 comments

Comments

@ghost
Copy link

ghost commented Apr 22, 2015

When I run a cargo build command, I get the following errors:

Process didn't exit successfully: rustc -vV (exit code: 127)
--- stderr
rustc: error while loading shared libraries: librustc_driver-4e7c5e5c.so: cannot open shared object file: No such file or directory

My computer is running the latest version of arch linux, and I installed rust using the curl command: curl -sf -L https://static.rust-lang.org/rustup.sh | sudo sh

I don't think the issue is with my code, but you can look in my repositories for my simple hello_world program here: https://github.com/a-jamesregan/LearnRust

@cipherself
Copy link
Contributor

I have the same problem running latest version of arch linux, running rustc generates the same error (without running cargo).

@zaeleus
Copy link
Contributor

zaeleus commented Apr 22, 2015

Add /usr/local/lib to your LD_LIBRARY_PATH (or include it in your /etc/ld.so.conf so ldconfig searches it when run).

This doesn't happen just on Arch. Most non-Debian systems don't trust anything outside /lib and /usr/lib by default. Because rustup installs to /usr/local, ldconfig doesn't see the newly installed libraries.

@cipherself
Copy link
Contributor

Ah, I see. You're correct @zaeleus.

For anyone else who faces this problem:
1- Edit the file /etc/ld.so.conf and add /usr/local/lib to it, you will need sudo rights to be able to write changes to the file.
2- Run sudo ldconfig to update the ldconfig cache.
3- Profit!

@steveklabnik
Copy link
Member

/cc @brson , in theory, we made rustup.sh run ldconfig to fix this.

@ghost
Copy link
Author

ghost commented Apr 23, 2015

Thanks @skeuomorf, what you suggested worked. It's worth nothing that when you say to add /usr/local/lib to the file, you should do this literally. I got confused because the file by default contains a single line starting with include /etc/ld.so.conf.d/*.conf. If you place an include before /usr/local/lib the fix doesn't work.

@steveklabnik, should I mark this issue as closed now? Or is this going to be used to track the issue in the rustup.sh script?

@chessnokov
Copy link

just run:
sudo ldconfig /usr/local/lib

@yantonov
Copy link

Same problem if you install rust into specifi dir (./configure --prefix=$INSTALL_DIR && make && make install)
In that case you need to manually add file, for example rustlib.conf at /etc/ld.so.conf.d/ which contains one line $INSTALL_DIR.
You can do this way:
sudo echo $INSTALL_DIR >> /etc/ld.so.conf.d/rustlib.conf
Than reconfigure ldconfig by call
sudo ldconfig

@andyleejordan
Copy link

Reporting that the latest version of the installer fails to add the path properly on CentOS 7.

@ghost
Copy link
Author

ghost commented Jun 17, 2015

Ha ha ha! I just had this problem again on a different distro (fedora instead of ubuntu, or was it arch?) and when I searched for the issue again, my own bug report came up! I just wanted to point out that this issue exists for Fedora too.

@PAStheLoD
Copy link

If editing anything in /etc/ is not really an option (or someone prefers not to), using a script to launch cargo (and I assume this works for other executables in bin/) works pretty well:

~/bin/cargo:

#!/bin/bash
PREFIX=/home/john/rust
export LD_LIBRARY_PATH=$PREFIX/lib
exec $PREFIX/bin/cargo "$@"

Maybe rustup could emit minimal shims/wrappers like these, kind of how other version managers do it. (rvm, pyenv, nvm)

@cyplo
Copy link
Contributor

cyplo commented Aug 1, 2015

Seems that this is the same issue as: #26860
Comment there references rust-lang/rust-installer#30 as the main culript. It has a patch already, so probably will be fixed soon , for Fedora at least. @a-jamesregan: could you maybe add info that it did not work on Arch for you there (if it still doesn't?) ? :)

@ghost
Copy link
Author

ghost commented Aug 4, 2015

@cyplo Sorry, I can't check to see if it works in Arch. As much fun - and by that I mean a headache - as it was setting up Arch, I'm now running Ubuntu. Rust seems to be working fine on 15.10 though!

@cyplo
Copy link
Contributor

cyplo commented Aug 4, 2015

No worries, thanks a lot for checking :) Running ok on my ubuntu machine as well, fedora one having problems though. thanks again !

@Gabriel-Alves-Cunha
Copy link

Fedora still having problem with it.

@divaisthewonder
Copy link

hi All - thanks for the posting. while i building the latest firefox, i am getting the same error. i did everything as suggested.

[root@USTNCOL-BHU01-RHELDMZHUB01 bin]# /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc: error while loading shared libraries: librustc_driver-eaf580548f9ab3b9.so: cannot open shared object file: Operation not permitted
[root@USTNCOL-BHU01-RHELDMZHUB01 bin]#

@P1119r1m
Copy link

P1119r1m commented Feb 16, 2024

It looks like Rust build system is immature.
If I run "./x.py build" and "./x.py install" into some non-system folder I will get and error running rustc:

.../Git/install/bin# ./rustc 
./rustc: error while loading shared libraries: librustc_driver-12c173733915d579.so: cannot open shared object file: No such file or directory

Yes, we can fix this problem using LD_LIBRARY_PATH-related workaround.
But this looks completely immature.

UPD. It is possible to resolve mentioned problem if to set (in config.toml file):

rpath = true

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

15 participants