Closed DisposaBoy closed 11 years ago
I changed dev machines, so I did a fresh install of GoSulime today. GoSublime did not automatically install MarGo for me.
Possibly helpful: I'm Ubuntu 12.04, with golang installed from deb. I've set up my go environment as described on http://golang.org/doc/code.html . This means that my .bashrc has this:
export GOPATH=$HOME/mygo export PATH=$PATH:$HOME/mygo/bin
However, I had not adjusted the PATH of GoSublime to reflect this.
After installing MarGo on the command line and configuring the PATH for GoSublime, everything worked fine.
it doesn't install it automatically. unless you're using an old version, you shouldn't been prompted about GoSublime being updated with a couple options to view the changelog and another to install/update gocode and margo. the latter, simply runs go get -u
and you can see the output including any errors. the problem with environment variables is a gui problem and i've long given up on even trying to do anything about it. GS will add GOROOT/bin and each entry of GOPATH/bin to PATH to make things easier. in the future i will add the reasonable directories like C:\Go\bin on windows /usr/bin, ~/bin ~/go/bin etc. so hopefully eventually noone will need to know there was a problem in the first place
I installed MarGo by hand from the command line, and have export GOPATH=/usr/local/go in my .zshrc but GsDepends is still saying it can't find MarGo on startup of Sublime Text, and that GOPATH and/or GOROOT are unset. This is on OS X. I know you were saying the environment variables is a gui problem, but I wasn't sure if that was specifically an Ubuntu problem or larger than that. Any idea what I'm doing wrong with the PATH variables?
Thanks!
Edited to add: Nevermind, I found out how to add PATH items to the GoSublime config files themselves.
It appears to be a *nix GUI environment thing. The easiest thing to do is to set GOPATH and GOROOT in your User/GoSublime.json file e.g
"env": {
"GOPATH": "/GOPATH1:GOPATH2",
"GOROOT": "/GOROOT"
},
GOROOT/bin and GOPATH*/bin are automatically added to $PATH
so only those two should be necessary
From https://groups.google.com/d/msg/golang-nuts/uCYRUxjWkqs/XXwQfOHdN10J
I've installed GoSublime via Package Control and then MarGo (gocode already present for vim), but each time ST2 starts it tells me GoSublime update to r12.06.17-1 with an option to go get the already up-to-date dependencies. How do I quieten this?
Follow up:
OK, likely cause is that gocode is installed system-wide and so go get -u gocode failed, so I did go got MarGo and gocode via ST2 as root. Running ST2 as root doesn't complain. Obviously, my user instance isn't aware of the system wide update status.
Removing the system-wide install of gocode as a (hopefully) temporary work around and allowing GoSublime to install it fixes the problem.
@kortschak, that's strange. it it perhaps unable to access gocode? maybe it's in a path that your user can't see or it has no permission to access it. pressing ctrl+dot,ctrl+b will open the gsshell where you can type commands. maybe try running gocode -h
directly and seeing what the contents of echo $PATH
and env | grep ^GO
are
Having fixed it with the work around above, and reverting to what I had that demonstrated the problem, I can't replicate it. Sorry - put it down to something I did previously. Thanks.
I had problems with git not being in the PATH, so go get
couldn't find it. There's a popup to tell you that gocode and MarGo are missing, but it disappears before you can copy it down the repo paths manually. Can this be made to stay up, or the manual go get
commands be added as a fallback to the installation instructions?
Where does the error output from the GoSublime: Install ~
stuff get sent?
If the installation of MarGo/Gocode fails, the options sometimes disappears from package control. It's possible the installation check isn't right.
I can't make it stay up unless I repeatedly open it and that is just too obnoxious. There is an option in the command palette off go files to run it install manually. I can add the instructions but it seems pointless especially considering you're likely going to need to run it frequently. If the automated run doesn't work then something is wrong and needs to be fixed unless you don't plan to update GoSublime. All errors apart from those in GsShell and a few places where it doesn't make sense are duplicated in the console.
I'm not sure what you mean by options. do you mean the command palette entry to install/update margo & gocode ? if so, that only shows up in .go files . this applies to all options except the few that can break functionality if GS is disabled
Cheers DisposaBoy, you're correct on all points. Thanks for the great work! For anyone else unfamiliar with git on Windows: http://superuser.com/a/444533/15896.
I can't get MarGo and gocode to install though GoSublime it gives me an error, I have the 64-bit version of Go v1 for OSX installed at /usr/local/go so the go exec is at /usr/local/go/bin/go. I tried in the GoSublime settings env to set PATH and GOPATH: "/usr/local/go/bin/" but this didn't work I'm not sure what else to do.
@Niessy, what's the error
When I'm typing something I get GsDepends or GsComplete: cannot find directory or file MarGo/gocode [Errno 2], when I install MarGo and gocode via GoSublime it gives me a similar error.
@Niessy,
ctrl+dot
,ctrl+b
and type env | grep ^GO
env
setting (copy-paste)No files get created when I try install MarGo and gocode via GoSublime, I am supposed to manually install them then is what your saying?
My env was env = { "PATH" : "usr/local/go/bin" }
that env setting doesn't include a GOPATH and you didn't tell me what the value of GOPATH is, as seen from within GS so can only assume it's not set and possibly neither is GOROOT. In addition to that your PATH is wrong in two ways.
you probably want to add your GOPATH and maybe GOROOT and not touch the PATH variable e.g
"env": { "GOROOT": "/usr/local/go", "GOPATH": "$HOME/go" }
the PATH will be updated to include GOROOT/bin and GOPATH*/bin
I am having trouble getting this all to work as well.
I am on a Mac and my installation of Go was done through the official package. My go env is such:
GOROOT="/usr/local/go"
GOBIN="/usr/local/go/bin"
GOARCH="amd64"
GOCHAR="6"
GOOS="darwin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common"
CGO_ENABLED="1"
My GOPATH is:
$HOME/Projects/go
In my GoSublime user settings, I have:
"env": {
"GOPATH": "$HOME/Projects/go",
"GOROOT": "/usr/local/go"
}
When I attempt to run the installation command, the console spits this at me:
** GsDepends: Installing/updating gocode and MarGo... done
github.com/nsf/gocode (download)
# cd /usr/local/go/src/pkg/github.com/nsf/gocode; git fetch
error: cannot open .git/FETCH_HEAD: Permission denied
package github.com/nsf/gocode: exit status 255
github.com/DisposaBoy/MarGo (download)
**
I am assuming the gocode fetch fails because super user privileges are required at that point. I've installed gocode manually and verified that it is in the same location as above.
MarGo is successfully downloaded to $HOME/Projects/go/src/github.com/DisposaBoy/MarGo but it doesn't seem to matter? Whenever I start Sublime, I get the error:
starting gocode
starting margo
** GsDepends: Error while running MarGo: [Errno 2] No such file or directory **
"MarGo" as an executable of some sort does not seem to exist on my system at this point.
I hope I've provided all the information necessary to help me get this running! I really want to get it working! :)
Please let me know if you need more information. And thank you very much for putting this together! I can't wait to have it working!!
@tylerb
it's hard to know what the actual env vars are so I usually ask people to check env | grep ^GO
from within GS because that way I can know what GS is actually seeing. from that output I assume you typed go env
somewhere which isn't as helpful because it contains hard-coded values. from the error message I can see that you probably installed gocode as root at some point which now prevents you from updating it as a regular user and because that update fails, MarGo is never installed. I'd recommend you delete the existing gocode repo so go get
doesn't try to update it and then run the install again. since the files for MarGo exist in your GOPATH I expect that it's pefectly writable by your user and providing gocode installs fine this time round you should end up with two new binaries: $HOME/Projects/go/{gocode,MarGo}
@DisposaBoy I managed to get it to work, thanks @tylerb I reinstalled gosublime set the env like you did except GOPATH was different of course.
MY GOPATH is currently $HOME/Desktop/work/ if I move the the contents of the bin and src directories in my GOPATH to my GOROOT /usr/local/go/bin/ and /usr/local/go/src/ respectively and change my GOPATH to /usr/local/go/ will I then be able to edit files in any directory instead of just GOPATH?
@Niessy, no don't do that. never set GOPATH to include GOROOT, it's just asking for trouble. GOROOT should never be touched, it's intended to be very much a static location where the distributed go files live. if you want your files to be in two separate directories then just add them to GOPATH (it's very much like the PATH variable, a set of directories separated by a colon on Linux and OS X) see: http://golang.org/cmd/go/#GOPATH_environment_variable
I should probably also mention not to set GOBIN
@Niessy
will I then be able to edit files in any directory instead of just GOPATH?
you can edit files anywhere in your filesystem, even without saving them. not everything supports unsaved files yet but you probably won't even notice. the restrictions on the file's location with regards to GOPATH are a requirement of the go
command and only affects multi-file packages and go install
it doesn't affect go build
nor go run
...
actually I'm not sure it even affects anything locally because I just did a go install
in /tmp and it installs the binary in the current directory
@DisposaBoy Ok Thanks I'm glad I asked and didn't go for the just see what happens approach.
@DisposaBoy that worked! Thank you!
It seems the install process was attempting to update my previous install of gocode rather than install it somewhere it had access. I didn't know it would do that. Everything seems to be running perfectly and my go coding experience just became significantly better. Thank you very much for putting all this together!!
Having trouble with Gocode and Margo install on win7 x64 My go env:
File STDIN: set GOROOT=C:\Go set GOBIN= set GOARCH=amd64 set GOCHAR=6 set GOOS=windows set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GOGCCFLAGS=-g -O2 -m64 -mthreads set CGO_ENABLED=1
User setting is clear. Please help with it, i really don't know what to do ;(
@iGeTT,
ctrl+\``or
ctrl+'`)GOROOT
and GOPATH
as seen by GS, you can see these by doing env | grep ^GO
inside gsshel ( ctrl+dot
,ctrl+b
) or in the python console with import gscommon; gscommon.env().get('GOROOT'); gscommon.env().get('GOPATH')
User setting is clear.
starting gocode starting margo *\* 2012-07-22 17:48:39.910000 **: GsDepends: Error while running MarGo: [Error 2]
>>> import gscommon; gscommon.env().get('GOROOT'); gscommon.env().get('GOPATH') 'C:\Go\'
You don't seem to have GOPAT set. Either set it an env var or add it to your GS settings file
Packages/User/GoSublime.sublime-settings
or via the menu Preferences > Package Settings > GoSublime > Settings - User
{
"env": {
"GOPATH": "YOUR_GOPATH_HERE"
}
}
after that install gocode and margo with ctrl+dot
,ctrl+dot
and typing install (the exact entry in the command palette is GoSublime: Install/Update MarGo and Gocode
)
Everything is working now, thx a lot :)
Just fyi, when doing a Package Control upgrade of GoSublime from a previous version, the option GoSublime: Install/Update Margo and Gocode
was not available. I did an unintall/reinstall of GoSublime to get it to show up. Something must've been broken with the upgrade mechanism, because I also saw gotype still in the shipped GoSublime.sublime-settings, but it is up-to-date now.
Of note, I needed to setup GoSublime's PATH env before running the install (not clear in the README).
"PATH": "$HOME/Development/go/golang/bin:$PATH"
I was having trouble with code completion, where it was working for fmt
but saying "No available completion" for mgo
. This persisted even after adding my GOPATH to the env settings:
"GOPATH": "$HOME/Development/go/vendor:$HOME/Development/go/lib"
But after removing & reinstalling margo/gocode with that ENV setting in place, it is now working.
Gslint isn't working yet. Not sure why.
Fyi, using go version 1.0.2 (installed via hg), and Sublime Text 2.0.1 on Mountain Lion.
Hm. Maybe GsLint is working, it's just catching dumb syntax errors, and not the things gotype caught, like this type is undefined. Is that it?
GsLint currently only supports syntax check
Use Ubuntu 12.04, install SublimeText2(ok), install Sublime Package Control (ok), install GoSublime (ok). Run editor, press ctrl-shift P, run GoSublime: Install/Update MarGo and Gocode, and in console show error: GsDepends: Traceback (most recent call last): File "./gsq.py", line 21, in run File "./gsdepends.py", line 83, in f File "./gsdepends.py", line 33, in call_cmd File "./gscommon.py", line 126, in runcmd UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 10: ordinal not in range(128)
How to fix?
@sashanv, sorry I can't reproduce that one. What code is on line 126 of Packages/GoSublime/gscommon.py
? also, do you have some non-english letters in your GOROOT or GOPATH ? I can't imagine where that is coming from or why.
what happens/what's the output of calling gocode close
from the command line
I've tried the suggestions here, but am also getting the "\ GsDepends: Error while running MarGo: [Errno 2] No such file or directory **" error -- I am on 64-bit OSX Lion, running 64-bit ST2. cmd-dot,cmd-b go env yields:
GOROOT="/usr/local/go" GOBIN="" GOARCH="amd64" GOCHAR="6" GOOS="darwin" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common" CGO_ENABLED="1" [Finished in 0.1s]
and in my settings I have
{ "env": { "GOPATH": "/Users/my-user-id/Projects/go", "GOROOT": "/usr/local/go" } }
When I try the "update/install margo" command it creates the folders for Projects/go/src/github.com/DisposaBoy and Projects/go/src/github.com/nsf, but with no source files, and (obviously) no bin directory... so presumably something about the git fetch and/or go-get is botched, but not sure what. Suggestions welcomed.
UPDATE MINUTES LATERS: if I manually do "go get github.com/DisposaBoy/GoSublime" in bash, all is well. So presumably something about the path to go in my ST2 settings is botched...
I'm running Sublime with GoSublime on Mac OS X Lion and I've notice that if I start sublime through the Command+Space Spotlight search, none of the correct environment variables are passed to Sublime so it's unable to locate the 'go' binary and doesn't receive the GOPATH variable. This in turn causes MarGo and gocode to fail installation through GoSublime.
But if I start Sublime text from within a bash shell using a symbolic link as described at http://www.sublimetext.com/docs/2/osx_command_line.html then Sublime will actually receive all the correct environment variables and GoSublime will locate the 'go' binary and install MarGo/gocode without issue.
So launching Sublime from within a bash shell seems to make GoSublime work perfectly. I'm assuming it's because it properly receives the environment variables from your .bashrc when launched in this manner.
I have a problem with MarGo and GoCode on Windows 7. I try to install them through GoSublime:Install\Update Margo and GoCode but
My env is:
set GOROOT=C:\Go set GOBIN= set GOARCH=amd64 set GOCHAR=6 set GOOS=windows set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GOGCCFLAGS=-g -O2 -m64 -mthreads set CGO_ENABLED=1
I have this code:
package main
import "fmt"
func main() { fmt.Println("aasa") }
When I type fmt. I don't get any methods I can use.
@krussell Same thing happened for me. Logging out and logging in again might fix it (I didn't try yet, but I did notice that on the other computer where I've been using it for a week it stopped being a problem and I don't think I use subl to start Sublime every time ...)
I don't know what the go installer is doing on OS X Lion, but from Terminal I can see it in PATH
, nothing else appears to be set however. Setting GOPATH in ~/.launchd.conf
:
setenv GOPATH /a/b/c
makes it appear in ST2 as well as Termina so I assume that's likely the best place to set environment variables on OS X.
@abh, if it just magically fixed itself and you're using GS through package control where you get automatic updates, it's likely a side-effect of GS now getting GOROOT from go env
Hi, I installed MarGo and gocode from the command line using go get, and %GOROOT%\bin is in the path.
I keep getting this:
\ 2012-08-30 09:44:55.003000 **: GsDepends Installing/updating gocode and MarGo... done Error while running go: environment can only contain strings
and when doing anything that triggers it to do go fmt or lookup things for autocompletion, it says: \ 2012-08-30 09:44:55.008000 **: GsDepends: Error while running MarGo: environment can only contain strings
Any ideas?
(Oh and, it has worked for a few days before. AFAIK I did not install anything to make it break)
@avisagie, what's your GOROOT ? (continue this discussion on issue #112)
I am having issues with GSDepends and updating\installing MarGo/gocode on win7 x64. At some point about a month ago it was definitely working...
\ 2012-09-03 16:50:15.322000 **:
GsDepends
GoSublime depends on gocode and MarGo
Install gocode, MarGo (using go get
)
gocode repo: github.com/nsf/gocode
MarGo repo: github.com/DisposaBoy/MarGo
\ 2012-09-03 16:50:17.947000 **: GsDepends: Error while running MarGo: [Error 2] The system cannot find the file specified
I have gopath and goroot set:
import gscommon; gscommon.env().get('GOROOT'); gscommon.env().get('GOPATH') 'C:/Go' 'C:/Users/Dustin/Documents/golibs'
Also, I have gocode.exe and MarGo.exe built in the golibs directory, so that bit is all working. I am at a loss to understand which file MarGo cannot find.
@dustinconrad
Try adding the "bin" directory of your GOPATH folder to your system PATH.
'C:/Users/Dustin/Documents/golibs/bin'
This fixed it for me on Windows. It looks like GS can't find and execute MarGo.exe (which gets compiled and placed into the GOPATH/bin directory..).
@irwinb thanks man, that was it.
Typing "package main" on the editor generates. How do I just type "package main" ?
package func main() {
}
Edit: Shift+Enter to make a new line works.
Still a problem with GDepends not updating correctly. I uninstalled GoSublime and removed all traces of gocode and MarGo.
Used package control to install GoSublime. Then updated the GoSublime user settings to: { "env": { "GOPATH": "C:\DevBin\Go\ext", "GOROOT": "C:\DevBin\Go", "GOOS": "windows" } }
Closed and restarted ST2 (just out of an abundance of caution) and loaded a .go file to edit. Got and accepted the prompt to install/update gcode & MarGo. . . This is the output from the ST2 console:
\ 2012-10-07 15:27:54.025000 **:
GoSublime: checking dependencies
GOROOT is: C:\DevBin\Go
GOPATH is: C:\DevBin\Go\ext
----------------------------------------
\ 2012-10-07 15:27:54.122000 **:
GsDepends
GoSublime depends on gocode and MarGo
Install gocode, MarGo (using go get
)
gocode repo: github.com/nsf/gocode
MarGo repo: github.com/DisposaBoy/MarGo
----------------------------------------
\ 2012-10-07 15:27:57.468000 **:
GsDepends: Error while running MarGo: [Error 2] The system cannot find the file specified
----------------------------------------
\ 2012-10-07 15:28:23.445000 **:
GsDepends: Installing/updating gocode and MarGo... done
----------------------------------------
\ 2012-10-07 15:28:23.498000 **:
GsDepends
Installing/updating gocode and MarGo... done
github.com\nsf\gocode (download)
github.com\DisposaBoy\MarGo (download)
----------------------------------------
\ 2012-10-07 15:28:23.626000 **:
GsDepends: Error while running MarGo: [Error 2] The system cannot find the file specified
----------------------------------------
And here is ST2's view of the environment:
>>>
import gscommon; gscommon.env().get('GOROOT'); gscommon.env().get('GOPATH'); gscommon.env().get('PATH')
'C:\DevBin\Go'
'C:\DevBin\Go\ext'
'C:\Users\Gbr\AppData\Roaming\Sublime Text 2\Packages\User\GoSublime\9\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Python;C:\Program Files\Python\Lib\site-packages;C:\Program Files\Python\Scripts;C:\Program Files\Tools\GnuWin32\bin;C:\Program Files\Tools\Git\cmd;C:\DevBin\Go\bin;C:\DevBin\Go\ext\bin;C:\Go\bin'
The first directory in the path (...GoSublime\9\bin) does not exist. Also, the last (C:\Go\bin) also does not exist -- looks like a default path, but my Go installation is rooted at C:/DevBin/Go.
Newly compiled copies of gocode.exe and MarGo.exe are present in C:\DevBin\Go\ext\bin
Seems the gscommon environment is not being used to find and run MarGo?
Use Ubuntu 12.04, install SublimeText2(ok), install Sublime Package Control (ok), install GoSublime (ok), MarGo and Gocode (ok), open file with script "Hello world", press key for Run, and in console show error:
Traceback (most recent call last):
File "./gsshell.py", line 117, in
how fix ?
@sashanv, what's in this file. also, make sure you're up-to-date, those error lines doesn't seem to make any sense based on the latest gsshell.py file
In file: package main
import "fmt"
func main() { fmt.Println("Hello world!") }
i open many files, always this error on try run.
P.S. To solve my problem: https://github.com/DisposaBoy/GoSublime/issues/44#issuecomment-7375919 need istall git-core before install gosublime.
@sashanv, this isn't an issue I can reproduce. I'm guessing that somewhere, likely in the env vars there's characters that are not latin/english (char 208). In which case, my only suggestion is to try ctrl+shift+p
and type activate gscommander with the file open. when you get the command prompt, type 9 play
and press enter. if that works then i'll make it live
try, on console show:
[ 9 play ] ⌛ [ /home/user/goprj/hello ] #
and in status bar all the time spinning semicircle.
In linux console type "env" and look, not see not latin/english char.
An issue to track the dependency and integration of MarGo and Gocode in GS