project-flogo / cli

CLI used to create & build Flogo applications.
BSD 3-Clause "New" or "Revised" License
32 stars 36 forks source link

CLI $GOPATH not resolved properly #107

Open dcsouthwick opened 4 years ago

dcsouthwick commented 4 years ago

Current behavior (how does the issue manifest): Flogo fails to create any and all projects with Centos8 (other OS not yet checked)

Expected behavior: Not that. Anything but that.

Minimal steps to reproduce the problem (not required if feature enhancement): (taken from my initial gitter report)

docker run -it centos:centos8 bash
dnf install golang git
go get -u github.com/project-flogo/cli/...
flogo create new --verbose
Setting up app directory: /root/go/src/new
go: creating new go.mod: module main
Installing: github.com/project-flogo/core@latest
go: finding github.com/project-flogo/core v0.10.1
...
all modules verified
Adding sample flogo.json
Error creating project: open pkg/mod/github.com/project-flogo/core@v0.10.1/examples/engine/main.go: no such file or directory

...profit?

What is the motivation / use case for changing the behavior? To make the core product function.

Please tell us about your environment (Operating system, docker version, browser & verison if webui, etc): As described in the centos8 default docker image.

Flogo version (CLI & contrib/lib. If unknown, leave empty or state unknown): 0.X.X All? Additional information you deem important (e.g. issue happens only occasionally): This issue is a path resolving problem. Flogo clearly has no problem pulling the modules and installing them in $GOPATH/pkg, but when it tries to load them, it appears to load from $GOPATHpkg without a '/'. Flogo should not make whatever assumption it seems to be making at this step.

skothari-tibco commented 4 years ago

Hey, I'm having a tough time recreating the issue. Here's what I did in the container.

dnf install golang git
export GOPATH=/home/lib/go
export PATH=$PATH:$GOPATH/bin
go get -u github.com/project-flogo/cli/...
flogo create newApp --verbose

And it worked just fine.

dcsouthwick commented 4 years ago

Hi there,

Here is a log of my results:

[root@9b0428717427 /]# echo $GOPATH

[root@9b0428717427 /]# go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/golang"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build545544793=/tmp/go-build -gno-record-gcc-switches"
[root@9b0428717427 /]# export PATH=$PATH:/root/go/bin
[root@9b0428717427 /]# flo
flock  flogo
[root@9b0428717427 /]# flogo create new --verbose
Creating Flogo App: new
Setting up app directory: /new
go: creating new go.mod: module main
Installing: github.com/project-flogo/core@latest
go: finding github.com/project-flogo/core v0.10.1
go: finding github.com/stretchr/testify v1.4.0
go: finding github.com/pkg/errors v0.9.1
go: finding github.com/xeipuuv/gojsonschema v1.1.0
go: finding go.uber.org/zap v1.9.1
go: finding go.uber.org/atomic v1.5.1
go: finding go.uber.org/multierr v1.4.0
go: finding github.com/stretchr/objx v0.1.0
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/davecgh/go-spew v1.1.0
go: finding go.uber.org/atomic v1.5.0
go: finding github.com/stretchr/testify v1.3.0
go: finding golang.org/x/lint v0.0.0-20190930215403-16217165b5de
go: finding go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5
go: finding github.com/davecgh/go-spew v1.1.1
go: finding golang.org/x/tools v0.0.0-20190311212946-11955173bddd
go: finding golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c
go: finding honnef.co/go/tools v0.0.1-2019.2.3
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: finding golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac
go: finding github.com/google/renameio v0.1.0
go: finding github.com/rogpeppe/go-internal v1.3.0
go: finding github.com/BurntSushi/toml v0.3.1
go: finding github.com/kisielk/gotool v1.0.0
go: finding golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e
go: finding gopkg.in/errgo.v2 v2.1.0
go: finding golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529
go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
go: finding github.com/kr/pretty v0.1.0
go: finding golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
go: finding golang.org/x/sys v0.0.0-20190412213103-97732733099d
go: finding golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: finding golang.org/x/net v0.0.0-20190311183353-d8887717615a
go: finding github.com/kr/text v0.1.0
go: finding golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
go: finding golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding golang.org/x/text v0.3.0
go: finding github.com/kr/pty v1.1.1
all modules verified
Adding sample flogo.json
Error creating project: open pkg/mod/github.com/project-flogo/core@v0.10.1/examples/engine/main.go: no such file or directory

Does Flogo not use the system default $GOPATH? Your documentation on the matter (https://tibcosoftware.github.io/flogo/getting-started/getting-started-cli/) citing https://golang.org/doc/code.html#GOPATH https://github.com/golang/go/wiki/SettingGOPATH

seems to indicate that this is fine and should work.

dcsouthwick commented 4 years ago

I'm no golang pro, but it seems something like this might be in the way:

package main

import (
    "fmt"
    "go/build"
    "os"
)

func main() {
    gopath := os.Getenv("GOPATH")
    if gopath == "" {
        gopath = build.Default.GOPATH
    }
    fmt.Println(gopath)
}

and finds my $GOPATH just fine, whereas Flogo seems to trust that the user is not using the default

skothari-tibco commented 4 years ago

I looked into it. As a matter of fact we did took that thing into consideration. The only issue go get -u is not getting the latest tag. The latest one is pre-release , which somehow doesn't show up.

dcsouthwick commented 4 years ago

I guess the workaround here is to explicitly set $GOPATH in the user env until the latest release is moved from pre-release, assuming it addresses this problem

skothari-tibco commented 4 years ago

Yes.

mingfang commented 4 years ago

When is the release?

aheissenberger commented 3 years ago

This problem still exists - setting $GOPATHfixed the problem.

MacOS / zsh / golang installed with brew install gland

.zprofile:

export GOROOT="$(brew --prefix golang)/libexec"
export GOPATH="${HOME}/go"
export PATH="$PATH:$GOPATH/bin"