Closed zeke closed 1 year ago
@zeke Can you share the commands you tried and the output you got since https://github.com/replicate/cog/pull/823#issuecomment-1338095078?
Reading through the Go docs again:
The
go install
command builds and installs the packages named by the paths on the command line. Executables (main packages) are installed to the directory named by theGOBIN
environment variable, which defaults to$GOPATH/bin
or$HOME/go/bin
if theGOPATH
environment variable is not set.
What if you try running make install BINDIR=$GOBIN
?
GOPATH
attempt$ go env GOPATH
/Users/z/go
~/git/replicate/cog main*
$ echo $GOPATH
~/git/replicate/cog main*
$ make install PREFIX=$GOPATH
install -m 0755 cog /bin/cog
install: /bin/cog: Operation not permitted
make: *** [install] Error 71
~/git/replicate/cog main*
$ sudo make install PREFIX=$GOPATH
Password:
install -m 0755 cog /bin/cog
install: /bin/cog: Operation not permitted
make: *** [install] Error 71
~/git/replicate/cog main*
$ sudo make install PREFIX=$(go env GOPATH)
install -m 0755 cog /Users/z/go/bin/cog
~/git/replicate/cog main*
$ which cog
/Users/z/go/bin/cog
~/git/replicate/cog main*
$ cog --version
cog version v0.5.1-7-g0bb3ace (built 2022-12-13T09:17:37-0800)
make install-dev
attemptAdded this to the Makefile:
.PHONY: install-dev
install-dev: build-dependencies
go install $(LDFLAGS) $(MAIN)
Then:
$ make install-dev
make: *** No rule to make target `build-dependencies', needed by `install-dev'. Stop.
GOBIN
attempt$ make install BINDIR=$GOBIN
install -m 0755 cog /cog
install: /cog: Read-only file system
make: *** [install] Error 71
~/git/replicate/cog main*
$ sudo make install BINDIR=$GOBIN
install -m 0755 cog /cog
install: /cog: Read-only file system
make: *** [install] Error 71
~/git/replicate/cog main*
$ which go
/opt/homebrew/bin/go
~/git/replicate/cog main*
$ go version
go version go1.19.1 darwin/arm64
~/git/replicate/cog main*
$ echo $GOBIN
~/git/replicate/cog main*
$ go env GOBIN
@zeke Thanks for running through all of that.
It looks like sudo make install PREFIX=$(go env GOPATH)
worked as expected. Since that's in your user directory, that should work without sudo
, yeah?
sudo
or not, that seems like a reasonable solution for dev env setup. (Nice work figuring out to run go env
to get the missing env variables!) I opened https://github.com/replicate/cog/pull/851 with that change.
https://github.com/replicate/cog/pull/823 made some changes to the build process (to pave the way for
brew install cog
becoming a thing). The dev env docs slipped through the cracks, and they're now out of date. Let's update them to include the proper invocation for building and installing cog locally.A few ideas were floated about how to keep the local dev install working:
From @nickstenning:
From @mattt :
I attempted both of those (with various prependings of
sudo
) but wasn't able to get either of them working. I figured I should stop and open an issue for guidance before digging any further.