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

embed_migrations! misbehaves in workspaces #1873

Closed
kpcyrd opened this Issue Oct 5, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@kpcyrd
Contributor

kpcyrd commented Oct 5, 2018

Setup

  • foo/Cargo.toml <- this is my workspace
  • foo/target <- this is the workspace build folder
  • foo/bar/Cargo.toml <- my other project
  • foo/bar/assets/foo.bin <- an asset
  • foo/bar/migrations <- my migrations
  • foo/bar/src/main.rs <- this file has embed_migrations!

Versions

  • Diesel: 1.3.3
  • Diesel migrations: 1.3.0

Problem Description

I have to specify the path differently from what I'm doing in include_bytes!:

embed_migrations!("../bar/migrations");

while I can do the following with assets:

include_bytes!("../assets/foo.bin");

The problem is that the macro panics during cargo package, probably since the path doesn't match anymore during a publish/package, while include_bytes! seems to work.

   = help: message: Error reading migrations: No such file or directory (os error 2)                                               
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

I couldn't find a way to workaround this yet, changing this to "../migrations" for the release didn't seem to work either.

@kpcyrd

This comment has been minimized.

Contributor

kpcyrd commented Oct 5, 2018

I was able to work around this with embed_migrations!("migrations"), if I recall correctly I had to provide a path explicitly because foo uses diesel as well and it would pick up foo/migrations from foo/bar otherwise.

@sgrif

This comment has been minimized.

Member

sgrif commented Oct 7, 2018

The path given is resolved relative to the CARGO_MANIFEST_DIR environment variable given to us by Cargo, which is the only available information we have. If you believe the value of that environment variable is incorrect in the presence of a workspace, that is a bug in Cargo, not Diesel.

@sgrif sgrif closed this Oct 7, 2018

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