stamm
stamm

Reputation: 129

Unable to get started with diesel.rs and Rust 1.16 nightly

I'm trying to follow the Diesel getting started guide by directly copying examples/getting_started_step_3/ from the Diesel GitHub repo, but I'm facing some compile errors I can not fix:

cargo build 
   Compiling diesel_demo_step_3 v0.1.0 (file:///home/stamm/code/rustsome/pkiexpress)
error: macro undefined: 'options!'
 --> src/schema.rs:1:1
  |
1 | infer_schema!("dotenv:DATABASE_URL");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in a macro outside of the current crate

error: macro undefined: 'table_name!'
  --> src/models.rs:12:1
   |
12 | #[table_name="posts"]
   | ^^^^^^^^^^^^^^^^^^^^^

Here is my .env:

DATABASE_URL=postgres://postgres:password@localhost/pkiexpress

I am using Rust 1.16.0-nightly (df8debf6d 2017-01-25) and Diesel 0.9.0.

Upvotes: 0

Views: 711

Answers (1)

Erik Vesteraas
Erik Vesteraas

Reputation: 4735

The compile error you are getting sounds like it is caused by an issue with the current nightly. You can probably fix it by removing #![feature(proc_macro)] from your code (it should no longer be needed for the feature Diesel uses). For the example you linked, this was done in a commit made 17 days ago.

When working with examples for the nightly compiler there is a high risk of breakage. For popular crates, examples are updated pretty fast, so you should make sure both your compiler and the examples you are trying to run is up to date. Fortunately with the release of 1.15 (in less than a week, on 2017-02-02) Diesel will work with the stable compiler, where the risk of breakage is much less.

If the above does not work you can use an older nightly (c07a6ae77 2017-01-17 for example should work), just wait for the issue to be fixed, or wait until 1.15 is released and use stable.

Upvotes: 1

Related Questions