testsAndMisc/linux_configuration/fixes/fix_yay_aur_database.sh
Krzysztof kuhy Rudnicki 4f2b0ccdf7 Dissolve linux_configuration/scripts/ and single_use/
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.

Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.

The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:

  - 52 relative `source` lines for lib/common.sh and lib/android.sh. The
    correct prefix differs per file: 40 were ../../ and 12 were ../../../,
    so a blanket replace would have fixed one set and broken the other.
  - REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
    each walking up four levels from a directory now two levels shallower.
    This caused a real regression -- the fixes suite went red with
    "log_warn: command not found" -- caught by running it and comparing
    against the pre-move baseline worktree.
  - conftest.py's sys.path entries, which took the pytest gate down with
    14 collection errors, and the `# shellcheck source=` directives, which
    took shellcheck down with SC1091.

16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.

Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
2026-08-23 18:53:30 +02:00

78 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Fix for "database AUR not found" error in yay
# This error occurs when yay's AUR database cache becomes corrupted
# or when using a buggy yay-git version
set -euo pipefail
echo "=== Fixing yay AUR database ==="
# Check if using yay-git (development version with potential bugs)
if pacman -Qi yay-git &> /dev/null; then
echo ""
echo "Detected yay-git (development version)."
echo "The 'database AUR not found' error is a known bug in some yay-git versions."
echo ""
read -rp "Switch to stable yay? [Y/n] " response
if [[ ${response,,} != "n" ]]; then
echo "Switching to stable yay..."
# Build and install stable yay from AUR
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
git clone https://aur.archlinux.org/yay.git
cd yay
# Remove yay-git and yay-git-debug (they conflict)
sudo pacman -Rdd yay-git --noconfirm
sudo pacman -Rdd yay-git-debug --noconfirm 2> /dev/null || true
# Build and install stable yay
makepkg -si --noconfirm
cd /
rm -rf "$TEMP_DIR"
echo ""
echo "=== Switched to stable yay ==="
echo "You can now retry your yay command."
exit 0
fi
fi
# Remove yay's cache directory
YAY_CACHE_DIR="${HOME}/.cache/yay"
if [[ -d $YAY_CACHE_DIR ]]; then
echo "Removing yay cache directory: $YAY_CACHE_DIR"
rm -rf "$YAY_CACHE_DIR"
fi
# Remove yay's local database directory (stores AUR package info)
YAY_DB_DIR="${HOME}/.local/share/yay"
if [[ -d $YAY_DB_DIR ]]; then
echo "Removing yay database directory: $YAY_DB_DIR"
rm -rf "$YAY_DB_DIR"
fi
# Remove yay state directory
YAY_STATE_DIR="${HOME}/.local/state/yay"
if [[ -d $YAY_STATE_DIR ]]; then
echo "Removing yay state directory: $YAY_STATE_DIR"
rm -rf "$YAY_STATE_DIR"
fi
# Clear pacman's sync databases and refresh
echo "Refreshing pacman databases..."
sudo pacman -Sy
# Generate new yay database by running a simple query
echo "Regenerating yay AUR database..."
yay -Sy
echo ""
echo "=== Fix complete ==="
echo "You can now retry your yay command."
echo ""
echo "If the issue persists and you're using yay-git, consider running this script"
echo "again and choosing to switch to the stable yay version."