gnormal / gnorm

A database-first code generator for any language
https://gnorm.org
Other
487 stars 40 forks source link

gnorm gen fails #41

Closed gernest closed 6 years ago

gernest commented 6 years ago

With the latest master running gnorm gen I get

$ gnorm gen
Error: generating file for schema Public: error writing generated file "Public.go
": cannot replace "Public.go" with tempfile "/var/folders/ft/j4yq82wd4bd4s74gvmv4n_000000gn/T/Public.go436637883": rename /var/folders/ft/j4yq82wd4bd4s74gvmv4n_000000gn/T/Public.go436637883 Public.go: cross-device link
Usage:
  gnorm gen [flags]

Flags:
  -c, --config string   relative path to gnorm config file (default "gnorm.toml")
  -h, --help            help for gen
  -v, --verbose         show debugging output

Somehow this part https://github.com/gnormal/gnorm/blob/9354db9b80938db07681cb45dd19b77c24f710be/run/generate.go#L130-L132 fails

natefinch commented 6 years ago

arg. you must have your temp dir on a different disk than your output directory or something.

I have code that writes the files to a temp file first and then renames it, to ensure the whole file gets written. it's honestly overkill,and evidently buggy.

gernest commented 6 years ago

Have you thought about just using ioutil.WriteFile?

There is no need to be fancy, since the whole point of generating files is just overwriting them.

natefinch commented 6 years ago

Yeah, I was going to go back to that. That's the way it was before.

On Wed, Sep 27, 2017, 7:37 AM Geofrey Ernest notifications@github.com wrote:

Have you thought about just using ioutil.WriteFile?

There is no need to be fancy, since the whole point of generating files is just overwriting them.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gnormal/gnorm/issues/41#issuecomment-332493413, or mute the thread https://github.com/notifications/unsubscribe-auth/ADCcyKflc3PTXt9uhmroc4-cu2MqGVQKks5smjNegaJpZM4PlbFC .

gernest commented 6 years ago

Okay.

natefinch commented 6 years ago

if you want to fix it, you can search for atomic.Writefile and replace it with ioutil.writefile

gernest commented 6 years ago

Okay.