0

I'm using hashicorp/precise64. (I got the same error for ubuntu/trusty64 and a lot other boxes as well.)

Tried to used the following code for provisioning, but got error.

  config.vm.provision "shell", inline: <<-SHELL
    sudo apt-get update
    sudo apt-get install -y python-pip python-dev python-setuptools build-essential
    sudo pip install numpy
  SHELL

==> default: sudo ==> default: : ==> default: pip: command not found

And after ssh into the VM, and tried to call pip, I got

vagrant@precise64:$ pip The program 'pip' is currently not installed. You can install it by typing: sudo apt-get install python-pip

If I do sudo apt-get install python-pip, pip will indeed be installed. I don't understand why it couldn't be install through shell.

I guess maybe it has to with exposing the installation to some paths?

fuiiii
  • 1,359
  • 3
  • 17
  • 33
  • 1
    I'm intrigued by this issue, but I'm not able to reproduce it with either "hashicorp/precise64" or "ubuntu/trusty64". Can you edit your question to include a complete minimal Vagrantfile that causes this error? – Patrick Lee Feb 07 '16 at 00:51
  • starting over (removing the vagrant box and instance) and add the '-y' flag for both 'sudo apt-get -y update;sudo apt-get -y upgrade' seem resolve the issue. I'm double checking and see if it actually does work now. – fuiiii Feb 07 '16 at 01:23

2 Answers2

0

starting over (removing the vagrant box and instance) and adding the -y flag for both sudo apt-get update;sudo apt-get upgrade resolved the issue.

I did 'sudo apt-get update;sudo apt-get upgrade' without the -y flag and the problem occurred.

Though I still don't understand why sudo apt-get install xxx will work through ssh without having to sudo apt-get -y update;sudo apt-get -y upgrade

fuiiii
  • 1,359
  • 3
  • 17
  • 33
0

I'm able to reproduce the problem w/ the following Vagrantfile (Ubuntu 23.04 guest):

# -*- mode: ruby -*-
# vi: set ft=ruby :

Site = "crbienes"
Box = Site + "-test"

Vagrant.configure("2") do |config|
    # Every Vagrant development environment requires a box. You can search for boxes at https://vagrantcloud.com/search.
    config.vm.box = "vasilli/Ubuntu-23.04-LAMP"
    config.vm.define Box
    config.vm.hostname = Box
    config.vm.network "private_network", ip: "192.168.70.11"

    config.vm.provider "virtualbox" do |vb|
    vb.name = Box
  end

  config.vm.provision "shell", inline: <<-SHELL
    sudo apt-get update
    sudo apt-get install -y python-pip python-dev python-setuptools build-essential
    sudo pip install numpy
  SHELL
end

I'm getting this error:

    crbienes-test: Package python-dev is not available, but is referred to by another package.
    crbienes-test: This may mean that the package is missing, has been obsoleted, or
    crbienes-test: is only available from another source
    crbienes-test: However the following packages replace it:
    crbienes-test:   python-dev-is-python3
    crbienes-test: 
    crbienes-test: Package python-setuptools is not available, but is referred to by another package.
    crbienes-test: This may mean that the package is missing, has been obsoleted, or
    crbienes-test: is only available from another source
    crbienes-test: 
    crbienes-test: Package python-pip is not available, but is referred to by another package.
    crbienes-test: This may mean that the package is missing, has been obsoleted, or
    crbienes-test: is only available from another source
    crbienes-test: However the following packages replace it:
    crbienes-test:   python3-pip

If I SSH into the guest I'm getting the exact same error, so that's good, consistent. I'm able to install python-dev-is-python3 and python3-pip via apt install. When I try to install build-essential I get a warning that I already have the latest version. But it still works (as in tries to install). I could not install/find python-setuptools. Seems like it's deprecated. You should search for alternatives.

This is your new Vagrantfile. I removed 'sudo' b/c the shell script is running as sudo by default, you don't need to explicitly specify it.:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Site = "crbienes"
Box = Site + "-test"

Vagrant.configure("2") do |config|
    # Every Vagrant development environment requires a box. You can search for boxes at https://vagrantcloud.com/search.
    config.vm.box = "vasilli/Ubuntu-23.04-LAMP"
    config.vm.define Box
    config.vm.hostname = Box
    config.vm.network "private_network", ip: "192.168.70.11"

    config.vm.provider "virtualbox" do |vb|
    vb.name = Box
    vb.linked_clone = true # saves time/space by not copying the box
  end

  config.vm.provision "shell", inline: <<-SHELL
    apt-get update
    apt-get install -y python3-pip python-dev-is-python3 build-essential
    pip install numpy # this gives me an error, you should investigate
  SHELL
end
vasilli
  • 43
  • 9