vim-gocode icon indicating copy to clipboard operation
vim-gocode copied to clipboard

Installation on OS X

Open jaytaylor opened this issue 10 years ago • 35 comments

The install lists pathogen as "todo". Is it not yet ready?

When I try to run :CurPkg, I get:

You are not in a go package

jaytaylor avatar Sep 03 '13 00:09 jaytaylor

You successfully installed vim-gocode through pathogen, it seems to be a bug at first sight. Can you run the command

:echo ReadLink(g:gocode_path)

And then

:echo ReadLink(@%)

And tell me the output?

volgar1x avatar Sep 03 '13 04:09 volgar1x

:echo ReadLink(g:gocode_path)

E121: Undefined variable: g:gocode_path E116: Invalid arguments for function ReadLink(g:gocode_path) E15: Invalid expression: ReadLink(g:gocode_path)

:echo ReadLink(@%)

readlink: illegal option -- f usage: readlink [-n] [file ...]

Other miscellaneous info: this is on a MacBook Air with a fresh install of OS-X 10.8.4 and a case-sensitive filesystem.

jaytaylor avatar Sep 03 '13 05:09 jaytaylor

I haven't tested this plugin on other system than Linux. Could you please edit the ReadLink function inside vim-gocode/ftplugin/go/pkg.vim to make it works (ie get the full path) on your OS ? Other question : have you installed Go? VIM can't echo any g:gocode_path variable which is a sign that 'go env GOPATH' didn't work.

volgar1x avatar Sep 03 '13 06:09 volgar1x

I will update the readlink fn. go is definitely installed with good GOPATH and GOROOT env vars.

Hopefully together we can get this to be compatible with Mac.

Best, Jay

On Sep 2, 2013, at 11:15 PM, Blackrush [email protected] wrote:

I haven't tested this plugin on other system than Linux. Could you please edit the ReadLink function inside vim-gocode/ftplugin/go/pkg.vim to make it works (ie get the full path) on your OS ? Other question : have you installed Go? VIM can't echo any g:gocode_path variable which is a sign that 'go env GOPATH' didn't work.

— Reply to this email directly or view it on GitHub.

jaytaylor avatar Sep 03 '13 06:09 jaytaylor

I found a good starting point to use readlink on OS X : http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac

volgar1x avatar Sep 03 '13 06:09 volgar1x

Might I recommend making a note that it currently doesn't work on osx? Spent a while beating myself over the head until I checked the issues.

macb avatar Sep 12 '13 04:09 macb

Also, as a solution for future mac users:

brew install coreutils ln /usr/local/bin/greadlink /usr/local/bin/readlink

maybe re-source profile. (I had to get which readlink to return the correct path)

macb avatar Sep 12 '13 04:09 macb

@seanbr nice job, gave a solution an hour before I went looking for it!

JohnAmican avatar Sep 12 '13 05:09 JohnAmican

Also FYI things start breaking if there are spaces in folder names. I'll open up an issue about it later.

JohnAmican avatar Sep 12 '13 05:09 JohnAmican

I renamed this issue "Installation on OS X", created a wiki article and linked it in the README. Tell me if I have done anything wrong.

volgar1x avatar Sep 12 '13 09:09 volgar1x

I get the same You are not in a go package error on both OS X and ubuntu 13.

oguzbilgic avatar Sep 17 '13 14:09 oguzbilgic

Can you please execute the commands that I previously wrote?

volgar1x avatar Sep 17 '13 16:09 volgar1x

I'm having the same issue, already executed both commands and no luck.

bilby91 avatar Sep 28 '13 04:09 bilby91

What is exactly the output ?

volgar1x avatar Sep 28 '13 07:09 volgar1x

:echo ReadLink(g:gocode_path)

E121: Undefined variable: g:gocode_path
E116: Invalid arguments for function ReadLink(g:gocode_path)
E15: Invalid expression: ReadLink(g:gocode_path) 

:echo ReadLink(@%)

readlink: illegal option -- f
usage: readlink [-n] [file ...] 

bilby91 avatar Sep 28 '13 15:09 bilby91

Have you install coreutils and make the greadlink redirection to readlink ?

volgar1x avatar Sep 28 '13 15:09 volgar1x

Yes, installed coreutils through brew and made the symlink.

bilby91 avatar Sep 28 '13 15:09 bilby91

Try readlink -f . in a Terminal and tell me the output

volgar1x avatar Sep 28 '13 16:09 volgar1x

Same output

readlink: illegal option -- f
usage: readlink [-n] [file ...] 

bilby91 avatar Sep 28 '13 16:09 bilby91

vim-gocode needs some OS X integration, wait until someone patch this problem or make it yourself (I don't own a Mac)

volgar1x avatar Sep 28 '13 16:09 volgar1x

Can your provide me any orientation on where the issue could be.

Thanks for the help either way!

bilby91 avatar Sep 28 '13 16:09 bilby91

You can look here https://github.com/Blackrush/vim-gocode/blob/master/ftplugin/go/pkg.vim#L10 as a first step

volgar1x avatar Sep 28 '13 18:09 volgar1x

what is the output of:

which brew which readlink

It seems to me that you are using osx's readlink still. I've installed vim-gocode 3 times now on seperate OSX installs and after doing the 'brew install coreutils' and linking greadlink into my path (ahead of osx readlink) it's been perfect.

My guess is your brew bin path (most likely /usr/local/bin) is at the end of your path.

macb avatar Sep 29 '13 01:09 macb

which brew
/usr/local/bin/brew

which readlink
/usr/bin/readlink

bilby91 avatar Sep 29 '13 04:09 bilby91

Yep, that's your issue. You need to make sure your home brew path /usr/local/bin is the first entry into your path. This way anything that replaces an osx default will be used instead of the osx one.

Do this by editing your bash profile, bash rc, or system profile to something that contains:

export PATH=/usr/local/bin:$PATH

macb avatar Sep 29 '13 17:09 macb

I changed my .zshrc file to fix the problem with the order of paths. Now my output is correct.

which readlink
/usr/local/bin/readlink

I'm still having the same issue. Can it be an issue with my GOPATH being setup'd incorrectly? It seems correct to me.

bilby91 avatar Sep 29 '13 21:09 bilby91

What does output, in VIM, :!go env GOPATH ?

volgar1x avatar Sep 30 '13 07:09 volgar1x

It shows me the correct GOPATH.

bilby91 avatar Sep 30 '13 14:09 bilby91

I solved the problem by installing brew install coreutils and replacing readlink -f with greadlink -f in -> https://github.com/Blackrush/vim-gocode/blob/master/ftplugin/go/pkg.vim#L10

Previously I tried ln -s /usr/local/bin/greadlink /usr/local/bin/readlink but it didn't worked for me.

ghost avatar Nov 06 '13 09:11 ghost

does function ReadLink has to be edited to include OS specific behavior ?

volgar1x avatar Nov 06 '13 11:11 volgar1x