Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include schema by relative path. #429

Open
Toasterson opened this issue Jan 9, 2024 · 3 comments
Open

Include schema by relative path. #429

Toasterson opened this issue Jan 9, 2024 · 3 comments

Comments

@Toasterson
Copy link

Toasterson commented Jan 9, 2024

I develop both on a Mac and and my linux computer.

On my linux computer I get the following error:

error: couldn't read /Users/toasty/ws/oxifed/prisma/schema.prisma: No such file or directory (os error 2)
 --> src/prisma.rs:4:5
  |
4 |     include_str!("/Users/toasty/ws/oxifed/prisma/schema.prisma");
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `oxifed` (lib) due to previous error

I had to delete prisma.rs and make an empty prisma.rs to be able to run prisma generate

Unless relative paths are used the generated prisma.rs file is machine dependant and user dependant which is not usable with CI.

@Brendonovich
Copy link
Owner

From the docs:

The generated client must not be checked into source control. It cannot be transferred between devices or operating systems. You will need to re-generate it wherever you build your project. If using git, add it to your .gitignore file.

Migrations require using an absolute path, so for consistency I've made the schema do the same.

@Toasterson
Copy link
Author

Toasterson commented Jan 29, 2024

Well in migrations you can still be changed by the program. The Rust source always assume relative path so hardcoding fixed paths breaks rust tooling. No crate with prisma can be distributed at all.

@Brendonovich
Copy link
Owner

Well in migrations you can still be changed by the program

Migrations are embedded into the binary at build-time, not sure I get your point

The Rust source always assume relative path so hardcoding fixed paths breaks rust tooling

I'll gladly accept a PR switching to relative paths for schema + migrations but I probably won't be the one to write it

No crate with prisma can be distributed at all

Haven't seen this use case before, I work in monorepos and workspaces - can you generate the client in a build script for whoever consumes the package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants