Build XK6 Extension from local storage downloaded from git

There was a similar Post: I need to build k6 with an extension in Local

which got me further. Okay the problem here is that we work on a citrix server that won’t let us install anything from a git-link, at least via command line that comes from github. Now we assume we can just download the repos and install them locally. But whenever I try this it will tell me that the replacment directory does not exist (whatever that means), maybe I missunderstood the other Post and they meant to do something completely different.

So I try this:
C:\Program Files\k6>xk6 build v0.29.0 --with github.com/imiric/xk6-sql="/users/m.kleiner/downloads/xk6-sql-master"

but it returns me this:

2022/07/04 15:47:12 [INFO] Temporary folder: C:\Users\M7C22~1.KLE\AppData\Local\Temp\6\buildenv_2022-07-04-1547.901453775
2022/07/04 15:47:12 [INFO] Initializing Go module
2022/07/04 15:47:12 [INFO] exec (timeout=10s): C:\Program Files\Go\bin\go.exe mod init k6
go: creating new go.mod: module k6
2022/07/04 15:47:12 [INFO] Replace github.com/imiric/xk6-sql => /users/m.kleiner/downloads/xk6-sql-master
2022/07/04 15:47:12 [INFO] exec (timeout=0s): C:\Program Files\Go\bin\go.exe mod edit -replace github.com/imiric/xk6-sql=/users/m.kleiner/downloads/xk6-sql-master
2022/07/04 15:47:12 [INFO] exec (timeout=0s): C:\Program Files\Go\bin\go.exe mod tidy -compat=1.17
go: warning: "all" matched no packages
2022/07/04 15:47:12 [INFO] Pinning versions
2022/07/04 15:47:12 [INFO] exec (timeout=0s): C:\Program Files\Go\bin\go.exe mod tidy -compat=1.17
k6 imports
        github.com/imiric/xk6-sql: github.com/imiric/xk6-sql@v0.0.0-00010101000000-000000000000: replacement directory /users/m.kleiner/downloads/xk6-sql-master does not exist
2022/07/04 15:47:12 [INFO] Cleaning up temporary folder: C:\Users\M7C22~1.KLE\AppData\Local\Temp\6\buildenv_2022-07-04-1547.901453775
2022/07/04 15:47:12 [FATAL] exit status 1

Blockquote

Hi Maxi

For what I can tell, this is a windows machine, right? I’m curious if the path to your local extension (that is, where you cloned the repo) is actually /users/m.kleiner/downloads/xk6-sql-master because that is what the build is complaining about.

Okay I was under the impression that I also tried it with “C:\Users\m.kleiner\Downloads\xk6-sql-master” but I didn’t, I now tried it with it and the “C:\Users\m.kleiner\Downloads\xk6-sql-master.zip”

In the original folder I had it, it wouldn’t load with the full link but I that was probably because of administrational reason and I forget to retry it with this location.

But the program still got trouble because of some github links it is trying to download. So how do I best work around those things? I might be able to download them all separately but it would probably not install the extension properly. Is there some file where I can exclude the automatic import of those files?

Also sorry if some output is in German. the Phrase: “Dies ist normalerweise ein zeitweiliger Fehler bei der Auflösung von Hostnamen. Grund ist, dass der lokale Server keine Rückmeldung vom autorisierenden Server erhalten hat.”
roughly translates to: “that is normally a temporarely error with the resolution of the hostname. Reason is that the local server doesn’t got feedback from the authorizing server.”

C:\Program Files\k6>xk6 build v0.29.0   --with github.com/imiric/xk6-sql="C:\Users\m.kleiner\Downloads\xk6-sql-master"
2022/07/05 10:02:28 [INFO] Temporary folder: C:\Users\M7C22~1.KLE\AppData\Local\Temp\6\buildenv_2022-07-05-1002.990468239
2022/07/05 10:02:28 [INFO] Initializing Go module
2022/07/05 10:02:28 [INFO] exec (timeout=10s): C:\Program Files\Go\bin\go.exe mod init k6
go: creating new go.mod: module k6
2022/07/05 10:02:28 [INFO] Replace github.com/imiric/xk6-sql => C:\Users\m.kleiner\Downloads\xk6-sql-master
2022/07/05 10:02:28 [INFO] exec (timeout=0s): C:\Program Files\Go\bin\go.exe mod edit -replace github.com/imiric/xk6-sql=C:\Users\m.kleiner\Downloads\xk6-sql-master
2022/07/05 10:02:28 [INFO] exec (timeout=0s): C:\Program Files\Go\bin\go.exe mod tidy -compat=1.17
go: warning: "all" matched no packages
2022/07/05 10:02:28 [INFO] Pinning versions
2022/07/05 10:02:28 [INFO] exec (timeout=0s): C:\Program Files\Go\bin\go.exe mod tidy -compat=1.17
go: found github.com/imiric/xk6-sql in github.com/imiric/xk6-sql v0.0.0-00010101000000-000000000000
go: downloading github.com/go-sql-driver/mysql v1.6.0
go: downloading github.com/denisenkom/go-mssqldb v0.12.0
go: downloading github.com/lib/pq v1.10.4
go: downloading github.com/mattn/go-sqlite3 v1.14.12
go: downloading go.k6.io/k6 v0.38.0
k6 imports
        github.com/imiric/xk6-sql imports
        github.com/denisenkom/go-mssqldb: github.com/denisenkom/go-mssqldb@v0.12.0: Get "https://proxy.golang.org/github.com/denisenkom/go-mssqldb/@v/v0.12.0.zip": dial tcp: lookup proxy.golang.org: getaddrinfow: Dies ist normalerweise ein zeitweiliger Fehler bei der Auflösung von Hostnamen. Grund ist, dass der lokale Server keine Rückmeldung vom autorisierenden Server erhalten hat.
k6 imports
        github.com/imiric/xk6-sql imports
        github.com/go-sql-driver/mysql: github.com/go-sql-driver/mysql@v1.6.0: Get "https://proxy.golang.org/github.com/go-sql-driver/mysql/@v/v1.6.0.zip": dial tcp: lookup proxy.golang.org: getaddrinfow: Dies ist normalerweise ein zeitweiliger Fehler bei der Auflösung von Hostnamen. Grund ist, dass der lokale Server keine Rückmeldung vom autorisierenden Server erhalten hat.
k6 imports
        github.com/imiric/xk6-sql imports
        github.com/lib/pq: github.com/lib/pq@v1.10.4: Get "https://proxy.golang.org/github.com/lib/pq/@v/v1.10.4.zip": dial tcp: lookup proxy.golang.org: getaddrinfow: Dies ist normalerweise ein zeitweiliger Fehler bei der Auflösung von Hostnamen. Grund ist, dass der lokale Server keine Rückmeldung vom autorisierenden Server erhalten hat.
k6 imports
        github.com/imiric/xk6-sql imports
        github.com/mattn/go-sqlite3: github.com/mattn/go-sqlite3@v1.14.12: Get "https://proxy.golang.org/github.com/mattn/go-sqlite3/@v/v1.14.12.zip": dial tcp: lookup proxy.golang.org: getaddrinfow: Dies ist normalerweise ein zeitweiliger Fehler bei der Auflösung von Hostnamen. Grund ist, dass der lokale Server keine Rückmeldung vom autorisierenden Server erhalten hat.
k6 imports
        github.com/imiric/xk6-sql imports
        go.k6.io/k6/js/modules: go.k6.io/k6@v0.38.0: Get "https://proxy.golang.org/go.k6.io/k6/@v/v0.38.0.zip": dial tcp: lookup proxy.golang.org: getaddrinfow: Dies ist normalerweise ein zeitweiliger Fehler bei der Auflösung von Hostnamen. Grund ist, dass der lokale Server keine Rückmeldung vom autorisierenden Server erhalten hat.
2022/07/05 10:02:52 [INFO] Cleaning up temporary folder: C:\Users\M7C22~1.KLE\AppData\Local\Temp\6\buildenv_2022-07-05-1002.990468239
2022/07/05 10:02:52 [FATAL] exit status 1

I’m afraid there is no easy workaround your issue. What you see is It is not the xk6 build but go trying to install dependencies from github and your citrix server’s policies preventing the download.

The dependencies are listed in the go.mod file. You could download them one by one using some script.

Another work around would be installing a proxy for your dependencies like athens and see if that tricks the citrix server. I used it years ago to avoid downloading dependencies from public repositories in the CI/CD pipeline.

Maybe building your extension outside the citrix server would be easier.

Athens seems like giving the problem an overhead as there is no good description of how to install it. No Seriously I have not the slightest clue how to install it on the server.

I tried setting the proxy for git, but it won’t work. Oh yeah btw. I have a proxy adress that works for every part of the system but go seems to ignore it, and I don’t find any way to set it to use the proxy.

Have you checked the GOPROXY environment variable is set?

First time I’e heard of a goproxy, do you have any recommendations? I read there are several of them. Right now there, of course, is no goproxy environment variable set.

I’m afraid those are golang settings and you must adapt to your environment. For instance, you mentioned you already have a proxy (I’m guessing it is the HTTP_PROXY env variable). But you also mentioned the restrictions enforced by citrix server, which I don’t have any experience with. Hopefully you can find help to your specific setup in other forums.