手动删除Qt目录后qmake无法读取配置文件的求助
Let's break down what's happening here and work through the fix step by step:
Why the Double Slash?
That odd // in the path comes from a misconfiguration in qtchooser—chances are one of its config files has a path ending with a trailing slash. When qtchooser tries to stitch paths together, that extra slash combines with the next segment to create the double slash issue. Even though your default.conf exists in the correct (no-double-slash) path, qmake is pulling the broken path from qtchooser's settings.
Step 1: Find the Problematic Config File
Qtchooser uses two common config locations—check both:
- System-wide config:
/etc/xdg/qtchooser/default.conf - User-specific config:
~/.config/qtchooser/default.conf
Run this command to inspect both files at once:
cat /etc/xdg/qtchooser/default.conf ~/.config/qtchooser/default.conf 2>/dev/null
Look for lines that end with a slash (like /usr/lib/x86_64-linux-gnu/qt5/ instead of /usr/lib/x86_64-linux-gnu/qt5). That trailing slash is the culprit behind the double slash.
Step 2: Fix the Config File
Open the problematic file with a text editor (use sudo for the system-wide one):
sudo nano /etc/xdg/qtchooser/default.conf # Or for user-specific: nano ~/.config/qtchooser/default.conf
Remove any trailing slashes from the paths inside. For example, change:
/usr/lib/x86_64-linux-gnu/qt5/ /usr/lib/x86_64-linux-gnu/qt5/bin/
To:
/usr/lib/x86_64-linux-gnu/qt5 /usr/lib/x86_64-linux-gnu/qt5/bin
Save the file (Ctrl+O in nano) and exit (Ctrl+X).
Step 3: Alternative: Reconfigure Qt via update-alternatives
If fixing the config file doesn't resolve things, you can reset the default Qt version using update-alternatives:
- List available qmake versions:
update-alternatives --list qmake - Set the correct Qt 5 version as default:
sudo update-alternatives --config qmake
Follow the on-screen prompt to select your installed Qt 5 version.
Step 4: Verify the Fix
Run the command again to confirm it works:
qmake --version
It should now correctly locate the config file and display your Qt version without errors.
内容的提问来源于stack exchange,提问作者nilsiism

