Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The cobra generator can't add commands when a project is accessed via a symlink #612

Closed
mikolysz opened this issue Jan 14, 2018 · 0 comments
Labels
area/cobra-command Core `cobra.Command` implementations kind/bug A bug in cobra; unintended behavior

Comments

@mikolysz
Copy link

mikolysz commented Jan 14, 2018

Overview:

When your working directory is set to a project directory but the path contains a symlink, cobra add complains that your project isn't in the gopath even though it really is.

steps to reproduce:

vagrant@vagrant-ubuntu-trusty-64:~$ cobra init github.com/miki123211/symlinks
Your Cobra application is ready at
/vagrant/go/src/github.com/miki123211/symlinks.

Give it a try by going there and running `go run main.go`.
Add commands to it by running `cobra add [cmdname]`.
vagrant@vagrant-ubuntu-trusty-64:~$ cd /vagrant/go/src/github.com/miki123211/sy
mlinks/
vagrant@vagrant-ubuntu-trusty-64:/vagrant/go/src/github.com/miki123211/symlinks
$ cobra add thisWorks
thisWorks created at /vagrant/go/src/github.com/miki123211/symlinks/cmd/thisWork
s.go
vagrant@vagrant-ubuntu-trusty-64:/vagrant/go/src/github.com/miki123211/symlinks
$ ln -s . ~/proj
vagrant@vagrant-ubuntu-trusty-64:/vagrant/go/src/github.com/miki123211/symlinks
$ cd ~/proj
vagrant@vagrant-ubuntu-trusty-64:~/proj$ cobra add thisshouldWorkButItDoesNot
Error: Cobra supports project only within $GOPATH: Rel: can't make /home/vagrant
/proj relative to
vagrant@vagrant-ubuntu-trusty-64:~/proj$

Expected output:

thisShouldWorkButItDoesNot created at /vagrant/go/src/github.com/miki123211/symlinks/cmd/thisShouldWorkButItDoesNot.go
@n10v n10v added kind/bug A bug in cobra; unintended behavior area/cobra-command Core `cobra.Command` implementations labels Jan 14, 2018
n10v added a commit to n10v/cobra that referenced this issue Jan 15, 2018
If user has a project in symlink, just use its destination folder and
work there.
@n10v n10v closed this as completed in 0c34d16 Jan 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cobra-command Core `cobra.Command` implementations kind/bug A bug in cobra; unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants