Questions about installing, removing packages

FreeBSD 14.0

I'm having a lot of trouble understanding installing and removing packages in FreeBSD

Problem 1:
I install a package (pkg install package_name) and several packages that are its dependencies are installed alongside it. Example 40 packages installed
So I will remove the package with the command: pkg delete package_name and this command removes 1 package. What do you mean if when I installed it it installed 40? Why don't you remove what he installed?

Question: What is the correct way to install and remove packages without leaving my system cluttered with installation garbage? Do I really have to remove 1 by 1 of the 40 packages or more that an installation did?

Problem 2: I understood that the pkg clean command would remove packages from my /var/cache/pkg folder that are not installed and in use on my system. But that didn't happen, he removed, for example, 7-zip-23.01~f6b3129741.pkg, which is installed on my current system and in use, and obviously countless others that are in use on my system! Like this?

I wish someone could guide me where I'm doing it wrong! Because as it is, it's a huge mess. Do I really need to remove one by one a program that installed 200 packages? And having to look in a folder that has 2,200 packages, one by one, which are installed on my PC, to remove them?

Thanks to anyone who can help!
 
So I will remove the package with the command: pkg delete package_name and this command removes 1 package. What do you mean if when I installed it it installed 40? Why don't you remove what he installed?
Because you might have started using things provided by these packages. It is safer to not uninstall them.

As victort already said: If you want to uninstall packages that were installed solely to satisfy dependencies of other packages, pkg autoremove will do that for you. If you read the man pages for pkg, you can even see that you can move packages from "automatically installed for dependencies" to "installed because I want them". Personally, I would probably look at the packages and quickly check whether I want to keep them or not.

I understood that the pkg clean command would remove packages from my /var/cache/pkg folder that are not installed and in use on my system.
Read the documentation. The man page clearly explains that pkg clean (without any potions) deletes the package files only for packages that are no longer in use because they have been replaced by newer versions. It also describes the "-a" option, which will remove all package files.

I wish someone could guide me where I'm doing it wrong!
You are not reading the man pages carefully enough.
 
Read the documentation. The man page clearly explains that pkg clean (without any potions) deletes the package files only for packages that are no longer in use because they have been replaced by newer versions. It also describes the "-a" option, which will remove all package files.
As I stated in the question: The 7-zip package is installed on the system. And it was removed from the /var/cache/pkg folder by the pkg clean command. And not just him, but several others that are on the system and are no longer in the folder /var/cache/pkg Which leaves me without understanding why!

And what I understood from the pkg clean command is that it would only remove packages from the /var/cache/pkg folder that are not installed, that are not in use on the system! Example: If the 7-zip-23.01~f6b3129741.pkg package is installed and in use, it should remain in the /var/cache/pkg folder. But it is removed! And as I said, not just him!

Package 7-zip-23.01~f6b3129741.pkg was installed by ark that is installed on the system.
Does pkg clean remove dependencies in use from the /var/cache/pkg folder, leaving only the main programs? Since in practice 7-zip-23.01~f6b3129741.pkg was as installed as an ark dependency?

No other version of 7-zip is the same since installation!
 
Are there any packages left in /var/cache/pkg? I ask because there have been bugs with pkg-clean(8) in the past that would do an implied -a and just remove everything.
 
Visually below what I'm talking about! All this in the image, where I run pkg clean! These are not old packages, they are the current packages!

And as I said, there are many others that are installed and in use that are being removed!
There are not a few, but 3GB of packages, many of which are in use and installed on the system!
Look below: xorg I'm using. xfce is my only window manager there is no other!
/var/cache/pkg/xfce-4.18_1.pkg
/var/cache/pkg/xfce-4.18_1~4fb9462636.pkg
/var/cache/pkg/xorg-7.7_3.pkg
/var/cache/pkg/xorg-7.7_3~b3f62458f3.pkg
# pkg install ark
7-zip: 23.01
ark: 23.08.4
libsysinfo: 0.0.3_2
rar: 6.24,3
unrar: 6.24,6

# pkg info 7-zip
7-zip-23.01
Name : 7-zip
Version : 23.01
Installed on : Fri Mar 22 10:19:45 2024 -03
Origin : archivers/7-zip
Architecture : FreeBSD:14:amd64
Prefix : /usr/local
Categories : archivers
Licenses : UNRAR and LGPL21+ and BSD3CLAUSE
Maintainer : makc@FreeBSD.org
WWW : https://www.7-zip.org/
Comment : Console version of the 7-Zip file archiver
Options :
DOCS : on
Shared Libs required:
libsysinfo.so.0
Annotations :
FreeBSD_version: 1400097
build_timestamp: 2024-02-16T11:30:59+0000
built_by : poudriere-git-3.4.1
cpe : cpe:2.3:a:7-zip:7-zip:23.01:::::freebsd14:x64
port_checkout_unclean: no
port_git_hash : 756e18783
ports_top_checkout_unclean: no
ports_top_git_hash: b3e528239
repo_type : binary
repository : FreeBSD
Flat size : 2.43MiB
Description :
7-Zip is a file archiver with a high compression ratio in 7z format with LZMA
and LZMA2 compression. Supported formats:

* Packing / unpacking: 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM
* Unpacking only: AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS,
IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF,
UEFI, VDI, VHD, VMDK, WIM, XAR and Z

2.png
 
Are there any packages left in /var/cache/pkg? I ask because there have been bugs with pkg-clean(8) in the past that would do an implied -a and just remove everything.

It's not removing the entire folder, it's removing a little less than half of the folder! The folder today has 3581 files, of which a maximum of 300 that should be removed were uninstalled. The rest is installed! I tested the command by making a copy of the folder in case it went wrong.
 
And while we are asking questions: Did you use "-a" with pkg clean?

By the way, in my humble opinion, storing the package files in /var/cache/pkg is pointless in a modern environment. Most people have network connectivity all the time, and good bandwidth. Just delete the packages from the cache, and if you need them again, "pkg install" will re-fetch them.
 
it's removing a little less than half of the folder!
Ok, that's odd. Could be a bug somewhere, perhaps pkg-clean(8) is sometimes taking the wrong conclusion. That said, don't fret about it too much, these are cached packages, it has nothing to do with your installed or deleted packages (problem #1), the files in /var/cache/pkg could all be removed and everything will continue to work just fine. It just means a pkg-install(8) will download them again.
 
And while we are asking questions: Did you use "-a" with pkg clean?
Did you look at the terminal image? There is no -a
By the way, in my humble opinion, storing the package files in /var/cache/pkg is pointless in a modern environment. Most people have network connectivity all the time, and good bandwidth. Just delete the packages from the cache, and if you need them again, "pkg install" will re-fetch them.
As for what you say, that's completely relative!
A person who has a normal life in the USA does not have problems with the Internet.

Anyone who lives in Brazil and uses a cellular connection where the operator only provides 12GB to use throughout the month at a speed of 500k or 1MB, is not that lucky!
Anyone who earns US$ 250.00 a month cannot pay US$ 30.00 for Internet, and that is 85% of the Brazilian population. This person needs to eat, pay rent, buy medicine, etc...
Apart from places that don't have Internet.
In practice, there are many reasons to often access offline!

Just clarifying!
 
You may be surprised to hear that I'm quite familiar with the situation in Brasil. And yes, cell phone coverage there is expensive, but even in a rural environment, I found it to be remarkably fast and reliable. Even in a small farming village in MS, an hour by car away from Campo Grande. I have no idea what the situation is in Rio or SP.

But your statement is correct: If internet connection is expensive or spotty, and you expect to delete and then re-install the same package, then the cache is important.

By the way, after reading your post last night, I got reminded that I have to clean up my cache, and I first did "pkg clean" (removed some stuff, but left lots), and then "pkg clean -a" (removed everything else). On one of my machines, I pay for disk space, but not for network, so caching things that can be downloaded again is silly for me. YMMV.
 
Ok, that's odd. Could be a bug somewhere, perhaps pkg-clean(8) is sometimes taking the wrong conclusion. That said, don't fret about it too much, these are cached packages, it has nothing to do with your installed or deleted packages (problem #1), the files in /var/db/cache could all be removed and everything will continue to work just fine. It just means a pkg-install(8) will download them again

I don't have this folder var/db/cache
I have this: /var/db/pkg
FreeBSD 14.0

My goal for solving this is that I don't have to manually delete 1 by 1 unnecessary files from /var/cache/pkg
And yes, one of the reasons is to keep the packages in use, for later installation when necessary without spending 9Gb of internet bandwidth for this.

Because without a solution where the system works, I will have to manually save the packages to a separate folder for each installation.
 
If there is a BUG in pkg clean, wouldn't it be correct to report it so that it can be fixed in future versions?
 
Is there an alias defined for pkg clean anywhere?
I'm asking because I have not hit a "pkg clean" doing "pkg clean -a" before
 
I'm asking because I have not hit a "pkg clean" doing "pkg clean -a" before
It happened a while back. A pkg clean would just delete everything. There's even a thread on the forums about it.
 
  • Like
Reactions: mer
Oh, definitely. I was just trying to assure you it won't 'damage' your system, it's only an inconvenience if there is a bug in pkg-clean(8).

So far FreeBSD has not damaged my system! I installed several packages to test them, about 3 generated conflicts like git where I already had git-tiny, and a development package that updated things that I needed to remove.

In the end, I updated, upgraded, checked dependencies and autoremove, and the entire system was stable and automatically corrected, it didn't collapse!
What I considered positive about FreeBSD, and look, I watched these upgrades leave the screen unreadable with the letters all in squares, until everything was restored.

But what I learned from this is that I can't have packages installed on the system! My use requires packages installed in portable folders with all their dependencies and home and other configuration folders operating independently.

This way, these programs will NEVER be updated and will always work the way they were installed.

Because I didn't like shared libraries, forcing me to update a program when I don't want to, since unfortunately many updates are not welcome, they don't help, and are more disruptive than they should be. I cite as an example what they did to Konqueror over the last 7 years, they destroyed it!
 
Source code is in GitHub. Seeking clean finds a few issues.

I'm a very frequent user of pkg clean commands, albeit nearly always with option -a. I don't imagine a bug arising with normal use of the command.
 

Attachments

  • 1715626915959.png
    1715626915959.png
    19.5 KB · Views: 304
Source code is in GitHub. Seeking clean finds a few issues.

I'm a very frequent user of pkg clean commands, albeit nearly always with option -a. I don't imagine a bug arising with normal use of the command.
The -a option removes everything. It works! I've already tested this. What doesn't work is not using -a. Because it doesn't do what it promises to do!
 
My use requires packages installed in portable folders with all their dependencies and home and other configuration folders operating independently.

A distro such as helloSystem might suit you, however the isolation there was somewhat problematic, last time I checked. Any such problem should please be discussed in a helloSystem area.
 
A distro such as helloSystem might suit you, however the isolation there was somewhat problematic, last time I checked. Any such problem should please be discussed in a helloSystem area.
Thanks for the recommendation, I like getting to know different systems, although at the moment I'm still studying everything about FreeBSD Original!
 
Back
Top