Skip to content

Commit dde4008

Browse files
authored
Update app-vscode.sh
I was getting this error: wget -qO- https://omakub.org/install | bash ________ __ ___. \_____ \ _____ _____ | | ____ _\_ |__ / | \ / \__ \ | |/ / | \ __ \ / | \ Y Y \/ __ \| <| | / \_\ \ \_______ /__|_| (____ /__|_ \____/|___ / \/ \/ \/ \/ \/ => Omakub is for fresh Ubuntu 24.04+ installations only! Begin installation (or abort with ctrl+c)... E: Conflicting values set for option Signed-By regarding source https://packages.microsoft.com/repos/code/ stable: /etc/apt/keyrings/packages.microsoft.gpg != /usr/share/keyrings/microsoft.gpg E: The list of sources could not be read. The Problem I Faced When I first tried to run the installation, I immediately ran into a persistent error from your system's package manager, apt. The core of the problem was a conflict in your software sources. The repository for Microsoft VS Code was defined in more than one place, and these definitions were secured with two different, conflicting GPG keys. This created a deadlock; apt would refuse to do anything until the conflict was resolved, which in turn caused the installation script to fail right at the start. My initial attempts to fix this weren't working because I was placing the cleanup logic in scripts that were being called too late in the process. The error was happening before my fixes could even run. The Change I Made After realizing the timing was the issue, I corrected my approach. I pinpointed the exact script that was triggering the error: install/desktop/app-vscode.sh. I then modified this file to perform a comprehensive cleanup at the very beginning, before it could do anything else. The logic I added to the start of that script now does the following: 1. It actively searches for and removes any apt source file on your system that mentions the conflicting Microsoft repository. 2. It explicitly removes both of the GPG keys that were causing the conflict. 3. Finally, it runs sudo apt-get update to confirm that the fix was successful. By placing this robust cleanup process in the correct script, I ensured that the conflict is resolved at the precise moment necessary, allowing the installation to proceed on a clean and stable foundation.
1 parent a837b00 commit dde4008

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

install/desktop/app-vscode.sh

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,59 @@
11
#!/bin/bash
22

3+
# Temporarily disable exit on error to run a robust cleanup process.
4+
set +e
5+
6+
echo "--- Running VS Code Pre-installation Cleanup ---"
7+
8+
# Find and remove ANY apt source file mentioning the conflicting repository.
9+
CONFLICTING_FILES=$(grep -lr "packages.microsoft.com/repos/code" /etc/apt/sources.list.d/ /etc/apt/sources.list 2>/dev/null)
10+
if [ -n "$CONFLICTING_FILES" ]; then
11+
echo "Found conflicting repository files. Removing them..."
12+
echo "$CONFLICTING_FILES" | sudo xargs -r rm -f
13+
echo "Removed: $CONFLICTING_FILES"
14+
fi
15+
16+
# Remove both potential GPG keys if they exist.
17+
if [ -f "/usr/share/keyrings/microsoft.gpg" ]; then
18+
echo "Removing old GPG key..."
19+
sudo rm -f /usr/share/keyrings/microsoft.gpg
20+
fi
21+
if [ -f "/etc/apt/keyrings/packages.microsoft.gpg" ]; then
22+
echo "Removing new GPG key..."
23+
sudo rm -f /etc/apt/keyrings/packages.microsoft.gpg
24+
fi
25+
26+
# Refresh apt lists and check if the conflict is resolved.
27+
echo "Refreshing package lists to verify the fix..."
28+
sudo apt-get update -y
29+
APT_EXIT_CODE=$?
30+
31+
# Re-enable exit on error for the rest of the script.
32+
set -e
33+
34+
if [ $APT_EXIT_CODE -ne 0 ]; then
35+
echo "--------------------------------------------------------------------"
36+
echo "FATAL: APT conflict could not be resolved automatically."
37+
echo "The installation of VS Code cannot proceed."
38+
echo "--------------------------------------------------------------------"
39+
exit 1
40+
fi
41+
42+
echo "--- Cleanup Successful. Proceeding with VS Code installation. ---"
43+
44+
# Now, proceed with a clean installation of the VS Code repository.
345
cd /tmp
4-
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >packages.microsoft.gpg
46+
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
547
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
6-
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null
48+
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
749
rm -f packages.microsoft.gpg
850
cd -
951

10-
sudo apt update -y
11-
sudo apt install -y code
52+
# Update package list again and install VS Code
53+
sudo apt-get update -y
54+
sudo apt-get install -y code
1255

56+
# Configure VS Code
1357
mkdir -p ~/.config/Code/User
1458
cp ~/.local/share/omakub/configs/vscode.json ~/.config/Code/User/settings.json
1559

0 commit comments

Comments
 (0)