livebud / bud

The Full-Stack Web Framework for Go
MIT License
5.58k stars 179 forks source link

run error #91

Closed huqiuyun closed 2 years ago

huqiuyun commented 2 years ago

Hello, After I bud build the project, I remove the *.go and go.mod source files. run ./bud/app in the terminal, but it output the error: unable to find go.mod: file does not exist in "/Users/Works/news"

---- for exmaple input the command in the terminal news % ./bud/app unable to find go.mod: file does not exist in "/Users/Works/news"

Why the app is running and it needs to depend go.mod?

matthewmueller commented 2 years ago

Hey @huqiuyun thanks for trying out bud! You'll need to run bud build to make ./bud/app self-contained.

The ./bud/app built with bud run indeed relies on go.mod because that's the development build.

012e commented 2 years ago

Hey @huqiuyun thanks for trying out bud! You'll need to run bud build to make ./bud/app self-contained.

The ./bud/app built with bud run indeed relies on go.mod because that's the development build.

I tried and got the same issue image image

matthewmueller commented 2 years ago

I just tested and I'm also able to reproduce this. Sorry for the confusion!

The problem is here: https://github.com/livebud/bud/blob/9e9272f37f0a480e354f066a860df06298365dca/runtime/generator/program/program.gotext#L36-L41

When the Embed flag is true, we'll just need to embed the go.mod as a string and use gomod.Parse instead of gomod.Load

huqiuyun commented 2 years ago

Thanks, new go.mod file, and it is empty, the app is running too.

huqiuyun commented 2 years ago

Create a new empty go.mod file, the app can run too.

matthewmueller commented 2 years ago

Yep, pretty sure the contents of the go.mod don't matter after bud build, just needs something.

huqiuyun commented 2 years ago

Please if publish it to online environment,what I need to do? do I need to publish the app and go.mod?

matthewmueller commented 2 years ago

@huqiuyun right now the workaround is to create a go.mod from the directory where you run ./bud/app.