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

Unable to build for testing and contributing #1543

Closed
vityafx opened this Issue Feb 6, 2018 · 13 comments

Comments

Projects
None yet
3 participants
@vityafx

vityafx commented Feb 6, 2018

I have a problem: the diesel framework does not have a database serialization for chrono::Duration
So, I forked the project and made changes as I wanted. However, I can't run cargo test:

$ cargo test
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling all_about_updates v0.1.0 (file:///home/user/diesel/examples/postgres/all_about_updates)
   Compiling diesel_demo_step_2_mysql v0.1.0 (file:///home/user/diesel/examples/mysql/getting_started_step_2)
   Compiling diesel_demo_step_1_mysql v0.1.0 (file:///home/user/diesel/examples/mysql/getting_started_step_1)
   Compiling all_about_inserts v0.1.0 (file:///home/user/diesel/examples/postgres/all_about_inserts)
   Compiling diesel_demo_step_2_pg v0.1.0 (file:///home/user/diesel/examples/postgres/getting_started_step_2)
   Compiling diesel_demo_step_3_mysql v0.1.0 (file:///home/user/diesel/examples/mysql/getting_started_step_3)
   Compiling diesel_demo_step_1_pg v0.1.0 (file:///home/user/diesel/examples/postgres/getting_started_step_1)
error[E0282]: type annotations needed
  --> examples/postgres/all_about_updates/src/lib.rs:45:9
   |
45 |         debug_query(&diesel::update(posts).set(draft.eq(false))).to_string()
   |         ^^^^^^^^^^^ cannot infer type for `DB`

error: aborting due to previous error

I can't even add my diesel for as dependency to my project which uses it so I can be at least sure that it works as expected.
How to test it and how to add my fork as a dependency instead of it from the using crates-io?

Versions:

  • rustc 1.25.0-nightly (0c6091fbd 2018-02-04)
  • rustc 1.23.0 (766bd11c8 2018-01-01)
  • diesel 1.1.1
@weiznich

This comment has been minimized.

Contributor

weiznich commented Feb 6, 2018

Please add informations about what compiler version you tried to use

@Eijebong

This comment has been minimized.

Member

Eijebong commented Feb 6, 2018

You need to enable at least one feature. cargo test --features sqlite for example

@vityafx

This comment has been minimized.

vityafx commented Feb 6, 2018

@weiznich I have added the information you asked for.
@Eijebong The result is still the same. I had tried that before, actually. It was what I started with.

@Eijebong

This comment has been minimized.

Member

Eijebong commented Feb 6, 2018

Ha you're running tests from the root, that's probably why. We don't do that. You should use bin/test instead to run all tests

@vityafx

This comment has been minimized.

vityafx commented Feb 6, 2018

@Eijebong well, was written it somewhere and I missed that? :)
Okay, what about using it in my project then? How can I add my local fork as a dependency correctly?

$ ./bin/test
   Compiling clippy v0.0.185
   Compiling getopts v0.2.17
   Compiling either v1.4.0
   Compiling if_chain v0.1.2
   Compiling semver-parser v0.7.0
   Compiling bitflags v0.9.1
   Compiling antidote v1.0.0
   Compiling quine-mc_cluskey v0.2.4
   Compiling pulldown-cmark v0.0.15
   Compiling toml v0.4.5
   Compiling itertools v0.6.5
   Compiling syn v0.11.11
   Compiling scheduled-thread-pool v0.2.0
   Compiling semver v0.6.0
   Compiling quickcheck v0.4.1
   Compiling r2d2 v0.8.2
   Compiling serde_derive_internals v0.19.0
   Compiling derive-error-chain v0.10.1
   Compiling serde_derive v1.0.27
   Compiling dotenv v0.10.1
   Compiling cargo_metadata v0.2.3
   Compiling clippy_lints v0.0.185
error[E0599]: no method named `layout_of` found for type `(rustc::ty::TyCtxt<'a, 'tcx, 'tcx>, rustc::ty::ParamEnv<'tcx>)` in the current scope
    --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.185/src/utils/mod.rs:1041:28
     |
1041 |     (cx.tcx, cx.param_env).layout_of(ty)
     |                            ^^^^^^^^^

error[E0599]: no method named `layout_of` found for type `(rustc::ty::TyCtxt<'a, 'tcx, 'tcx>, rustc::ty::ParamEnv<'tcx>)` in the current scope
    --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.185/src/utils/mod.rs:1063:28
     |
1063 |     (cx.tcx, cx.param_env).layout_of(ty).ok().map(|layout| layout.align)
     |                            ^^^^^^^^^

error: aborting due to 2 previous errors
@Eijebong

This comment has been minimized.

Member

Eijebong commented Feb 6, 2018

It's written there https://github.com/diesel-rs/diesel/blob/master/CONTRIBUTING.md#setting-up-diesel-locally (5.)

To use it in your project, you can add a [replace] section in your Cargo.toml

@Eijebong

This comment has been minimized.

Member

Eijebong commented Feb 6, 2018

You also need to pin your compiler to the same version we're using, you can find it there: https://github.com/diesel-rs/diesel/blob/master/.travis.yml#L45
This is also written in the contributing file ;)

@vityafx

This comment has been minimized.

vityafx commented Feb 6, 2018

@Eijebong could you provide an example of how I add the diesel into the [replace] section please? I tried that today but with no success:

[dependencies.diesel]
version = "1"
features = ["sqlite", "chrono"]

[replace]
"diesel:1.1.1" = { path = "../../diesel/" }

According to what I see during the compilation, my replace section is ignored.

@weiznich

This comment has been minimized.

Contributor

weiznich commented Feb 6, 2018

A replace section will only work in a workspace as far as I know, so you need to add [workspace] to Cargo.toml.

@vityafx

This comment has been minimized.

vityafx commented Feb 6, 2018

I have a project without workspaces which uses diesel. Can I use local diesel there?

@weiznich

This comment has been minimized.

Contributor

weiznich commented Feb 6, 2018

Just add an line with [workspace] into your Cargo.toml and it should work. Alternatively you could try to use a [patch] section. (I've never tried this)

@vityafx

This comment has been minimized.

vityafx commented Feb 6, 2018

The patch section does not work for me at all, looks like it is not even parsed.
Adding the empty workspace section helped but:

error: cannot find macro `impl_Insertable!` in this scope
 --> <proc-macro source code>:1:1
  |
1 | impl_Insertable ! { ( struct_name = Punishment , table_name = punishments , struct_ty = Punishment , lifetimes = ( ) , ) , fields = [ { field_name:  user_id ,  column_name:  user_id ,  field_ty:  i64 ,  field_kind:  regular ,  inner_field_ty:  i64 ,  } { field_name:  server_id ,  column_name:  server_id ,  field_ty:  i64 ,  field_kind:  regular ,  inner_field_ty:  i64 ,  } { field_name:  start_time ,  column_name:  start_time ,  field_ty:  NaiveDateTime ,  field_kind:  regular ,  inner_field_ty:  NaiveDateTime ,  } { field_name:  duration ,  column_name:  duration ,  field_ty:  chrono :: Duration ,  field_kind:  regular ,  inner_field_ty:  chrono :: Duration ,  } { field_name:  reason ,  column_name:  reason ,  field_ty:  String ,  field_kind:  regular ,  inner_field_ty:  String ,  } ] , }
  | ^^^^^^^^^^^^^^^

error: aborting due to previous error

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

This was for:

[dependencies.diesel]
version = "1"
features = ["sqlite", "chrono"]

[replace]
"diesel:1.1.1" = { path = "../../diesel/diesel" }
[workspace]

If I try to set the root path where is the diesel workspace (or repository root):

[dependencies.diesel]
version = "1"
features = ["sqlite", "chrono"]

[replace]
"diesel:1.1.1" = { path = "../../diesel" }
[workspace]

I get this:

cargo build 
error: failed to load source for a dependency on `diesel`

Caused by:
  Unable to update file:///home/user/diesel

Caused by:
  found a virtual manifest at `/home/user/diesel/Cargo.toml` instead of a package manifest

Cargo-Process exited abnormally with code 101 at Tue Feb  6 17:33:28
@vityafx

This comment has been minimized.

vityafx commented Feb 6, 2018

Fixed that by adding a diesel_derives as a replacement, so finally it looks like:

[dependencies.diesel]
version = "1"
features = ["sqlite", "chrono"]

[replace]
"diesel:1.1.1" = { path = "../../diesel/diesel" }
"diesel_derives:1.1.0" = { path = "../../diesel/diesel_derives" }

[workspace]

@vityafx vityafx closed this Feb 6, 2018

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