How to install CLOC in RockyLInux 9?

How to install CLOC in RockyLInux 9?

https://cloc.sourceforge.net/

For Red Hat they recommend this:
sudo yum install cloc # Red Hat, Fedora

but it does not work in Rocky, neither does the dnf version

Thank you for the help you can provide

Their instructions are extremely vague and the links seem to be broken.

You would have to figure out how to download the cloc.rpm to a local directory. Then cd to that directory and run:

sudo dnf --nogpgchk install cloc

The problem is I couldn’t find an rpm poking around on their download site and that is the first hurdle.

cloc does exist in Fedora repositories. It doesn’t exist for RHEL or any other derivative like Alma/Rocky either when searched on pkgs.org.

The source rpms from Fedora can be downloaded here: Overview - rpms/cloc - src.fedoraproject.org they can then be used in conjunction with mock to build the rpm for you to then install on your system.

Thank you for your help !

I was looking at their latest website, and there the command to install in Fedora is shown:

sudo dnf install cloc # Fedora 22 or later

Do you know if any of the recommended commands would work in Rocky or only dnf ?

npm install -g cloc              # https://www.npmjs.com/package/cloc
sudo apt install cloc            # Debian, Ubuntu
sudo yum install cloc            # Red Hat, Fedora
sudo dnf install cloc            # Fedora 22 or later
sudo pacman -S cloc              # Arch
sudo emerge -av dev-util/cloc    # Gentoo https://packages.gentoo.org/packages/dev-util/cloc
sudo apk add cloc                # Alpine Linux
doas pkg_add cloc                # OpenBSD
sudo pkg install cloc            # FreeBSD

For yum/dnf commands to work, the package must be in a repository that is configured on the system. As I wrote, there isn’t a repository for it, so those commands do not work for RHEL/Rocky/Alma, etc. It does exist in Fedora. So since the source rpm is available you can build it with mock and then install the generated rpm.

As already mentioned by @jbkt23 their instructions are pretty lame since they say the commands below might work - they may as well have not bothered putting them - especially for RHEL since nobody packages their RPM and distributes via a configurable yum/dnf repository.

You could install npm/nodejs and use the npm command to install - it just depends if you prefer that way, or building it with mock and installing an rpm which can be easily removed without npm potentially pulling in and installing other dependencies. dnf will remove dependencies installed when a package is removed.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.