incu6us / goimports-reviser

Right imports sorting & code formatting tool (goimports alternative)
MIT License
611 stars 72 forks source link

go command required, not found #137

Closed jniewt closed 6 days ago

jniewt commented 1 year ago

Installed with snap and now I'm getting:

Failed to fix file: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr:

even though go (1.19) is in my $PATH.

incu6us commented 1 year ago

please, more details:

jniewt commented 1 year ago

Sorry. There you go:

version: 3.4.5 build with: tag: v3.4.5 commit: 607f2e628d899ae012894fcbd513d85cd65f0281 source: https://github.com/incu6us/goimports-reviser

Command: /var/lib/snapd/snap/bin/goimports-reviser -rm-unused -company-prefixes foo.com -format -recursive .

Output: 2023/09/14 15:07:07 Failed to fix directory .: failed to walk dif: failed to fix: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr:

I should add I'm trying to move from an older version that doesn't have the version flag, so no idea what version it was, but the command parameters worked there flawlessly. I tried to update with go install but had some problems there so I used snap.

incu6us commented 1 year ago

what shows you:

?

jniewt commented 1 year ago
$ go version
go version go1.19.12 linux/amd64
$ which go
/usr/bin/go
$ echo $PATH
/home/foo/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/var/lib/snapd/snap/bin:/home/foo/go/bin:/home/foo/.local/share/JetBrains/Toolbox/scripts
incu6us commented 1 year ago

try to use:

PATH=$PATH:/usr/bin /var/lib/snapd/snap/bin/goimports-reviser -rm-unused -format -recursive .
jniewt commented 1 year ago

It's still the same error unfortunately.

incu6us commented 1 year ago

Your issue is related to configuration of your Snapd. Unfortunately, can't suggest what is wrong on your host with Snap. Reinstall the tool using go command

go install -v github.com/incu6us/goimports-reviser/v3@latest
jniewt commented 1 year ago

Any idea why this happens then?

$ go clean -modcache
$ go install -v github.com/incu6us/goimports-reviser/v3@latest
go: downloading github.com/incu6us/goimports-reviser/v3 v3.4.5
go: downloading github.com/incu6us/goimports-reviser v0.1.6

I can't seem to be able to get the right binary out of this, it doesn't even have the -version option. That's why I tried snap in the first place, because then at least I get the v3 binary.

incu6us commented 1 year ago

v1 is fetched because of linter package inside the project. it is ok. try to install the tool using go and run goimports-reviser with version parameter

incu6us commented 1 year ago

my bad. don't use version if you're installing the tool using go. just use below line to install the latest version

go install -v github.com/incu6us/goimports-reviser/v3@latest
incu6us commented 1 year ago

@jniewt have you had a chance to resolve it on you environment?

jniewt commented 1 year ago

No, sorry. I gave up and I'm using the old one. Whenever I install it with go like you said it installs fine but when I run it it still seems to run the old one and I can't find the reason for that. Or I assume it's the old one because it doesn't have a -version option.

On Sat, 25 Nov 2023, 21:28 Vyacheslav Pryimak, @.***> wrote:

@jniewt https://github.com/jniewt have you had a chance to resolve it on you environment?

— Reply to this email directly, view it on GitHub https://github.com/incu6us/goimports-reviser/issues/137#issuecomment-1826413834, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJJGZKRWTBXJVSKAXRKR6VTYGJIF7AVCNFSM6AAAAAA4YALO3GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWGQYTGOBTGQ . You are receiving this because you were mentioned.Message ID: @.***>

elbert-chan commented 11 months ago

I installed goimports-reviser with go (go install -v github.com/incu6us/goimports-reviser/v3@latest) . but I got the same error when i configure it in goland.

incu6us commented 11 months ago

@elbert-chan is it working from cli? not via your IDE?

elbert-chan commented 11 months ago

@elbert-chan is it working from cli? not via your IDE?

yes, cli is working. but IDE(goland) is not.

jniewt commented 11 months ago

I removed all files concerning goimports-reviser from my system and installed it with: go install -v github.com/incu6us/goimports-reviser/v3@latest (from the terminal window within Goland IDE). The resulting binary still doesn't have the -version flag, but it doesn't complain anymore about go.mod containing toolchain keyword, so I don't know what to make of it. It seems I have the new version now...?

incu6us commented 11 months ago

I removed all files concerning goimports-reviser from my system and installed it with: go install -v github.com/incu6us/goimports-reviser/v3@latest (from the terminal window within Goland IDE). The resulting binary still doesn't have the -version flag, but it doesn't complain anymore about go.mod containing toolchain keyword, so I don't know what to make of it. It seems I have the new version now...?

yes. it is the latest version

hiyced commented 5 months ago

@jniewt Have you solved your problem? I'm having the same issue.

hiyced commented 5 months ago

just solved my problem, need to add go/libexec to $PATH

@jniewt Have you solved your problem? I'm having the same issue.