matthewmueller / joy

A delightful Go to Javascript compiler (ON HOLD)
https://mat.tm/joy
GNU General Public License v3.0
1.32k stars 35 forks source link

Getting Started not working on OSX #65

Closed shaban closed 6 years ago

shaban commented 6 years ago

Hello, i was quite curious to see joy in action so i tried the getting started Tutorial to get an idea of how joy works. I ran into problems though. I use normal OSX shell no brew or anything . What happened was this.

Command: curl -sfL https://raw.githubusercontent.com/matthewmueller/joy/master/install.sh | sh

Result: matthewmueller/joy: checking GitHub for latest version matthewmueller/joy: found version 0.1.2 for darwin/amd64 matthewmueller/joy: downloading https://github.com/matthewmueller/joy/releases/download/v0.1.2/joy_0.1.2_darwin_amd64.tar.gz curl --fail -sSL -o /var/folders/7k/7fcv6h1j4g92mh2ztmcpts6r0000gp/T//joy_0.1.2_darwin_amd64.tar.gz https://github.com/matthewmueller/joy/releases/download/v0.1.2/joy_0.1.2_darwin_amd64.tar.gz matthewmueller/joy: verifying checksums curl --fail -sSL -o /var/folders/7k/7fcv6h1j4g92mh2ztmcpts6r0000gp/T//joy_0.1.2_checksums.txt https://github.com/matthewmueller/joy/releases/download/v0.1.2/joy_0.1.2_checksums.txt install: chmod 755 /usr/local/bin: Operation not permitted install: /usr/local/bin//joy: Permission denied

This time as super user (which doesn't do a lot since i should sudo the resulting install.sh i guess): sudo curl -sfL https://raw.githubusercontent.com/matthewmueller/joy/master/install.sh | sh

Result: matthewmueller/joy: checking GitHub for latest version matthewmueller/joy: found version 0.1.2 for darwin/amd64 matthewmueller/joy: downloading https://github.com/matthewmueller/joy/releases/download/v0.1.2/joy_0.1.2_darwin_amd64.tar.gz curl --fail -sSL -o /var/folders/7k/7fcv6h1j4g92mh2ztmcpts6r0000gp/T//joy_0.1.2_darwin_amd64.tar.gz https://github.com/matthewmueller/joy/releases/download/v0.1.2/joy_0.1.2_darwin_amd64.tar.gz matthewmueller/joy: verifying checksums curl --fail -sSL -o /var/folders/7k/7fcv6h1j4g92mh2ztmcpts6r0000gp/T//joy_0.1.2_checksums.txt https://github.com/matthewmueller/joy/releases/download/v0.1.2/joy_0.1.2_checksums.txt install: chmod 755 /usr/local/bin: Operation not permitted install: /usr/local/bin//joy: Permission denied

Now by downloading from releases putting joy executable into GOPATH/bin it seems to work though there is still some rough edges: joy run main.go Result: downloading headless chrome (this only needs to be done once) /Users/shaban/Library/Preferences/joy/internal/runtime/runtime.go:3:8: could not import github.com/matthewmueller/joy/macro (cannot find package "github.com/matthewmueller/joy/macro" in any of: /usr/local/go/src/github.com/matthewmueller/joy/macro (from $GOROOT) /Users/shaban/go/src/github.com/matthewmueller/joy/macro (from $GOPATH)) ⨯ parse error: load error: unable to load the go package: couldn't load packages due to errors: runtime

Now remedying the situation by manually go getting: go get github.com/matthewmueller/joy/macro

Another Try: joy run main.go Result working as expected: github.com/matthewmueller/joy/macro hi world!

Now let's try the serve Command: joy serve main.go Result: cannot find package "../../Downloads" in: /Users/Downloads FATAL[0000] error serving: load error: unable to load the go package: couldn't load packages due to errors: ../../Downloads Downloads just happens to be the directory i put my main.go in.

So either serve command only works with an installable package in GOPATH or am i missing something?

matthewmueller commented 6 years ago

@shaban thanks for compiling this! This is a good list to make sure I handle all the cases.

I made some assumptions about GOPATH that didn't hold up once you're shipping I binary

I have a fix ready that I just need to cleanup. Should be a much better experience tomorrow :-)

shaban commented 6 years ago

Thanks for the speedy response. Looking forward to trying it out.

matthewmueller commented 6 years ago

Alrighty, could you please try running that command again and let me know if it works?

curl -sfL https://raw.githubusercontent.com/matthewmueller/joy/master/install.sh | sh
loilo commented 6 years ago

I had the same problem, for me it works now. 🎉 Would be nice to be confirmed by someone else though.

matthewmueller commented 6 years ago

FYI, still need to fix up this case:

Now let's try the serve Command:
joy serve main.go
Result:
cannot find package "../../Downloads" in: /Users/Downloads FATAL[0000] error serving: load error: unable to load the go package: couldn't load packages due to errors: ../../Downloads
Downloads just happens to be the directory i put my main.go in.
shaban commented 6 years ago

curl -sfL https://raw.githubusercontent.com/matthewmueller/joy/master/install.sh | sh

Didn't work :-( matthewmueller/joy: checking GitHub for latest version matthewmueller/joy: found version 0.1.4 for darwin/amd64 matthewmueller/joy: downloading https://github.com/matthewmueller/joy/releases/download/v0.1.4/joy_0.1.4_darwin_amd64.tar.gz curl --fail -sSL -o /var/folders/7k/7fcv6h1j4g92mh2ztmcpts6r0000gp/T//joy_0.1.4_darwin_amd64.tar.gz https://github.com/matthewmueller/joy/releases/download/v0.1.4/joy_0.1.4_darwin_amd64.tar.gz matthewmueller/joy: verifying checksums curl --fail -sSL -o /var/folders/7k/7fcv6h1j4g92mh2ztmcpts6r0000gp/T//joy_0.1.4_checksums.txt https://github.com/matthewmueller/joy/releases/download/v0.1.4/joy_0.1.4_checksums.txt install: chmod 755 /usr/local/bin: Operation not permitted install: /usr/local/bin//joy: Permission denied

Trying to make it work by breaking down the steps: curl https://raw.githubusercontent.com/matthewmueller/joy/master/install.sh > install.sh sudo sh install.sh

Result: matthewmueller/joy: checking GitHub for latest version matthewmueller/joy: found version 0.1.4 for darwin/amd64 matthewmueller/joy: downloading https://github.com/matthewmueller/joy/releases/download/v0.1.4/joy_0.1.4_darwin_amd64.tar.gz curl --fail -sSL -o /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tmp.KZTBXNOF/joy_0.1.4_darwin_amd64.tar.gz https://github.com/matthewmueller/joy/releases/download/v0.1.4/joy_0.1.4_darwin_amd64.tar.gz matthewmueller/joy: verifying checksums curl --fail -sSL -o /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tmp.KZTBXNOF/joy_0.1.4_checksums.txt https://github.com/matthewmueller/joy/releases/download/v0.1.4/joy_0.1.4_checksums.txt matthewmueller/joy: installed as /usr/local/bin/joy

Trying out if it worked: joy run main.go Result OK: hi world!

Just out of curiosity.

If making your project go-gettable was an option for you, you would probably avoid a lot of minefields since go users are already equipped with a GOPATH and if there is none i think newest go-version comes with a default GOPATH.

And then in most cases GOPATH/bin is inside PATH which means you can ab/use it for all kinds of executables needed like the headless chrome and whatnot. On top you'd benefit from all the abstractions go's build system offers you. On a sidenote what i really love about go is that i know where the files land and how to get rid of them. This makes go users less reluctant to try out some package because they know:

FYI an interesting discussion here about GOPATH and the new default GOPATH and what people use in general as GOPATH.

And the tl;dr; version here The only drawback is that you would have to rely on a recent go version (1.8)

matthewmueller commented 6 years ago

@shaban I think you're right about this and I am overcomplicating it. A bit surprised /usr/local/bin isn't writable, is that normal? I'm just using https://github.com/goreleaser/godownloader here, but that seems like it's going to be a problem for non-go users.

For some reason, when I first read 1.8 I thought it was coming out, not already out 😅. Then I realized I'm already on 1.9.2! I think relying on 1.8+ is okay, since this is a new project.

The state I need on the client's machine is:


1. Some uncompiled Go source files (stdlib + runtime), so they can be compiled with the rest of the client's program. I may be able to ship .a files here, but I haven't looked into that

For this one, maybe I can just put them where they'd normally be?

UPDATE this doesn't work unfortunately:

testpkg : ls
macro/  stdlib/
testpkg : go get -u -v github.com/matthewmueller/testpkg/...
package github.com/matthewmueller/testpkg/macro: directory "/Users/matt/go/src/github.com/matthewmueller/testpkg/macro" is not using a known version control system
package github.com/matthewmueller/testpkg/stdlib: directory "/Users/matt/go/src/github.com/matthewmueller/testpkg/stdlib" is not using a known version control system
package github.com/matthewmueller/testpkg/stdlib/fmt: directory "/Users/matt/go/src/github.com/matthewmueller/testpkg/stdlib/fmt" is not using a known version control system

2. I need a version of headless chrome that we control so we can make sure it's consistent.

I think you're right that I can stick this in $GOPATH/bin, creating that directory if it doesn't already exist. Since we know where it is, it doesn't need to be in the user's $PATH.

Update I think i'll just stick this one in the same location as the source since I don't actually need it to be in the path.


Does that make sense?

shaban commented 6 years ago

ok i wrote something stupid here before and i hope you haven't seen it yet ;)

i overlooked something and i tried it out now the go way and good news it worked out of the box. go get github.com/matthewmueller/joy/cmd/joy then joy run main.go • downloading headless chrome (this only needs to be done once) hi World! ⨯ error flushing error=missing stream name so the only oddity is the last line otherwise it works flawlessly out of the box.

source of the error is in your analytics backend

matthewmueller commented 6 years ago

ahh yep, that's fixed in master. I've been adding a bunch of tests to this pipeline as well as simplifying things, so I think the next release will be pretty solid

matthewmueller commented 6 years ago

Okay, I think I've squashed all the major installation issues in the latest release 0.1.6 🎉

One thing I didn't add in was a fix if /usr/local/bin is not writable, I'm not sure yet if that's something we ought to be fixing.

If you were having troubles, please try again and let me know how it goes!

shaban commented 6 years ago

Well i go the go get way, so that it lands where i expect it. And that works really nicely. The usr/local problem doesn't happen at all to me now.

IMHO in modern unix /usr/... should be used by package manager(s)/OS and thats it.

matthewmueller commented 6 years ago

/cc @caarlos0

Any thoughts on this? I'm using godownloader which installs to /usr/local/bin. Should this be changed? I'm not sure where else it'd be placed though.

shaban commented 6 years ago

Just a question, since i assume you want to have a prospering ecosystem of reusable code / components etc. at some point.

Why not use $HOME/joy on linux and userprofile/joy on windows. This place could be a stub for some sort of package system later on.

matthewmueller commented 6 years ago

Most of the shared components and things will be in $GOPATH, we just have a few things like the runtime which need to be compiled alongside the source. I'm definitely open to changing this, in fact we could stick them in $GOPATH too, but they just can't be in the exact same place as joy's source because they'd break go get, so maybe under .joy instead.

Not a huge fan of $HOME/... clutter but I could be convinced if others prefer that. Right now, I'm using these settings: https://github.com/sindresorhus/env-paths to choose the config path.

This is a bit different than the problem with /usr/local/bin, longer-term we'd probably just want brew install joy or os-specific package installers (e.g. joy.pkg)

caarlos0 commented 6 years ago

Any thoughts on this? I'm using godownloader which installs to /usr/local/bin. Should this be changed? I'm not sure where else it'd be placed though.

it should be ok to install to /usr/local/bin, either way, it can be overwritten with the -b flag:

curl -sfL https://raw.githubusercontent.com/matthewmueller/joy/master/install.sh | sh -s -- -b /tmp
matthewmueller commented 6 years ago

@caarlos0 ahh okay awesome, thanks for chiming in!

Going to close this since I think this issue should be solved. Will add a note in the readme about -b if anyone else runs into this.