cli icon indicating copy to clipboard operation
cli copied to clipboard

CLI is not go install-able

Open marwan-at-work opened this issue 4 years ago • 11 comments

Due to the replace clause in the go.mod file of this repository, go get fails with the following errors:

go: found github.com/cli/cli/cmd/gh in github.com/cli/cli v0.11.0
# github.com/cli/cli/api
go/pkg/mod/github.com/cli/[email protected]/api/queries_issue.go:393:12: gql.MutateNamed undefined (type *graphql.Client has no field or method MutateNamed)
go/pkg/mod/github.com/cli/[email protected]/api/queries_issue.go:418:12: gql.MutateNamed undefined (type *graphql.Client has no field or method MutateNamed)
go/pkg/mod/github.com/cli/[email protected]/api/queries_repo.go:148:12: too many errors

I highly recommend either removing this replace clause here either by contributing the changes upstream or forking the repo and changing the import path.

Thanks!

marwan-at-work avatar Jul 18 '20 20:07 marwan-at-work

AFAIK, we are just focussing on being a command line program, and not a library/dependency/module for any external program, so go getting cli would not make sense

AliabbasMerchant avatar Jul 21 '20 02:07 AliabbasMerchant

@AliabbasMerchant just FYI I wasn't trying to use it as a library or dependency. Go get is a common way to download and install Go programs that are executed as a binary

marwan-at-work avatar Jul 21 '20 02:07 marwan-at-work

Oh. Okay :+1:

AliabbasMerchant avatar Jul 21 '20 02:07 AliabbasMerchant

The repo is already forked but there is another issue: cli/shurcooL-graphql@89ab2a8.

The added go.mod declares its module as github.com/shurcooL/graphql so it cannot be directly required as cli/shurcooL-graphql, thus the need for the replace directive here.

I created a pull request to get this fixed as referenced above.

Directly trying to push these kinds of changes upstream is already in progress, see:

  • shurcooL/graphql#53
  • shurcooL/graphql#57

Uzume avatar Nov 20 '20 19:11 Uzume

This issue prevents gh from being installed directly by using Go 1.16's go install:

% go install github.com/cli/cli/cmd/[email protected]
go: downloading github.com/cli/cli v1.9.2
go install: github.com/cli/cli/cmd/[email protected] (in github.com/cli/[email protected]):
  The go.mod file for the module providing named packages contains one or
  more replace directives. It must not contain directives that would cause
  it to be interpreted differently than if it were the main module.

Given that it looks like the graphql upstream isn't being updated, and that the cli repository doesn't depend on anything external that itself depends on the graphql repository, it seems like it would be a reasonable idea to hard fork it, replacing all import paths as necessary.

rogpeppe avatar Apr 27 '21 16:04 rogpeppe

@rogpeppe You are right; our upstream changes to graphql package are unlikely to get merged and we should hard-fork this dependency instead.

mislav avatar Apr 27 '21 17:04 mislav

It would be nice to be able to simply install it from go get. The package manager options available for Linux just aren't good.

go install github.com/cli/cli/v2/cmd/gh@latest

go install: github.com/cli/cli/v2/cmd/gh@latest (in github.com/cli/cli/[email protected]):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

NatoBoram avatar Oct 26 '21 15:10 NatoBoram

It seems like the origin of this problem might finally be solved and this can be rectified here after this gets merged:

  • cli/shurcooL-graphql#3

Uzume avatar Nov 17 '21 06:11 Uzume

Linking threads, this now appears to be blocked on https://github.com/cli/cli/issues/4731.

myitcv avatar Jan 08 '22 06:01 myitcv

This issue should also be retitled to something like:

"CLI is not go install-able"

because the de facto means of installing a Go program outside of a module context is now:

go install github.com/cli/cli/v2/cmd/[email protected]

(as mentioned in a couple of comments above)

myitcv avatar Jan 08 '22 06:01 myitcv

@myitcv I renamed the issue. Also, the only replace statement I see the crypto library which at this point should also be hard-forked as I think that would make for a much better experience.

marwan-at-work avatar Jul 22 '22 17:07 marwan-at-work

Great works, thanks all!

myitcv avatar Oct 18 '23 13:10 myitcv