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

Cannot find macro `table!` and cannot find derive macro `Queryable` #1811

Closed
biot023 opened this Issue Aug 4, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@biot023

biot023 commented Aug 4, 2018

Setup

Versions

  • Rust: rustc 1.27.2 (58cc626de 2018-07-18)
  • Diesel: 1.3.2
  • Database: PostgreSQL
  • Operating System: Ubuntu 18.04

Feature Flags

  • diesel:

Problem Description

I followed the getting started tutorial and that worked okay.
But now I'm seeing these errors when I run cargo check on another project I'm trying to use diesel on.

  • error: cannot find macro table! in this scope
  • error: cannot find derive macro Queryable in this scope

The first in particular is in a file generated by diesel.

What are you trying to accomplish?

Implementing the same functionality as the "getting started" tutorial, pretty much.

What is the expected output?

That it should compile (or show me some other errors).

What is the actual output?

$ cargo check --verbose
Fresh unicode-xid v0.1.0
Fresh cc v1.0.18
Fresh libc v0.2.42
Fresh void v1.0.2
Fresh cfg-if v0.1.4
Fresh ucd-util v0.1.1
Fresh rustc-demangle v0.1.9
Fresh lazy_static v1.0.2
Fresh utf8-ranges v1.0.0
Fresh byteorder v1.2.4
Fresh bitflags v1.0.3
Fresh matches v0.1.7
Fresh proc-macro2 v0.4.9
Fresh proc-macro2 v0.3.8
Fresh memchr v2.0.1
Fresh time v0.1.40
Fresh rand v0.4.2
Fresh unreachable v1.0.0
Fresh regex-syntax v0.6.2
Fresh quote v0.6.4
Fresh quote v0.5.2
Fresh aho-corasick v0.6.6
Fresh num-traits v0.2.5
Fresh thread_local v0.3.5
Fresh serde v1.0.70
Fresh pq-sys v0.4.6
Fresh syn v0.14.7
Fresh syn v0.13.11
Fresh backtrace-sys v0.1.23
Fresh num-integer v0.1.39
Fresh regex v1.0.2
Fresh uuid v0.6.5
Fresh synstructure v0.9.0
Fresh serde_derive v1.0.70
Fresh diesel_derives v1.3.0
Fresh backtrace v0.3.9
Fresh chrono v0.4.5
Fresh failure_derive v0.1.2
Fresh diesel v1.3.2
Fresh failure v0.1.2
Fresh dotenv v0.13.0
Checking dp v0.1.0 (file:///home/me/work/home/rust/dp/dp)
Running rustc --crate-name dp src/lib.rs --crate-type lib --emit=dep-info,metadata -C debuginfo=2 -C metadata=b98d1f9a214d87e3 -C extra-filename=-b98d1f9a214d87e3 --out-dir /home/me/work/home/rust/dp/dp/target/debug/deps -C incremental=/home/me/work/home/rust/dp/dp/target/debug/incremental -L dependency=/home/me/work/home/rust/dp/dp/target/debug/deps --extern serde_derive=/home/me/work/home/rust/dp/dp/target/debug/deps/libserde_derive-0da1fdb6e3476cb6.so --extern uuid=/home/me/work/home/rust/dp/dp/target/debug/deps/libuuid-d10e8fac523e9907.rmeta --extern chrono=/home/me/work/home/rust/dp/dp/target/debug/deps/libchrono-64c508931f79b192.rmeta --extern serde=/home/me/work/home/rust/dp/dp/target/debug/deps/libserde-082b5e8e59eeb2b9.rmeta --extern diesel=/home/me/work/home/rust/dp/dp/target/debug/deps/libdiesel-3a4cd3de6c40644c.rmeta --extern dotenv=/home/me/work/home/rust/dp/dp/target/debug/deps/libdotenv-d099a357f49696b9.rmeta --extern matches=/home/me/work/home/rust/dp/dp/target/debug/deps/libmatches-368d41e99865b973.rmeta -L native=/usr/lib/x86_64-linux-gnu -L native=/home/me/work/home/rust/dp/dp/target/debug/build/backtrace-sys-6dfb52fe4b98ef15/out
error: cannot find macro table! in this scope
--> src/schema.rs:1:1
|
1 | table! {
| ^^^^^

error: cannot find derive macro Queryable in this scope
--> src/models.rs:1:10
|
1 | #[derive(Queryable)]
| ^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile dp.

Caused by:
process didn't exit successfully: rustc --crate-name dp src/lib.rs --crate-type lib --emit=dep-info,metadata -C debuginfo=2 -C metadata=b98d1f9a214d87e3 -C extra-filename=-b98d1f9a214d87e3 --out-dir /home/me/work/home/rust/dp/dp/target/debug/deps -C incremental=/home/me/work/home/rust/dp/dp/target/debug/incremental -L dependency=/home/me/work/home/rust/dp/dp/target/debug/deps --extern serde_derive=/home/me/work/home/rust/dp/dp/target/debug/deps/libserde_derive-0da1fdb6e3476cb6.so --extern uuid=/home/me/work/home/rust/dp/dp/target/debug/deps/libuuid-d10e8fac523e9907.rmeta --extern chrono=/home/me/work/home/rust/dp/dp/target/debug/deps/libchrono-64c508931f79b192.rmeta --extern serde=/home/me/work/home/rust/dp/dp/target/debug/deps/libserde-082b5e8e59eeb2b9.rmeta --extern diesel=/home/me/work/home/rust/dp/dp/target/debug/deps/libdiesel-3a4cd3de6c40644c.rmeta --extern dotenv=/home/me/work/home/rust/dp/dp/target/debug/deps/libdotenv-d099a357f49696b9.rmeta --extern matches=/home/me/work/home/rust/dp/dp/target/debug/deps/libmatches-368d41e99865b973.rmeta -L native=/usr/lib/x86_64-linux-gnu -L native=/home/me/work/home/rust/dp/dp/target/debug/build/backtrace-sys-6dfb52fe4b98ef15/out (exit code: 101)

Are you seeing any additional errors?

No.

Steps to reproduce

Running cargo check on my codebase.

I have the following lines in my src/lib.rs file in this order:

extern crate diesel;
// ...
use diesel::prelude::*;
// ...
mod schema;
mod models;

The diesel-generated src/schema.rs file looks like this:

table! {
    users (id) {
        id -> Int4,
        email -> Varchar,
        given_name -> Varchar,
        family_name -> Varchar,
        crypted_password -> Varchar,
        admin -> Bool,
        deleted -> Bool,
    }
}

And the src/models.rs file looks like this:

#[derive(Queryable)]
pub struct User {
    pub id: i32,
    pub email: String,
    pub given_name: String,
    pub family_name: String,
    pub crypted_password: String,
    pub admin: bool,
    pub deleted: bool,
}

Checklist

  • I have already looked over the issue tracker for similar issues.
  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
@weiznich

This comment has been minimized.

Contributor

weiznich commented Aug 4, 2018

error: cannot find macro table! in this scope
error: cannot find derive macro Queryable in this scope

This sounds like that the #[macro_use] annotation is missing on your extern crate diesel; import.

(I closed this issue because there is nothing actionable for the diesel team here. Feel free to response here or use our gitter channel to ask future questions.)

@weiznich weiznich closed this Aug 4, 2018

@biot023

This comment has been minimized.

biot023 commented Aug 4, 2018

Oh good grief. Yes, it was precisely that -- thank you!

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