tl;dr version
I added:
PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/x86_64-linux-gnu"
to ~/.profile
and saved the file, closed and re-opened Terminal and echo $PKG_CONFIG_PATH
gave me a blank line.
Details
I am very new to Linux and Ubuntu.
I am using Terminal to run cargo install cargo-embed
. I got an error:
Unable to find libudev:
pkg-config exited with status code 1
> PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags libudev
The system library libudev
required by crate hidapi
was not found.
The file libudev.pc
needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
The PKG_CONFIG_PATH environment variable is not set.
HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing libudev.pc
.
I have installed the library so I tried to set PKG_CONFIG_PATH.
First, I ran echo $PKG_CONFIG_PATH
to confirm and got a blank line.
Then I ran gedit ~/.profile
as suggested in an answer about setting environment variables permanently. At the end of the file, I added:
PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/x86_64-linux-gnu"
and saved the file. I then ran source ~/.profile
and re-ran echo $PKG_CONFIG_PATH
to confirm and got
/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/x86_64-linux-gnu
I then accidentally closed the terminal window and when I opened a new one and tried cargo install cargo-embed
I got the same error. I ran echo $PKG_CONFIG_PATH
again and got a blank line.
If I run source ~/.profile
it imports but when I close and re-open Terminal it's not there. I tried just adding echo "Test"
near the start of the .profile
file to see if it's running. I see it when I run source ~/.profile
but I don't see it when I open the Terminal. But then I don't know if I should see it. Like, I said, I'm very new to Ubuntu
Clarification
I have got past the cargo installation problem. I'd still like to know why this didn't work and how to add an environment variable permanently.
~/.bashrc
file instead ... based on your expectations – Raffa Jan 02 '24 at 16:09libudev-dev
development package from the Ubuntu repository then its .pc file should be in the default pc_path (which you can examine withpkg-config --variable pc_path pkg-config
) - it shouldn't be necessary to use thePKG_CONFIG_PATH
variable here at all. – steeldriver Jan 02 '24 at 16:27