cobra init only works with name

Created on 21 Mar 2018  路  6Comments  路  Source: spf13/cobra

cobra init --help lists possible combinations including no name.
It seems that all other combinations except cobra init name, fail.
For example:

[user@host cobra_project]$ cobra init 
Error: Rel: can't make /home/user/ws/testws-2/go/cobra_project relative to 

[user@host cobra_project]$ cobra init $(pwd)
Error: Rel: can't make /home/user/ws/testws-2/go/cobra_project relative to 

[user@host cobra_project]$ cobra init $(pwd)/test
Error: can't read path info: lstat /home/user/ws/testws-2/go/cobra_project/test: no such file or directory

With a name provided, it works, as expected:

[user@host cobra_project]$ cobra init cobra_project
Your Cobra application is ready at
/home/user/ws/testws-2/go/cobra_project/src/cobra_project.

Give it a try by going there and running `go run main.go`.
Add commands to it by running `cobra add [cmdname]`.


$GOPATH is set to: /home/user/ws/testws-2/go/cobra_project/
host is Fedora 27

Most helpful comment

Same issue for me.

All 6 comments

Same issue for me.

Same issue for me.

Any plans on addressing this issue or should it be closed and we can work around it?

I had the same issue and it was caused by me having symlinks in my project directory. You can do

cd `pwd -P`

to resolve all symlinks and then do cobra add|init ...

I'd say that this PR does not apply anymore, because of #817 (see also #904). @galileo-pkm, @dbrimley, @XiaoyeFang, @jmvbxx, could try the latest master?

@dimitarvdimitrov, could you please provide some context? Which is the structure of the directory where you did need to execute pwd -P for cobra init to work?

@jharshman, should this be closed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rogercoll picture rogercoll  路  5Comments

eine picture eine  路  5Comments

anentropic picture anentropic  路  4Comments

phanirithvij picture phanirithvij  路  5Comments

jjzcru picture jjzcru  路  3Comments