Back to course

Advanced Package Operations: pkg upgrade and dependencies

Termux Masterclass: From Zero to Linux Power User on Android

24. Advanced Package Operations: pkg upgrade and Dependencies

While pkg update && pkg upgrade covers most scenarios, understanding dependency resolution and cleaning up unused packages is key to maintaining a healthy Termux environment.

1. Dependency Management

When you install a package (e.g., Python), pkg automatically installs all required supporting packages (dependencies).

  • When you uninstall Python, those dependencies might remain if other installed programs are using them.

2. Removing Unused Dependencies (pkg autoremove)

This command removes packages that were installed as dependencies but are no longer needed by any installed software.

bash $ pkg autoremove

Running autoremove regularly helps free up storage space.

3. Resolving Conflicts During Upgrade

Sometimes, pkg upgrade might hit a conflict or a broken package installation. You can try to fix it using apt directly (since pkg wraps apt).

bash

Attempts to fix broken dependencies or incomplete installations

$ apt --fix-broken install

Forces removal if a package is completely stuck

WARNING: Use with caution!

$ dpkg --remove --force-all [package_name]

Note: If you encounter persistent issues, especially related to the repository list, you might need to manually edit /etc/apt/sources.list (advanced users only), or simply run pkg update to try fetching fresh lists.