Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on Mac OS X 10.9.5 #9

Closed
vielmetti opened this issue Jun 22, 2015 · 21 comments
Closed

Build fails on Mac OS X 10.9.5 #9

vielmetti opened this issue Jun 22, 2015 · 21 comments

Comments

@vielmetti
Copy link

Edwards-MacBook-Air:src emv$ git clone https://github.com/opencontainers/runc.git
Cloning into 'runc'...
remote: Counting objects: 7237, done.
remote: Total 7237 (delta 0), reused 0 (delta 0), pack-reused 7237
Receiving objects: 100% (7237/7237), 1.59 MiB | 1.67 MiB/s, done.
Resolving deltas: 100% (4531/4531), done.
Checking connectivity... done.
Edwards-MacBook-Air:src emv$ cd runc
Edwards-MacBook-Air:runc emv$ ls
Godeps      Makefile    checkpoint.go   libcontainer    restore.go  signals.go  spec_linux.go   utils.go
LICENSE     README.md   events.go   main.go     run.go      spec.go     tty.go
Edwards-MacBook-Air:runc emv$ make
go get github.com/tools/godep
godep go build -o runc .
checkpoint.go:9:2: cannot find package "github.com/opencontainers/runc/libcontainer" in any of:
    /usr/local/go/src/pkg/github.com/opencontainers/runc/libcontainer (from $GOROOT)
    /Users/emv/src/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer (from $GOPATH)
    /Users/emv/src/github.com/opencontainers/runc/libcontainer
restore.go:11:2: cannot find package "github.com/opencontainers/runc/libcontainer/configs" in any of:
    /usr/local/go/src/pkg/github.com/opencontainers/runc/libcontainer/configs (from $GOROOT)
    /Users/emv/src/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/configs (from $GOPATH)
    /Users/emv/src/github.com/opencontainers/runc/libcontainer/configs
main.go:10:2: cannot find package "github.com/opencontainers/runc/libcontainer/nsenter" in any of:
    /usr/local/go/src/pkg/github.com/opencontainers/runc/libcontainer/nsenter (from $GOROOT)
    /Users/emv/src/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/nsenter (from $GOPATH)
    /Users/emv/src/github.com/opencontainers/runc/libcontainer/nsenter
restore.go:12:2: cannot find package "github.com/opencontainers/runc/libcontainer/utils" in any of:
    /usr/local/go/src/pkg/github.com/opencontainers/runc/libcontainer/utils (from $GOROOT)
    /Users/emv/src/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/utils (from $GOPATH)
    /Users/emv/src/github.com/opencontainers/runc/libcontainer/utils
godep: go exit status 1
make: *** [all] Error 1
Edwards-MacBook-Air:runc emv$ uname
Darwin
Edwards-MacBook-Air:runc emv$ 
@LK4D4
Copy link
Contributor

LK4D4 commented Jun 22, 2015

@vielmetti Did you set your GOPATH to /Users/emv?

@chmouel
Copy link

chmouel commented Jun 22, 2015

I have the same issue on linux and i did setup my GOPATH as well

@pims
Copy link

pims commented Jun 22, 2015

Different error on OS X Yosemite:

cd runc/
tim@home /go/src/github.com/opencontainers/runc> make
go get github.com/tools/godep
godep go build -o runc .
# github.com/opencontainers/runc/libcontainer/configs
libcontainer/configs/namespaces.go:5: undefined: Namespace
# github.com/opencontainers/runc/libcontainer/nsenter
libcontainer/nsenter/nsexec.c:8:10: fatal error: 'linux/limits.h' file not found
godep: go exit status 2
make: *** [all] Error 1

@krobertson
Copy link

Since runc does the containerization directly, I believe it is only intended to be built/ran on Linux.

@LK4D4
Copy link
Contributor

LK4D4 commented Jun 22, 2015

I'm pretty sure it should build on MacOS and FreeBSD.

@AndrewVos
Copy link

Looks like libcontainers hasn't been vendored?

[~/runc] master ∞ ls Godeps/_workspace/src/github.com/opencontainers
ls: cannot access Godeps/_workspace/src/github.com/opencontainers: No such file or directory

@AndrewVos
Copy link

Install instructions should probably be:

go get github.com/opencontainers/runc
cd $GOPATH/src/github.com/opencontainers/runc
make

@vielmetti
Copy link
Author

+1 to @AndrewVos who got me closer with his install instructions. Again on Mac OS X 10.9, some progress:

Edwards-MacBook-Air:runc emv$ go get github.com/opencontainers/runc
# github.com/opencontainers/runc/libcontainer/configs
../github.com/opencontainers/runc/libcontainer/configs/namespaces.go:5: undefined: Namespace
# github.com/opencontainers/runc/libcontainer/nsenter
../github.com/opencontainers/runc/libcontainer/nsenter/nsexec.c:8:10: fatal error: 'linux/limits.h' file not found
Edwards-MacBook-Air:runc emv$ cd $GOPATH/src/github.com/opencontainers/runc
Edwards-MacBook-Air:runc emv$ make
go get github.com/tools/godep
godep go build -o runc .
# github.com/opencontainers/runc/libcontainer/configs
libcontainer/configs/namespaces.go:5: undefined: Namespace
# github.com/opencontainers/runc/libcontainer/nsenter
libcontainer/nsenter/nsexec.c:8:10: fatal error: 'linux/limits.h' file not found
godep: go exit status 2
make: *** [all] Error 1

at least that suggests where a change might be made.

@vielmetti
Copy link
Author

And digging a little deeper, when I patch so that I do

#include <limits.h>

instead of including linux/limits.h, I discover that this all depends on the clone(2) syscall which Darwin does not have. Not sure that there's an easy way around that on OS X without delving way deeper into kernel space that I don't pretend to understand.

http://linux.die.net/man/2/clone is a man page.

@vincepri
Copy link

Same thing happens on OSX 10.10.3

# github.com/opencontainers/runc/libcontainer/configs
libcontainer/configs/namespaces.go:5: undefined: Namespace
# github.com/opencontainers/runc/libcontainer/nsenter
libcontainer/nsenter/nsexec.c:8:10: fatal error: 'linux/limits.h' file not found
godep: go exit status 2
make: *** [all] Error 1

@didip
Copy link

didip commented Jun 23, 2015

@vielmetti is onto something here.
It should be #include <limits.h> because on OS X Yosemite that file is located here:

/Library/Developer/CommandLineTools/usr/lib/clang/6.1.0/include/limits.h

Once I changed the include to limits.h, I got different errors:

make
go get github.com/tools/godep
godep go build -o runc .
# github.com/opencontainers/runc/libcontainer/configs
libcontainer/configs/namespaces.go:5: undefined: Namespace
# github.com/opencontainers/runc/libcontainer/nsenter
libcontainer/nsenter/nsexec.c:61:10: warning: implicit declaration of function 'clone' is invalid in C99 [-Wimplicit-function-declaration]
libcontainer/nsenter/nsexec.c:61:42: error: use of undeclared identifier 'CLONE_PARENT'
libcontainer/nsenter/nsexec.c:135:7: warning: implicit declaration of function 'setns' is invalid in C99 [-Wimplicit-function-declaration]
libcontainer/nsenter/nsexec.c:154:8: warning: implicit declaration of function 'dup3' is invalid in C99 [-Wimplicit-function-declaration]
godep: go exit status 2
make: *** [all] Error 1

Going further down the rabbit hole, I added the following:

int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ... /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ );
int setns(int fd, int nstype);
int dup3(int oldfd, int newfd, int flags);

#if __APPLE__
#define CLONE_PARENT 0
#endif

Which leads me to this error:

Undefined symbols for architecture x86_64:
  "_clone", referenced from:
      _clone_parent in nsexec.o
  "_dup3", referenced from:
      _nsexec in nsexec.o
  "_setns", referenced from:
      _nsexec in nsexec.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Funny that https://github.com/docker/libcontainer does not have the same problem even though the code looks identical.

@exaexa
Copy link

exaexa commented Jun 23, 2015

On linux (debian jessie), the exact reported error is fixed by using:

GOPATH=$PWD PATH=$PWD/bin:$PATH  make
#wait for it to fail, fixup dependencies
mkdir -p src/github.com/opencontainers/runc/
ln -sf $PWD/libcontainer src/github.com/opencontainers/runc/
GOPATH=$PWD PATH=$PWD/bin:$PATH  make
#works now

I think this is preferred for not using systemwide Go dependencies.

@collinanderson
Copy link

the above snippet fixed the problem for me.

@ggiamarchi
Copy link

Using godep the build is straightforward (tested on Ubuntu 14.04).

go get github.com/tools/godep
godep get github.com/opencontainers/runc
cd $GOPATH/src/github.com/opencontainers/runc
make

@alfonsodev
Copy link

@collinanderson fixed it on Mac OS ? from which folder do you run those lines ?

@collinanderson
Copy link

This was linux. I ran it from the runc git checkout. @ggiamarchi's snippet looks promising too.

@alfonsodev
Copy link

unfortunately @ggiamarchi's snippet fails in mac (Mac OS 10.10.2)

godep get github.com/opencontainers/runc
# github.com/opencontainers/runc/libcontainer/configs
libcontainer/configs/namespaces.go:5: undefined: Namespace
# github.com/opencontainers/runc/libcontainer/nsenter
libcontainer/nsenter/nsexec.c:8:10: fatal error: 'linux/limits.h' file not found
godep: go exit status 2
godep: exit status 1

@maxkueng
Copy link

Using make or manually running the commands in the Makefile also didn't work for me on Arch Linux and also in a golang:latest Docker container with the GOPATH set properly. But @exaexa 's snippet works.

@rajasec
Copy link
Contributor

rajasec commented Jun 25, 2015

even in Linux, for runc and libcontainers to be compiled vendor list need to be pulled.

@mattfarina
Copy link

I wouldn't expect it to build on Mac because the spec won't exist there. spec.go is an interface. The only implementation is spec_linux.go which only builds on linux.

@pushrax
Copy link

pushrax commented Jun 27, 2015

The documentation should be updated and this issue closed - it makes no sense to build this on OS X (yet).

mtesselH added a commit to mtesselH/runc that referenced this issue Jun 30, 2015
Should compile now without errors but changes needed to be added for each system so it actually works.
main_unsupported.go is a new file with all the unsupported commands
Fixes opencontainers#9

Signed-off-by: Marianna <mtesselh@gmail.com>
booyaa added a commit to booyaa/runc that referenced this issue Aug 27, 2015
Signed-off-by: Mark Sta Ana <booyaabooyaabooyaa@gmail.com>
mrunalp pushed a commit that referenced this issue Aug 28, 2015
Add caveat will only build on Linux as per #9
allencloud added a commit to allencloud/runc that referenced this issue Mar 8, 2018
…-path-in-rich-containers-mode-v1

support relative path in rich container mode
mrunalp pushed a commit to mrunalp/runc that referenced this issue Feb 22, 2019
thaJeztah referenced this issue in thaJeztah/runc Aug 8, 2019
[17.06 backport] remove hot-fix, and apply latest upstream patch for CVE-2019-5736
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests