2

apt-get gives the following warning when some of the commands below are run by a GitHub Action on an Ubuntu-lastest GitHub runner:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

What else should be used instead of apt-get to do the same things that the following commands do on the Ubuntu-latest GitHub runner?

    sudo apt install -y dos2unix
    sudo apt update && sudo apt upgrade
    sudo apt clean

We originally just ignored the warning message above. But last night a lot of our jobs on those Ubuntu-latest runners returned wonky results, and some of the broken jobs had the apt-get warning shown above. We do not currently have last night's wonky logs to post here. But we want to prevent unpredictable intermittent wonky behavior.

Is there a better alternative to apt-get to use for scripts?

1
  • 2
    Uh do you mean apt-get per your text or apt per your examples? You seem to be confusing them Commented Jan 10, 2023 at 20:57

1 Answer 1

1

You should use apt-get instead of apt:

sudo apt-get install -y dos2unix
sudo apt-get update && sudo apt upgrade
sudo apt-get clean

This is explained in the apt man page:

The apt(8) commandline is designed as an end-user tool and it may change behavior between versions. While it tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for interactive use.

All features of apt(8) are available in dedicated APT tools like apt-get(8) and apt-cache(8) as well. apt(8) just changes the default value of some options (see apt.conf(5) and specifically the Binary scope). So you should prefer using these commands (potentially with some additional options enabled) in your scripts as they keep backward compatibility as much as possible.

3
  • Why in particular? Commented Jan 10, 2023 at 20:28
  • See the update. Commented Jan 10, 2023 at 21:44
  • I agree with this advice. I've been seeing a lot of instructions the past year or two giving apt commands instead of apt-get ones, and wondered if apt-get were being deprecated. Commented Jan 11, 2023 at 0:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.