Installing diesel_cli

I am using opensuse as my operating system. When i try to install the diesel_cli i get this error.

note: /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: cannot find -lmysqlclient
collect2: error: ld returned 1 exit status

Check the guide
You can find a section about this error.

1 Like

I used this command ```
cargo install diesel_cli --no-default-features --features mysql

And still get the error.

From the link provided by @nickelc:

This means you are missing the client library needed for a database backend – mysqlclient in this case. You can resolve this issue by either installing the library (using the usual way to do this depending on your operating system) or by specifying the backends you want to install the CLI tool with.

It says that ld cannot find MySQL client libraries needed for the diesel client.

And now you are saying that you want MySQL support, so this is not the solution for you. You need to install MySQL development libraries using zypper (I guess, I have never used SUSE).

I did a quick check in an OpenSuse docker container and this might help:

7275f0ec779d:/ # zypper search mysql | grep -- '-devel'
  | libmysqlclient-devel                 | MariaDB development header files and libraries                        | package
  | libmysqlcppconn-devel                | Development files for MySQL Connector/C++                             | package
  | libmysqld-devel                      | MariaDB embedded server development files                             | package
7275f0ec779d:/ # zypper install libmysqlclient-devel
1 Like

Thank you vary much for the help. Using this command worked.
zypper install libmysqlclient-devel

I'm a little rusty with opensuse. It has been awhile since I have used it. I was using windows to do my development for awhile then recently I switched to opensuse. It suits my development needs better than windows does.

I ran that command and it also installed some other required things with it. Then I ran cargo install diesel_cli --no-default-features --features mysql.

It appears it worked it just shows a warning now.
warning: be sure to add /home/Jared.Fulk/.cargo/bin to your PATH to be able to run the installed binaries

I'm working on a web app. And two parts of it I'm just going to write a cli for it. One part is the blog and the other part is for voting.

Thanks again appreciate it.

This one says that if you want to use the diesel executable in a shell like this:

$ diesel <some command and arguments ...>

you need to add the /home/Jared.Fulk/.cargo/bin directory into the $PATH variable so that the shell knows where to find the executable file. For example I have this line in my ~/.profile:

export PATH="$HOME/.cargo/bin:$PATH"

Note: I assume you are using Bash as your default shell. This is not going to work if you use some more exotic shell, e.g. fish.

1 Like

Thanks again. It now works when i run diesel setup. :slight_smile: