3

i'm face a problem when trying to install multiple packages

So for example when i try this :

apt-get install php5-gd php5-idn php-pear php5-imagick php5-imap php5-json etc..  

i get :

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package php5-gd php5-idn php-pear php5-imagick php5-imap php5-json

But i have no trouble installing the packages on at a time.

Am i doing it wrong ?

2
  • The command looks correct. If you ate entering it exactly like that, it should work. The error looks like you have some wrapper in place, either a shell alias or a misbehaving program you are entering this command into (perhaps a PHP script you need to tell us about?)
    – tripleee
    Mar 9, 2014 at 16:53
  • No, I'm doing this on a fresh debian 7 install. Apart from apache2 and the standard packages that come with debian, nothing else is installed yet.
    – FlashSP
    Mar 9, 2014 at 18:22

4 Answers 4

1

You don't run apt-get with admin rights. In order to do that make sure you use sudo before you execute apt-get.

Here is the full command:

sudo apt-get install php5-gd php5-idn php-pear php5-imagick php5-imap php5-json
3
  • 1
    Thanks for your answer but I get the same result when using sudo. E: Unable to locate package php5-imagick php5-imap php5-json php5-mcrypt . Do you think it's a syntax problem ? The error message makes me think that apt-get is considering the package names (for ex : php5-imagick php5-imap php5-json php5-mcrypt ) as a single package name, which it obviously doesn't recognize
    – FlashSP
    Mar 9, 2014 at 16:27
  • 1
    Looks like the package isn't in the repos. Try sudo apt-get update and then sudo apt-get upgrade and then sudo apt-get install php5-gd php5-idn php-pear php5-imagick php5-imap php5-json
    – Julian
    Mar 9, 2014 at 16:33
  • Yup, tried that as well but It doesn't help. What's weird is that I can install the packages one at a time which means they definitely are in the repos (but you can imagine how tedious it can be). It's the 'bulk' install that doesn't work. Thank you for taking the time to reply !
    – FlashSP
    Mar 9, 2014 at 16:41
1

Your error message tells the story: When calling

apt-get install does not exist but bash does

The result should be:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package does
E: Unable to locate package not
E: Unable to locate package exist
E: Unable to locate package but
E: Unable to locate package does

You get only one line, which means that either your shell itself or any alias or function defined in the shell for apt-get does not send the individual package names to the real executable as individual arguments, but as one long argument containing spaces. I think this is what tripleee was pointing out.

To find out what happens:

  1. If you did not type this directly into a "normal" shell but into a wrapper (a web-frontend to the shell counts as such): stop doing that or look up the documentation of the wrapper
  2. If you really typed this in correctly, check if an alias or a function is defined:
    • enter: type apt-get
    • should return: apt-get is /usr/bin/apt-get
    • if it returns apt-get is a function or apt-get is aliased to ..., you have your answer
1
  • This should be the accepted answer. Based on the results, something seems to be manipulating OP's apt or apt-get commands to be non-standard... Dec 27, 2020 at 22:04
1

I've experienced the same with clean ubuntu install. Running

apt-get update

helped, as it pulled latest package info.

0
1

I believe this might be a copy-paste / line-endings issue. Try putting the line with the long list of packages in its own shell file and then run it. The following seems to work reliably:

E.g.:

gedit installer.sh

Then paste the long line and save:

sudo apt-get install php-gd php-pear php-imagick php-imap php-json

Then set the permissions and run:

chmod +x installer.sh
./installer.sh
1
  • This is good feedback in the case of sourcing a list of packages in a bash script, but I believe OP was actually typing the command manually into his shell. Dec 27, 2020 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.