A recent update saw Flutter compiles on Ubuntu broken due to an issue with lld. This was only on Flutter installed under snap. To fix it, I removed Flutter and reinstalled it from Git. There were a few issues after that so I’ve documented them here. This is the process.
First remove Flutter
sudo snap remove flutter
Then install it manually
cd ~
git clone https://github.com/flutter/flutter.git -b stable
Now modify .bashrc (I prefer gedit but nano will do)
nano ~/.bashrc
Add this line at the end:
export PATH="$PATH:$HOME/flutter/bin"
Save it then do
source ~/.bashrc
Test the installation
flutter doctor
There may be some missing bits but this should fix them
sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev
and repeat flutter doctor until things are ok.
Now I still had some issues
Flutter doctor told me I had a different Dart installed.
So first remove the old one
sudo snap remove dart
Check with
which dart
My configuration still had the wrong dart in it. I searched these
cat /etc/environment cat ~/.profile cat ~/.bash_profile cat /etc/bash.bashrc grep -r "dart" ~/.bashrc ~/.bash_profile ~/.profile /etc/environment /etc/bash.bashrc 2
then did
echo $PATH
Which showed no dart references so
ls -la /usr/bin/dart which dart sudo apt remove dart which dart dart --version flutter doctor
I then found that it was trying to use a snap version of cmake
cd your_project flutter clean rm -rf build/ rm -rf linux/build/
and removed Cmake cache files
rm -rf linux/flutter/ephemeral/ rm linux/CMakeCache.txt 2>/dev/null
Finally I regenerated the build configuration
flutter pub get flutter config --enable-linux-desktop flutter create
and all was well and after adding the correct SDK path into the project files, it finally compiled on Linux again. Phew!