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

Example from the guide not working? #743

Closed
kirs opened this Issue Feb 20, 2017 · 12 comments

Comments

Projects
None yet
2 participants
@kirs

kirs commented Feb 20, 2017

I copied the project from examples/postgres/getting_started_step_3/ and prepared .env, but there's something about infer_schema! that fails on compile:

$ cargo install
   Compiling diesel_demo_step_3_pg v0.1.0 (file:///Users/kir/Projects/opensource/diesel_start)
error: custom derive attribute panicked
 --> src/schema.rs:1:1
  |
1 | infer_schema!("dotenv:DATABASE_URL");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: assertion failed: !p.is_null()
  = note: this error originates in a macro outside of the current crate

error: failed to compile `diesel_demo_step_3_pg v0.1.0 (file:///Users/kir/Projects/opensource/diesel_start)`, intermediate artifacts can be found at `/Users/kir/Projects/opensource/diesel_start/target`

Caused by:
  Could not compile `diesel_demo_step_3_pg`.

To learn more, run the command again with --verbose.

However the .env is valid:

$ cat .env
DATABASE_URL=postgres://kir@localhost/diesel_demo

$ psql --user kir diesel_demo
psql (9.6.1)
Type "help" for help.

I also tried running DATABASE_URL=... cargo install but it causes the same error.

I checked that maybe infer_schema! usage have changed from the previous version and the code from the guide is using outdates API, but looking at diesel_tests/tests/schema.rs I see nothing wrong.

cc @sgrif

@sgrif

This comment has been minimized.

Member

sgrif commented Feb 20, 2017

Can you run cargo clean and then paste the output of cargo install --verbose?

@sgrif

This comment has been minimized.

Member

sgrif commented Feb 20, 2017

Also make sure you cargo update

@kirs

This comment has been minimized.

@sgrif

This comment has been minimized.

Member

sgrif commented Feb 20, 2017

Hm. That assertion is coming from somewhere other than Diesel. Can you run again with RUST_BACKTRACE=1?

@kirs

This comment has been minimized.

kirs commented Feb 20, 2017

BTW, I'm running rust 1.15.1.

$ cargo update
    Updating registry `https://github.com/rust-lang/crates.io-index`
$ RUST_BACKTRACE=1 cargo install --verbose
       Fresh byteorder v1.0.0
       Fresh utf8-ranges v0.1.3
       Fresh winapi-build v0.1.1
       Fresh libc v0.2.20
       Fresh winapi v0.2.8
       Fresh regex-syntax v0.3.9
       Fresh quote v0.3.13
       Fresh unicode-xid v0.0.4
       Fresh memchr v0.1.11
       Fresh synom v0.11.0
       Fresh aho-corasick v0.5.3
       Fresh pq-sys v0.4.2
       Fresh syn v0.11.6
       Fresh kernel32-sys v0.2.2
       Fresh diesel v0.11.2
       Fresh thread-id v2.0.0
       Fresh diesel_infer_schema v0.11.0
       Fresh thread_local v0.2.7
       Fresh regex v0.1.80
       Fresh dotenv v0.8.0
       Fresh diesel_codegen v0.11.0
   Compiling diesel_demo_step_3_pg v0.1.0 (file:///Users/kir/Projects/opensource/diesel_start)
     Running `rustc --crate-name diesel_demo_step_3_pg src/lib.rs --crate-type lib -C opt-level=3 -C metadata=a7e40dfea0887d49 -C extra-filename=-a7e40dfea0887d49 --out-dir /Users/kir/Projects/opensource/diesel_start/target/release/deps --emit=dep-info,link -L dependency=/Users/kir/Projects/opensource/diesel_start/target/release/deps --extern dotenv=/Users/kir/Projects/opensource/diesel_start/target/release/deps/libdotenv-c0ef68bcfc5b2489.rlib --extern diesel_codegen=/Users/kir/Projects/opensource/diesel_start/target/release/deps/libdiesel_codegen-eefe7fa2e56aaa65.dylib --extern diesel=/Users/kir/Projects/opensource/diesel_start/target/release/deps/libdiesel-82ac424c6bfc818c.rlib -L native=/usr/local/opt/postgresql/lib`
error: custom derive attribute panicked
 --> src/schema.rs:1:1
  |
1 | infer_schema!("dotenv:DATABASE_URL");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: assertion failed: !p.is_null()
  = note: this error originates in a macro outside of the current crate

error: failed to compile `diesel_demo_step_3_pg v0.1.0 (file:///Users/kir/Projects/opensource/diesel_start)`, intermediate artifacts can be found at `/Users/kir/Projects/opensource/diesel_start/target`

Caused by:
  Could not compile `diesel_demo_step_3_pg`.

Caused by:
  process didn't exit successfully: `rustc --crate-name diesel_demo_step_3_pg src/lib.rs --crate-type lib -C opt-level=3 -C metadata=a7e40dfea0887d49 -C extra-filename=-a7e40dfea0887d49 --out-dir /Users/kir/Projects/opensource/diesel_start/target/release/deps --emit=dep-info,link -L dependency=/Users/kir/Projects/opensource/diesel_start/target/release/deps --extern dotenv=/Users/kir/Projects/opensource/diesel_start/target/release/deps/libdotenv-c0ef68bcfc5b2489.rlib --extern diesel_codegen=/Users/kir/Projects/opensource/diesel_start/target/release/deps/libdiesel_codegen-eefe7fa2e56aaa65.dylib --extern diesel=/Users/kir/Projects/opensource/diesel_start/target/release/deps/libdiesel-82ac424c6bfc818c.rlib -L native=/usr/local/opt/postgresql/lib` (exit code: 101)

Not sure if RUST_BACKTRACE=1 makes the output different.

I also tried grepping target/release/deps for !p.is_null() assertion but there was nothing.

@sgrif

This comment has been minimized.

Member

sgrif commented Feb 20, 2017

What version of Rust are you running against? (rustc -vV)

@sgrif

This comment has been minimized.

Member

sgrif commented Feb 20, 2017

Assuming the answer is stable 1.15.1, I found the assertion. Very unsure what it means though... Can you give the output of diesel print-schema perhaps?

@kirs

This comment has been minimized.

kirs commented Feb 20, 2017

$ rustc -vV
rustc 1.15.1
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-apple-darwin
release: 1.15.1
LLVM version: 3.9

$ diesel print-schema
table! {
    posts (id) {
        id -> Int4,
        title -> Varchar,
        body -> Text,
        published -> Bool,
    }
}

I'm curious about how did you find the assertion.

@sgrif

This comment has been minimized.

Member

sgrif commented Feb 20, 2017

I grepped the Rust source for assert!(!p.is_null. It's https://github.com/rust-lang/rust/blob/cfebdeaaccee40e060708d6b60c4abbe9edf72bb/src/libproc_macro/lib.rs#L156-L159 (which had no error message in 1.15.1).

I'd maybe give it a try on nightly. I'm unsure if this is an issue on our end or Rust's.

@kirs

This comment has been minimized.

kirs commented Feb 20, 2017

It works on nightly.

@kirs

This comment has been minimized.

kirs commented Feb 20, 2017

Thanks for your help! Should we close the issue?

@sgrif

This comment has been minimized.

Member

sgrif commented Feb 20, 2017

I suppose so. I wish I could reproduce the issue locally. :\

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