Apologies, I should have added more specific detail.
The installation is self-managed (version 8.5.3). It is a small instance in our QA environment. Elastic/Kibana/Fleet agent server is installed on a Linux machine (Centos 7) and the agent was installed on separate Linux machine (also Centos 7). There are other agents installed on other machines (also Centos) and these installed without error. Only on the machine which previously had an older version of Fleet agent (7.15.2) is there a problem.
Older agent was installed as a Fleet Managed Agent. This was when we were running Elastic-Kibana version 7.15.2. This would have been installed as follows:
curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-7.15.2-linux-x86_64.tar.gz
tar xzvf elastic-agent-7.15.2-linux-x86_64.tar.gz
sudo ./elastic-agent install -f --url=http://<agent hostname>:8220 --enrollment-token=<token>== --insecure
We then upgraded the stack to 8.5.3. After the upgrade, we attempted to update the agent via Kibana and as I mentioned above that didn't work.
To uninstall agent, ran the following:
sudo ./elastic-agent uninstall
Downloaded the new agent tar ball, extracted, added new agent via Kibana and ran the following:
sudo ./elastic-agent install --url=http://<agent hostname>:8220 --enrollment-token=<token>== --insecure
This threw the error:
Installed as a system package, installation will not be altered.
Error: failed to execute enroll command: fork/exec /usr/bin/elastic-agent: no such file or directory
Searching the file system, I noticed there were still remnants of previous installation, so I removed all that:
sudo rm -rf /usr/share/elastic-agent/
sudo rm /usr/bin/elastic-agent*
sudo rm /usr/lib/systemd/system/elastic-agent.service
sudo rm /etc/rc.d/init.d/elastic-agent
sudo rm -r /etc/elastic-agent
sudo rm -r /var/lib/elastic-agent
Maybe the uninstall wasn't successful. But I would have thought that removing the above would clear the installation.