Skip to content

Commit

Permalink
Merge #25325
Browse files Browse the repository at this point in the history
25325: build: make 'go get github.com/cockroachdb/cockroach' fail r=bdarnell a=benesch

The root package, github.com/cockroachdb/cockroach, previously served as
the main entry point for the default CCL binary. This meant that naively
running

    $ go get github.com/cockroachdb/cockroach

would fail with cryptic errors about missing "reserved keywords", as our
build requires generating some Go code via Make. Our documentation
suggests that users instead run

    $ go get -d github.com/cockroachdb/cockroach
    $ make

but many users, somewhat understandably, fail to read that
documentation.

Move the main entry point to ./pkg/cmd/cockroach. Running 'go get
github.com/cockroachdb/cockroach' will now produce a less confusing
error that reads:

    can't load package: package github.com/cockroachdb/cockroach: no Go
    files in GOPATH/src/github.com/cockroachdb/cockroach

Hopefully this spurs users to read the build instructions.

(Running 'go get github.com/cockroachdb/cockroach/pkg/cmd/cockroach'
still produces the same cryptic error messages as before, but users are
far less likely to construct that 'go get' invocation.)

Fix #23583.
Fix #23992.

Release note: None

Co-authored-by: Nikhil Benesch <[email protected]>
  • Loading branch information
craig[bot] and benesch committed May 30, 2018
2 parents 89690e0 + e64d40e commit f8a7889
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TAGS :=
ARCHIVE := cockroach.src.tgz
STARTFLAGS := -s type=mem,size=1GiB --logtostderr
BUILDMODE := install
BUILDTARGET := .
BUILDTARGET := ./pkg/cmd/cockroach
SUFFIX :=
INSTALL := install
prefix := /usr/local
Expand Down
2 changes: 1 addition & 1 deletion pkg/acceptance/cluster/dockercluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var maxRangeBytes = config.DefaultZoneConfig().RangeMaxBytes

// CockroachBinary is the path to the host-side binary to use.
var CockroachBinary = flag.String("b", func() string {
rootPkg, err := build.Import("github.com/cockroachdb/cockroach", "", 0)
rootPkg, err := build.Import("github.com/cockroachdb/cockroach", "", build.FindOnly)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestNoLinkForbidden(t *testing.T) {
defer leaktest.AfterTest(t)()
// Verify that the cockroach binary doesn't depend on certain packages.
buildutil.VerifyNoImports(t,
"github.com/cockroachdb/cockroach", true,
"github.com/cockroachdb/cockroach/pkg/cmd/cockroach", true,
[]string{
"testing", // defines flags
"go/build", // probably not something we want in the main binary
Expand Down
6 changes: 4 additions & 2 deletions main.go → pkg/cmd/cockroach/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
// implied. See the License for the specific language governing
// permissions and limitations under the License.

package main

// This is the default entry point for a CockroachDB binary.
//
// The ccl hook import below means building this will produce CCL'ed binaries.
// This file itself remains Apache2 to preserve the organization of ccl code
// under the /pkg/ccl subtree, but is unused for pure FLOSS builds.
package main

import (
_ "github.com/cockroachdb/cockroach/pkg/ccl" // ccl init hooks
"github.com/cockroachdb/cockroach/pkg/cli"
Expand Down

0 comments on commit f8a7889

Please sign in to comment.