iron / staticfile

Static file-serving middleware for the Iron web framework.
MIT License
63 stars 56 forks source link

README.md example currently fails #94

Closed xobs closed 7 years ago

xobs commented 7 years ago

If I copy the example from README.md into a main.rs file and run it, the resulting files does not build. I get the following output:


[6:38:35 PM] ~/Documents/Code/jig-20-interface-http> cargo build
   Compiling jig-20-interface-http v0.1.0 (file:///C:/Users/smcro/Documents/Code/jig-20-interface-http)
error[E0277]: the trait bound `for<'r, 'r, 'r> staticfile::Static: std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied
   --> src\main.rs:198:7
    |
198 | mount.mount("/", Static::new(Path::new("target/doc/")));
    |       ^^^^^ the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not implemented for `staticfile::Static`
    |
    = note: required because of the requirements on the impl of `iron::Handler` for `staticfile::Static`

error[E0277]: the trait bound `for<'r, 'r, 'r> staticfile::Static: std::ops::FnOnce<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied
   --> src\main.rs:198:7
    |
198 | mount.mount("/", Static::new(Path::new("target/doc/")));
    |       ^^^^^ the trait `for<'r, 'r, 'r> std::ops::FnOnce<(&'r mut iron::Request<'r, 'r>,)>` is not implemented for `staticfile::Static`
    |
    = note: required because of the requirements on the impl of `iron::Handler` for `staticfile::Static`

error[E0277]: the trait bound `for<'r, 'r, 'r> staticfile::Static: std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied
   --> src\main.rs:200:7
    |
200 | mount.mount("/doc/", Static::new(Path::new("target/doc/staticfile/")));
    |       ^^^^^ the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not implemented for `staticfile::Static`
    |
    = note: required because of the requirements on the impl of `iron::Handler` for `staticfile::Static`

error[E0277]: the trait bound `for<'r, 'r, 'r> staticfile::Static: std::ops::FnOnce<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied
   --> src\main.rs:200:7
    |
200 | mount.mount("/doc/", Static::new(Path::new("target/doc/staticfile/")));
    |       ^^^^^ the trait `for<'r, 'r, 'r> std::ops::FnOnce<(&'r mut iron::Request<'r, 'r>,)>` is not implemented for `staticfile::Static`
    |
    = note: required because of the requirements on the impl of `iron::Handler` for `staticfile::Static`

error[E0277]: the trait bound `for<'r, 'r, 'r> staticfile::Static: std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied
   --> src\main.rs:202:7
    |
202 | mount.mount("/src/", Static::new(Path::new("target/doc/src/staticfile/lib.rs.html")));
    |       ^^^^^ the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not implemented for `staticfile::Static`
    |
    = note: required because of the requirements on the impl of `iron::Handler` for `staticfile::Static`

error[E0277]: the trait bound `for<'r, 'r, 'r> staticfile::Static: std::ops::FnOnce<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied
   --> src\main.rs:202:7
    |
202 | mount.mount("/src/", Static::new(Path::new("target/doc/src/staticfile/lib.rs.html")));
    |       ^^^^^ the trait `for<'r, 'r, 'r> std::ops::FnOnce<(&'r mut iron::Request<'r, 'r>,)>` is not implemented for `staticfile::Static`
    |
    = note: required because of the requirements on the impl of `iron::Handler` for `staticfile::Static`

error: aborting due to 6 previous errors

error: Could not compile `jig-20-interface-http`.

To learn more, run the command again with --verbose.
[6:40:40 PM] ~/Documents/Code/jig-20-interface-http>

This is using the example from README.md:

    let mut mount = Mount::new();

// Serve the shared JS/CSS at /
mount.mount("/", Static::new(Path::new("target/doc/")));
// Serve the static file docs at /doc/
mount.mount("/doc/", Static::new(Path::new("target/doc/staticfile/")));
// Serve the source code at /src/
mount.mount("/src/", Static::new(Path::new("target/doc/src/staticfile/lib.rs.html")));

Iron::new(mount).http("127.0.0.1:3000").unwrap();

My Cargo.toml contains:


[dependencies]
iron = "*"
router = "*"
mount = "*"
staticfile = "*"

This was built using the latest Rust 1.15.

Cobrand commented 7 years ago

I have the same problem on 1.16 nightly, however cargo run --example router works well though (even though it's basically the same code)

Cobrand commented 7 years ago

Found it : staticfile has still the old dependencies on crates.io ( iron 0.4 , mount 0.2 ), @untitaker can we get dependencies bump and a version bump on crates.io as well ?

@xobs : in the meanwhile, replace staticfile = "*" by

staticfile = {git = "https://github.com/iron/staticfile.git"}
untitaker commented 7 years ago

Blocked by latest iron-test version on Crates.io not supporting Iron 0.5. @reem please move project to iron org

On Sat, Feb 04, 2017 at 05:31:48AM -0800, Cobrand wrote:

Found it : staticfile has still the old dependencies on crates.io ( iron 0.4 , mount 0.2 ), @untitaker can we get dependencies bump and a version bump on crates.io as well ?

@xobs : in the meanwhile, replace staticfile = "*" by

staticfile = {git = "https://github.com/iron/staticfile.git"}

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/iron/staticfile/issues/94#issuecomment-277446084

onur commented 7 years ago

@untitaker he actually moved iron-test to iron organization, but someone needs to release a new version.

untitaker commented 7 years ago

Yeah i can't do that

On 5 February 2017 10:29:47 CET, Onur Aslan notifications@github.com wrote:

@untitaker he actually moved iron-test to iron organization, but someone needs to release a new version.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/iron/staticfile/issues/94#issuecomment-277507212

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

reem commented 7 years ago

Just did cargo owner --add github:iron which I believe should let people in the iron organization release new versions. Please let me know if that did not work!

untitaker commented 7 years ago

Yeah that didn't work, unfortunately.

reem commented 7 years ago

I've recreated the iron organization dev-team team and am attempting cargo owner --add github:iron:dev-team, but cargo is telling me I have to be part of the team (which I am) to add it. I think this is likely to be an ephemeral error (since I just created the team) so I'll try again in an hour or so.

reem commented 7 years ago

Alright, for whatever reason I am still not able to add dev-team to the package, but I have released iron-test 0.5.0.

untitaker commented 7 years ago

released 0.4.0

On Sun, Feb 05, 2017 at 08:21:48AM -0800, Jonathan Reem wrote:

Alright, for whatever reason I am still not able to add dev-team to the package, but I have released iron-test 0.5.0.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/iron/staticfile/issues/94#issuecomment-277530149

Cobrand commented 7 years ago

I guess you can close that @xobs

martincalvert commented 6 years ago

This appears to be back when using iron 0.6.0

Cargo.toml looks like

[dependencies]
handlebars-iron = "0.25.2"
router = "0.5.1"
maplit = "*"
staticfile = "*"
mount = "*"
iron = "0.5.1"

Offending line looks like

let mut mount = Mount::new();
mount.mount("/assets/", Static::new(Path::new("src/assets")));

error is

the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>` is not implemented for `staticfile::Static`

UPDATE It was because mount updated to iron 0.6.0. So if i pin everything to the iron 0.5.1 supported crates it works fine.

jessbowers commented 6 years ago

@martincalvert can you post the Cargo.toml that worked for you?

martincalvert commented 6 years ago

@jessbowers I believe this is what i ended up with https://github.com/SensorArray/sensor_rust/blob/master/Cargo.toml

Keats commented 6 years ago

I believe the issue is those lines https://github.com/iron/staticfile/blob/master/Cargo.toml#L15-L16 but Iron 0.6 is not compatible with Iron 0.5 apparently so try a combination of cargo clean and cargo update to fix it