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

Problems with `infer_schema` and relative paths, when running `cargo build` in non-root dir. #1199

Closed
dpc opened this Issue Sep 25, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@dpc

dpc commented Sep 25, 2017

When specifying the db as a relative path (sqlite), infer_schema macro will use a different location, depending on which directory the cargo build is started in.

Expected behavior

Typically cargo build works correctly no matter where invoked, so I would expect infra_schem to use a relative directory against the root of the project, and not CWD where cargo build was invoked. Because it's not the case eg. building in Neomake fails. (This is a followup of #1142 .)

Steps to reproduce

> cat .env 
DATABASE_URL=test.db
> cat src/schema.rs 
infer_schema!("dotenv:DATABASE_URL");
> cargo build
   Compiling foo v0.1.0 (file:///home/dpc/lab/rust/foo)
    Finished dev [unoptimized + debuginfo] target(s) in 3.74 secs
> cd src; touch bin.rs; cargo build
   Compiling foo v0.1.0 (file:///home/dpc/lab/rust/foo)
error[E0432]: unresolved import `self::schema::reviews`
  --> main.rs:25:19
   |
25 | use self::schema::reviews::dsl::*;
   |                   ^^^^^^^ Could not find `reviews` in `schema`

[...]
@sgrif

This comment has been minimized.

Member

sgrif commented Sep 25, 2017

It seems like this is more of a problem of using a relative path for your database URL, rather than a bug in Diesel. We don't really have any behavior here other than passing what you give us unmodified to SQLite.

@sgrif sgrif closed this Sep 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment