containers / build

another build tool for container images (archived, see https://github.com/rkt/rkt/issues/4024)
Apache License 2.0
342 stars 80 forks source link

vagrant up fails with "unable to resolve host..." then `pushd` into nonexistent directory #234

Closed jzacsh closed 7 years ago

jzacsh commented 8 years ago

tl;dr problem running vagrant up from the readme, below (debugging info at the bottom)..

Hi, I'm guessing this might be an easy fix, and I'm happy to help debug the scripts - though I don't see anything obvious, looking myself...

I can't tell if the problem is the unable to resolve host ubuntu-xenial error (or maybe that's harmless?) or the pushd: /vagrant: No such file or directory, below:

$ vagrant up && vagrant ssh
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/xenial64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/xenial64'
    default: URL: https://atlas.hashicorp.com/ubuntu/xenial64
==> default: Adding box 'ubuntu/xenial64' (v20160707.0.0) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/ubuntu/boxes/xenial64/versions/20160707.0.0/providers/virtualbox.box
    default: Progress: 5% 

[... snipped... ]

  default: Progress: 99% (Rate: 7160k/s, Estimated time rema==> default: Successfully added box 'ubuntu/xenial64' (v20160707.0.0) for 'virtualbox'!
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: Setting the name of the VM: ubuntu-xenial-16.04-cloudimg
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: ubuntu
    default: SSH auth method: password
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Authentication failure. Retrying...
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Running provisioner: shell...
    default: Running: /home/jzacsh/tmp/vagrant-shell20160714-30920-g7og43.sh
==> default: + export DEBIAN_FRONTEND=noninteractive
==> default: + DEBIAN_FRONTEND=noninteractive
==> default: + VERSION=1.4.2
==> default: + OS=linux
==> default: + ARCH=amd64
==> default: + prefix=/usr/local
==> default: + '[' -e /usr/local/go ']'
==> default: + wget -q https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
==> default: + sudo tar -C /usr/local -xzf go1.4.2.linux-amd64.tar.gz
==> default: sudo
==> default: :
==> default: unable to resolve host ubuntu-xenial
==> default: + echo 'export GOROOT=/usr/local/go'
==> default: + sudo tee /etc/profile.d/01go.sh
==> default: sudo: unable to resolve host ubuntu-xenial
==> default: export GOROOT=/usr/local/go
==> default: + cat
==> default: + sudo tee -a /etc/profile.d/go.sh
==> default: sudo: unable to resolve host ubuntu-xenial
==> default:
==> default: export GOPATH=$HOME/.gopath
==> default:
==> default: [ -e $GOPATH ] || mkdir -p $GOPATH
==> default:
==> default: export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
==> default: + which git
==> default: /usr/bin/git
==> default: + sudo apt-get install -y git
==> default: sudo
==> default: :
==> default: unable to resolve host ubuntu-xenial
==> default: Reading package lists...
==> default: Building dependency tree...
==> default:
==> default: Reading state information...
==> default: git is already the newest version (1:2.7.4-0ubuntu1).
==> default: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
==> default: Running provisioner: shell...
    default: Running: /home/jzacsh/tmp/vagrant-shell20160714-30920-tj5186.sh
==> default: + export DEBIAN_FRONTEND=noninteractive
==> default: + DEBIAN_FRONTEND=noninteractive
==> default: + pushd /vagrant
==> default: /tmp/vagrant-shell: line 6: pushd: /vagrant: No such file or directory
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

more debug info:

$ git remote -v
origin  https://github.com/appc/acbuild (fetch)
origin  https://github.com/appc/acbuild (push)

$ git rev-parse HEAD
7be3ebe7431eeb146f672254d51d8a086ea90aaa

$ lsb_release --all
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux unstable (sid)
Release:    unstable
Codename:   sid

$ uname -a 
Linux theswan 4.6.0-1-amd64 #1 SMP Debian 4.6.3-1 (2016-07-04) x86_64 GNU/Linux

$ vboxmanage --version
5.0.24_Debianr108355

$ vagrant --version
Vagrant 1.8.4
jgerken commented 8 years ago

I have the same issue. The hostname error can be fixed by adding 127.0.0.1 ubuntu-xenial to /etc/hosts. Run the following commands (instead of nano you can you any editor you like):

vagrant up --no-provision
vagrant ssh
sudo nano /etc/hosts

After adding the line to /etc/hosts, exit the vagrant box and run

vagrant up --provision

Unfortunately, the directory /vagrant is still missing and the provisioning fails. I have no idea yet how to fix that.

cgonyeo commented 8 years ago

Debugging vagrant issues is always hard for me since I've never been able to get vagrant to work on my box :/

I'll find a coworker with vagrant next week and see if I can get the Vagrantfile working again. More likely than not I just made a silly mistake at some point.

psivesely commented 8 years ago

The solution to this would be to add the line

config.vm.synced_folder "./", "/vagrant", disabled: false

to the Vagrantfile. However, the person building the Ubuntu Xenial images screwed up and didn't install Virtualbox Guest Additions into the image and it's been a problem for quite a few months now (see https://bugs.launchpad.net/cloud-images/+bug/1565985).

If you want @dgonyeo, I have a workaround, implemented in https://github.com/freedomofpress/FingerprintSecureDrop/blob/master/Vagrantfile, which I can make work with your Vagrantfile. It's a bit of annoyance because it requires the user do a couple extra steps versus just vagrant up, but afaik there's not really a better way to handle this until Ubuntu fixes their Xenial Vagrant image.

psivesely commented 8 years ago

I'm downloading the latest Xenial box and then testing the build with the modified Vagrantfile. Will update with how it goes.

psivesely commented 8 years ago

Okay, so that fixed the original problem this issue was started with, but just uncovered further problems in the provisioning scripts (specifically, in scripts/vagrant-install-go.sh).

==> default: Running provisioner: shell...
    default: Running: /tmp/vagrant-shell20160808-5907-9ugdfb.sh
==> default: + export DEBIAN_FRONTEND=noninteractive
==> default: + DEBIAN_FRONTEND=noninteractive
==> default: + VERSION=1.4.2
==> default: + OS=linux
==> default: + ARCH=amd64
==> default: + prefix=/usr/local
==> default: + '[' -e /usr/local/go ']'
==> default: + wget -q https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
==> default: + sudo tar -C /usr/local -xzf go1.4.2.linux-amd64.tar.gz
==> default: sudo
==> default: :
==> default: unable to resolve host ubuntu-xenial
==> default: + echo 'export GOROOT=/usr/local/go'
==> default: + sudo tee /etc/profile.d/01go.sh
==> default: sudo: unable to resolve host ubuntu-xenial
==> default: export GOROOT=/usr/local/go
==> default: + cat
==> default: + sudo tee -a /etc/profile.d/go.sh
==> default: sudo: unable to resolve host ubuntu-xenial
==> default:
==> default: export GOPATH=$HOME/.gopath
==> default:
==> default: [ -e $GOPATH ] || mkdir -p $GOPATH
==> default:
==> default: export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
==> default: + which git
==> default: /usr/bin/git
==> default: Running provisioner: shell...
    default: Running: /tmp/vagrant-shell20160808-5907-5ul8rv.sh
==> default: + export DEBIAN_FRONTEND=noninteractive
==> default: + DEBIAN_FRONTEND=noninteractive
==> default: + pushd /vagrant
==> default: /vagrant ~
==> default: + ./build
==> default: Building acbuild...
==> default: gopath/src/github.com/appc/acbuild/lib/begin.go:32:2: cannot find package "github.com/appc/docker2aci/lib" in any of:
==> default:    /usr/local/go/src/github.com/appc/docker2aci/lib (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/appc/docker2aci/lib (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/lib/begin.go:33:2: cannot find package "github.com/appc/docker2aci/lib/common" in any of:
==> default:    /usr/local/go/src/github.com/appc/docker2aci/lib/common (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/appc/docker2aci/lib/common (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/util/files.go:23:2: cannot find package "github.com/appc/spec/aci" in any of:
==> default:    /usr/local/go/src/github.com/appc/spec/aci (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/appc/spec/aci (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/registry/fetch.go:32:2: cannot find package "github.com/appc/spec/discovery" in any of:
==> default:    /usr/local/go/src/github.com/appc/spec/discovery (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/appc/spec/discovery (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/registry/fetch.go:33:2: cannot find package "github.com/appc/spec/pkg/acirenderer" in any of:
==> default:    /usr/local/go/src/github.com/appc/spec/pkg/acirenderer (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/appc/spec/pkg/acirenderer (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/util/manifest.go:25:2: cannot find package "github.com/appc/spec/schema" in any of:
==> default:    /usr/local/go/src/github.com/appc/spec/schema (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/appc/spec/schema (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/engine/common.go:18:2: cannot find package "github.com/appc/spec/schema/types" in any of:
==> default:    /usr/local/go/src/github.com/appc/spec/schema/types (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/appc/spec/schema/types (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/registry/fetch.go:35:2: cannot find package "github.com/coreos/ioprogress" in any of:
==> default:    /usr/local/go/src/github.com/coreos/ioprogress (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/coreos/ioprogress (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/engine/chroot/chroot.go:24:2: cannot find package "github.com/coreos/rkt/pkg/fileutil" in any of:
==> default:    /usr/local/go/src/github.com/coreos/rkt/pkg/fileutil (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/coreos/rkt/pkg/fileutil (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/engine/chroot/chroot.go:25:2: cannot find package "github.com/coreos/rkt/pkg/multicall" in any of:
==> default:    /usr/local/go/src/github.com/coreos/rkt/pkg/multicall (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/coreos/rkt/pkg/multicall (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/util/files.go:24:2: cannot find package "github.com/coreos/rkt/pkg/tar" in any of:
==> default:    /usr/local/go/src/github.com/coreos/rkt/pkg/tar (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/coreos/rkt/pkg/tar (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/engine/chroot/chroot.go:26:2: cannot find package "github.com/coreos/rkt/pkg/user" in any of:
==> default:    /usr/local/go/src/github.com/coreos/rkt/pkg/user (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/coreos/rkt/pkg/user (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/engine/chroot/chroot-child.go:25:2: cannot find package "github.com/spf13/cobra" in any of:
==> default:    /usr/local/go/src/github.com/spf13/cobra (from $GOROOT)
==> default:    /vagrant/gopath/src/github.com/spf13/cobra (from $GOPATH)
==> default: gopath/src/github.com/appc/acbuild/registry/fetch.go:36:2: cannot find package "xi2.org/x/xz" in any of:
==> default:    /usr/local/go/src/xi2.org/x/xz (from $GOROOT)
==> default:    /vagrant/gopath/src/xi2.org/x/xz (from $GOPATH)
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

So now this is a problem between the build bash script and how you've set up the VM. The libraries it's looking for do seem to exist under vendor/ (/vagrant/vendor in the VM).

psivesely commented 8 years ago

At @freedomofpress we've switched to using bento boxes for all our Ubuntu Vagrant images. They're all the packages you get in a default Ubuntu server install plus the VirtualBox Guest Additions packages.