wtf
wtf copied to clipboard
Allow installation via `go install`
What should it do?
The current instructions to install via go get are deprecated in the recent versions of go.
Following the steps in README.md,
go get -u github.com/wtfutil/wtfgives this error:
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd@latest'
...
Running go install (which is a great way to install command line utilities) gives this error:
$go install github.com/wtfutil/wtf@latest
go: downloading github.com/wtfutil/wtf v0.43.0
go: github.com/wtfutil/wtf@latest (in github.com/wtfutil/[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.
It would be terrific to be able to install wtfutil using go install. I have found it to be a reliable way to install command line utilities, in particular.
The go version that I got these errors from is:
$go version
go version go1.21.5 linux/amd64
Seems that go install takes issue with this line:
https://github.com/wtfutil/wtf/blob/85b3568ad31d45bc0eb0c46c91d319621427208c/go.mod#L228
Git blame suggests https://github.com/wtfutil/wtf/commit/c327cd3bf1087d33a2c8f706da11f0fc087e06dc is relevant
Maybe dependent on (or blocked by?) https://github.com/wtfutil/todoist/pull/4 ?
For what it's worth, forking and removing that line (and changing the first line) in go.mod allowed me to install.
$go install github.com/edthedev/wtf@ba90358
go: downloading github.com/edthedev/wtf v0.0.0-20240520021219-ba90358e748d
go: downloading github.com/logrusorgru/aurora/v4 v4.0.0
go: downloading github
...
But it did not result in the expected wtfutil appearing in ~/go/bin.
This seems likely to be related to: https://stackoverflow.com/questions/26694271/go-install-doesnt-create-any-bin-file
(Essentially, go has a few more expectations about where main.go should be, if we want wtf to appear in ~/go/bin (on GOPATH).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Please disable that ⬆️ stale bot. 💩
To install, use:
go install github.com/wtfutil/wtf@latest
I still get this error on Windows with Powershell 7:
> go install github.com/wtfutil/wtf@latest
go: downloading github.com/wtfutil/wtf v0.43.0
go: github.com/wtfutil/wtf@latest (in github.com/wtfutil/[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.
and on RHEL under WSL, as well:
$ go install github.com/wtfutil/wtf@latest
go: downloading github.com/wtfutil/wtf v0.43.0
go: github.com/wtfutil/wtf@latest (in github.com/wtfutil/[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.
Indeed this is exactly what is discussed in https://github.com/golang/go/issues/44840 Nevertheless one can still clone the repo and install it directly
git clone https://github.com/wtfutil/wtf.git
cd wtf
go install .
Which I agree would be handier if one could use go install directly...