Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Go with fish fish shell - error when running `go install /path/to/src`

Tags:

I am following the "How to Write Code" portion of the golang docs, here. I am also using fish fish shell.

I have followed the tutorial and set the proper environment variables (GOPATH and PATH) but I can't get the command go install github.com/user/hello to work with my installation.
I am getting an error:

can't load package: package github.com/user/hello: import "github.com/user/hello": cannot find package

like image 719
codysehl Avatar asked Aug 28 '13 03:08

codysehl


People also ask

How do you set the path on a fish shell?

It does this by adding the components either to $fish_user_paths or directly to $PATH (if the --path switch is given). It is (by default) safe to use fish_add_path in config. fish, or it can be used once, interactively, and the paths will stay in future because of universal variables.

How do you get off the fish path?

At least by default, PATH is a global variable, which means it is per-session. That means to change something from $PATH, either remove it from where it is added (which is likely outside of fish since it inherits it), or put the set -e call in your ~/. config/fish/config. fish so it will be executed on every start.

How do I run a fish shell script?

To be able to run fish scripts from your terminal, you have to do two things. Add the following shebang line to the top of your script file: #!/usr/bin/env fish . Mark the file as executable using the following command: chmod +x <YOUR_FISH_SCRIPT_FILENAME> .

How do you make a fish Shell default?

If you wish to use fish (or any other shell) as your default shell, you need to enter your new shell's executable /usr/local/bin/fish in two places: add /usr/local/bin/fish to /etc/shells. change your default shell with chsh -s to /usr/local/bin/fish.


1 Answers

I had, in fact, incorrectly set my environment variables. Specifically, when setting GOPATH in my ~/.config/fish/config.fish file I needed to export the variable.

Put these lines in your config.fish for fish shell to use Go:
set -x GOPATH $HOME/path/to/your/workspace

Note the -x. That was what was missing.

like image 88
codysehl Avatar answered Sep 20 '22 12:09

codysehl