13

A script requires a ruby version greater than or equal to 1.9. How do I translate that to apt command? Tried below, does not work:

 % sudo apt-get install "ruby ( >= 1.9.1 )"
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ruby ( >


 % sudo apt-get install "ruby>=1.9.1"      
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ruby>

2 Answers 2

11

apt does not support specifying version ranges to install a package. You can only either specify the exact version you want it to take, or you omit the version to let it decide automatically.

To find out what versions of a package are available for you, the output of

apt policy PACKAGENAME

will be helpful, e.g. for ruby on 16.04:

ruby:
  Installed: (none)
  Candidate: 1:2.3.0+1
  Version table:
     1:2.3.0+1 500
        500 http://ftp.uni-stuttgart.de/ubuntu xenial/main amd64 Packages
        500 http://ftp.uni-stuttgart.de/ubuntu xenial/main i386 Packages

The version above corresponds to Ruby 2.3 btw.

So in this example, you could install either ruby to let the system automatically pick the only available version, or you could specify it explicitly as ruby=1:2.3.0+1.

The command to install the desired package will be one of

sudo apt install PACKAGENAME
sudo apt install PACKAGENAME=VERSION
3
  • What about dpkg/aptitude or other tools that can be used to install a package in ubuntu?
    – balki
    May 18, 2017 at 23:39
  • 1
    No, aptitude doesn't offer such an option either. dpkg on the other hand is just a tool to install an already downloaded .deb package file. It does not fetch the package for you, like apt or aptitude do, so you can not specify any version at all, because the version is determined by what you manually downloaded yourself.
    – Byte Commander
    May 19, 2017 at 8:47
  • Aptitude can be use to forbid a specific version. aptitude forbid-version vim=1.2.3.broken-4; however, this only works if using aptitude for upgrades, it doesn't get applied at lower levels. You can pin a specific version with a negative priority and that will prevent it's installation.
    – ravery
    Jan 9, 2018 at 19:32
4

In my case apt satisfy was perfect for installing python3 version greater-equal 3.9.

sudo apt update
sudo apt satisfy "python3 (>= 3.9), python3-dev (>= 3.9)"

Also this can help with broken dependencies.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .