cosmos72 / gomacro

Interactive Go interpreter and debugger with REPL, Eval, generics and Lisp-like macros
Mozilla Public License 2.0
2.18k stars 94 forks source link

Having issues with third party packages and go1.16.3 #109

Closed snowzach closed 3 years ago

snowzach commented 3 years ago

I am using this via https://github.com/gopherdata/gophernotes and I am still having issues importing 3rd party packages. I got it to work sometimes but only when it decided to go through the compiling step. If I just use a simple script like

import "github.com/davecgh/go-spew/spew"
spew.Dump("test")

I can see it downloading in the console and then it returns

error loading package "github.com/davecgh/go-spew/spew" metadata: packages.Load() could not find package "github.com/davecgh/go-spew/spew"

I got it to work once or twice when the console showed a "compiling" stage but I can't reliably get it to do that. I think something might be off still.

cosmos72 commented 3 years ago

Hi @snowzach, which version of gophernotes are you using, and which version fo Go toolchain did you use to compile it?

It should be fixed in the latest version (0.7.3) if modules support is enabled (it's enabled by default if gophernotes/gomacro are compiled with recent Go toolchain, but there is a special command to disable it)

image

snowzach commented 3 years ago

I used go 1.16.3... Here's the Dockerfile I am using to add gophernotes to jupyter. It pulls gophernotes master (which I think is 1.0RC) which depends on github.com/cosmos72/gomacro v0.0.0-20210413180755-590dbc3d0bcd which looks very recent. I also tried forcing module mode but that didn't seem to help.

FROM jupyter/datascience-notebook:latest

# Need to be root to do all this stuff
USER root

# Base image packages
RUN apt-get update \
    && sudo apt-get install -y \
    libpq-dev less \
    && rm -rf /var/lib/apt/lists/*

# Python packages
RUN pip install \
    psycopg2

# Install Go
RUN wget -O /tmp/go.tar.gz https://golang.org/dl/go1.16.3.linux-amd64.tar.gz \
    && tar -C /usr/local -xzf /tmp/go.tar.gz \
    && rm /tmp/go.tar.gz
ENV PATH="${PATH}:/usr/local/go/bin:$HOME/go/bin"
ENV GO111MODULE=on

# Install gophernotes
RUN cd /tmp && git clone https://github.com/gopherdata/gophernotes \
    && cd /tmp/gophernotes && GOPATH=/go go install \
    && mv /go/bin/gophernotes /usr/local/bin/gophernotes \
    && mkdir -p /opt/conda/share/jupyter/kernels/gophernotes \
    && cp kernel/* /opt/conda/share/jupyter/kernels/gophernotes \
    && chmod +w /opt/conda/share/jupyter/kernels/gophernotes/kernel.json \
    && chown -R jovyan:users /opt/conda/share/jupyter/kernels/gophernotes \
    && cd && rm -Rf /tmp/gophernotes && rm -Rf /go

# Switch back to jupyter default user
USER jovyan

When I try using Go it just says:

[I 14:48:07.597 NotebookApp] 302 GET / (172.17.0.1) 0.970000ms
[I 14:48:07.642 NotebookApp] 302 GET /tree? (172.17.0.1) 0.990000ms
[I 14:48:12.580 NotebookApp] 302 POST /login?next=%2Ftree%3F (172.17.0.1) 1.880000ms
[I 14:48:19.120 NotebookApp] Creating new notebook in
[I 14:48:19.208 NotebookApp] Writing notebook-signing key to /home/jovyan/.local/share/jupyter/notebook_secret
[I 14:48:25.080 NotebookApp] Kernel started: 7e12e118-ad92-40a3-87eb-60f398cd57c2, name: gophernotes
[I 14:48:25.209 NotebookApp] Adapting from protocol version 5.0 (kernel 7e12e118-ad92-40a3-87eb-60f398cd57c2) to 5.3 (client).
2021/04/16 14:48:27 Unhandled shell message:  comm_info_request
// debug: running "go get github.com/davecgh/go-spew/spew" ...
go: downloading github.com/davecgh/go-spew v1.1.1
go get: added github.com/davecgh/go-spew v1.1.1

And then the console shows image

I did get it to work at one point when I got it to print compiling in that log output.. I never restarted it. It literealy didn't work several times, then I did something and it printed compiling in the log output and after that it seemed to work. Not sure what I did to get that compiling stage to work though.

cosmos72 commented 3 years ago

I am definitely not expert with docker.

Moving this issue to https://github.com/gopherdata/gophernotes/issues/233 where hopefully someone more expert with docker can help.