英文:
CompileDaemon "command not found" Not using docker
问题
我之前在我的 Golang 应用程序中成功使用 CompileDaemon,但在我的 WSL Ubuntu 上停止工作了。我尝试了一切方法来使其工作,然后重新安装了 WSL 并切换到 Debian。我没有使用 Docker。然后我再次尝试,即使安装了两种不同的方式,仍然显示命令未找到:
go get github.com/githubnemo/CompileDaemon
go: added github.com/fatih/color v1.9.0
go: added github.com/fsnotify/fsnotify v1.4.9
go: added github.com/githubnemo/CompileDaemon v1.4.0
go: added github.com/mattn/go-colorable v0.1.4
go: added github.com/mattn/go-isatty v0.0.11
go: added github.com/radovskyb/watcher v1.0.7
go: added golang.org/x/sys v0.0.0-20191026070338-33540a1f6037
或者
go install -mod=mod github.com/githubnemo/CompileDaemon
然后当我运行 CompileDaemon --command="./folder_name"
时,
返回:
bash: CompileDaemon: 命令未找到
英文:
I hade CompileDaemon working in my golang app before, but it stopped working on my WSL Ubuntu. I tried everything to get it working, and then reinstalled WSL switching to Debian. I am not using docker. I then tried things again and it still says command not found even after installing it two different ways:
go get github.com/githubnemo/CompileDaemon
go: added github.com/fatih/color v1.9.0
go: added github.com/fsnotify/fsnotify v1.4.9
go: added github.com/githubnemo/CompileDaemon v1.4.0
go: added github.com/mattn/go-colorable v0.1.4
go: added github.com/mattn/go-isatty v0.0.11
go: added github.com/radovskyb/watcher v1.0.7
go: added golang.org/x/sys v0.0.0-20191026070338-33540a1f6037
OR
go install -mod=mod github.com/githubnemo/CompileDaemon
Then when I run CompileDaemon --command="./folder_name"
returns:
bash: CompileDaemon: command not found
答案1
得分: 3
我遇到了同样的问题,以下是我解决的方法。
看起来GOPATH没有按预期添加到环境变量中。
vim ~/.zshrc
...
export GOPATH="$HOME/go" # 设置GOPATH(go安装的路径)
export PATH=$PATH:$GOPATH/bin # 将GOPATH添加到PATH中
不要忘记执行以下命令使修改生效:
source ~/.zshrc
英文:
I face the same issue, here is how I solve it.
It seems that GOPATH is not added to ENVIRONMENT VARIABLE as expected.
vim ~/.zshrc
...
export GOPATH="$HOME/go" # set GOPATH (path to where go is installed)
export PATH=$PATH:$GOPATH/bin # append GOPATH to PATH
don't forget to
source ~/.zshrc
答案2
得分: 0
-
尝试运行
go env GOPATH
来查看你的Go工作区的位置。我的工作区在/root/go
中。 -
然后你可以尝试运行
ls
命令,例如ls /root/go
,看看可执行文件是否在那里。 -
如果不在那里,你可以尝试运行
go install github.com/githubnemo/CompileDaemon
来重新安装它。如果有帮助,请告诉我。 -
最后,在我的情况下运行
GOPATH/bin/CompileDaemon
,即/root/go/bin/CompileDaemon
。
注意:
你可以包含你的标志,例如-command="./directory"
。
你必须在你的go.mod初始化位置或当前模块所在的位置运行该命令。
英文:
-
Try running
go env GOPATH
to see where your Go workspace is located. Mine was in/root/go
-
Then you can try running
ls
the path e.gls /root/go
to see if the executable file is located there. -
If it is not located there, you can try running
go install github.com/githubnemo/CompileDaemon
to install it again. Let me know if that helps. -
Finally run
GOPATH/bin/CompileDaemon
in my own case/root/go/bin/CompileDaemon
.
Note:
You can include your flag e.g -command="./directory"
.
You must be in where you initialize your go.mod or current module for your go program
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论