GithubHelp home page GithubHelp logo

Cobra-Cli init Error about cobra-cli HOT 14 CLOSED

spf13 avatar spf13 commented on August 23, 2024 1
Cobra-Cli init Error

from cobra-cli.

Comments (14)

tahsinrahman avatar tahsinrahman commented on August 23, 2024 2

i'm having the same issue

go version 1.18.1

update: seems it only occurs with go.work. #26

from cobra-cli.

DevolvingSpud avatar DevolvingSpud commented on August 23, 2024 2

Seeing the same issue here, first module worked, second is unhappy in exactly the same way as the above with the error:

Error: invalid character '{' after top-level value

I worked around it by doing the init in a directory not under the workspace, then copying everything in. Once that's in place, the other commands (add etc.) seem to work.

from cobra-cli.

fseesink avatar fseesink commented on August 23, 2024 1

I am experiencing the same with Go 1.18.3 on macOS 12.4 "Monterey". And like the others, I, too, am in Go workspace.

If instead, at my Desktop or just a directory that's not a Go workspace, I simply

  1. mkdir Test
  2. cd Test
  3. go mod init cobratest
  4. cobra-cli init

then all is well.

So there definitely seems to be something with regard to the Go workspace feature for some reason.

from cobra-cli.

manicar2093 avatar manicar2093 commented on August 23, 2024

Don't you have a typo on your command? It's cobra-cli init

I'm using the same go version and I did not have this problem πŸ€”

from cobra-cli.

angelorc avatar angelorc commented on August 23, 2024

same here, the issue appear if you use go work

from cobra-cli.

kcmvp avatar kcmvp commented on August 23, 2024

i'm having the same issue

go version 1.18.1

update: seems it only occurs with go.work. #26

yes, my project is in a workspace. it's very easy to reproduce
1: create a workspace
2: init first normal module project
3: create a cobra module
4: run cobra-cli init --- runs into error

from cobra-cli.

tomato-ga avatar tomato-ga commented on August 23, 2024

I am running into a similar problem with init.

~/go/src/cobra cobra-cli init
cobra-cli: command not found

Installation is done
γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2022-06-22 20 04 29

from cobra-cli.

marckhouzam avatar marckhouzam commented on August 23, 2024

I am running into a similar problem with init.

~/go/src/cobra cobra-cli init cobra-cli: command not found

Try ./cobra-cli init

from cobra-cli.

tomato-ga avatar tomato-ga commented on August 23, 2024

@marckhouzam

Thx!
It didn't seem to work because I was running it in a VS code terminal,
I tried it with an SSH connection and it worked.

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2022-06-22 22 45 53

from cobra-cli.

ezk84 avatar ezk84 commented on August 23, 2024

Running into this also, and also using a workspace. Followed @DevolvingSpud's workaround for now.

from cobra-cli.

ebarti avatar ebarti commented on August 23, 2024

Same here, go workspaces are quite a disappointing feature to be honest, they seem to create more issues than anything.

from cobra-cli.

marckhouzam avatar marckhouzam commented on August 23, 2024

When doing an init, the cobra-cli runs go list -json -m to get information about the current module.
When using go workspaces, that command returns all modules in the workspace, which looks something like this:

$ go list -json -m
{
	"Path": "github.com/marckhouzam/cli",
	"Main": true,
	"Dir": "/Users/kmarc/tmp/cli",
	"GoMod": "/Users/kmarc/tmp/cli/go.mod",
	"GoVersion": "1.18"
}
{
	"Path": "github.com/marckhouzam/cli2",
	"Main": true,
	"Dir": "/Users/kmarc/tmp/cli2",
	"GoMod": "/Users/kmarc/tmp/cli2/go.mod",
	"GoVersion": "1.18"
}

This a a case the cobra-cli is not handling. We need to handle workspaces properly.

from cobra-cli.

marckhouzam avatar marckhouzam commented on August 23, 2024

Ah yes, I see this was reported in #26. Sorry for the noise.

from cobra-cli.

marckhouzam avatar marckhouzam commented on August 23, 2024

Duplicate of #26

from cobra-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.