rustyscreeps / screeps-starter-rust

Starter Rust AI for Screeps, the JavaScript-based MMO game
MIT License
121 stars 47 forks source link

Unable to compile the default example. #1

Closed WooterTheTroubleshooter closed 6 years ago

WooterTheTroubleshooter commented 6 years ago
$ cargo screeps -u
cargo_screeps: compiling...
info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
info: installing component 'rust-std' for 'wasm32-unknown-unknown'
   Compiling unicode-xid v0.1.0
   Compiling serde v1.0.70
   Compiling num-traits v0.2.5
   Compiling dtoa v0.4.3
   Compiling itoa v0.4.2
   Compiling stdweb v0.4.8
   Compiling base-x v0.2.2
   Compiling cfg-if v0.1.4
   Compiling discard v1.0.3
   Compiling scoped-tls v0.1.2
   Compiling proc-macro2 v0.4.9
   Compiling proc-macro2 v0.2.3
   Compiling log v0.4.3
   Compiling fern v0.5.6
   Compiling quote v0.6.4
   Compiling quote v0.4.2
   Compiling num-traits v0.1.43
   Compiling syn v0.14.7
   Compiling enum_primitive v0.1.1
   Compiling syn v0.12.15
   Compiling serde_json v1.0.24
   Compiling serde_derive v1.0.70
   Compiling stdweb-derive v0.4.0
   Compiling stdweb-internal-macros v0.1.0
   Compiling screeps-game-api v0.0.10
   Compiling screeps-wooter v0.0.0 (file:///home/wouter/Screeps/rust)
error[E0599]: no method named `pos` found for type `screeps::Creep` in the current scope
  --> src/main.rs:73:22
   |
73 |             if creep.pos().is_near_to(&source) {
   |                      ^^^
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
   |
8  | use screeps::HasPosition;
   |

error[E0277]: the trait bound `&screeps::Source: screeps::RoomObjectProperties` is not satisfied
  --> src/main.rs:79:23
   |
79 |                 creep.move_to(&source);
   |                       ^^^^^^^ the trait `screeps::RoomObjectProperties` is not implemented for `&screeps::Source`
   |
   = help: the following implementations were found:
             <screeps::Source as screeps::RoomObjectProperties>
   = note: required because of the requirements on the impl of `screeps::HasPosition` for `&screeps::Source`

error: aborting due to 2 previous errors
Some errors occurred: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: Could not compile `screeps-wooter`.

error: build failed

error: 'cargo web' exited with a non-zero exit code: exit code: 101

I have tried compiling using both screeps-game-api 0.0.8 and 0.0.10.

As I am new to rust, I'm not really sure where to start.

daboross commented 6 years ago

Thanks for reporting this! I really haven't been maintaining this repository well recently.

daboross commented 6 years ago

After pushing some updates to the screeps-in-rust-via-wasm tools and this repository, I think I have it building. I pushed a workaround for the nightly issue, so I'm building with the 2018-08-05 nightly

I'm now using cargo-web 0.6.15, cargo-screeps 0.1.4, and the latest update from this repository with screeps-game-api 0.1.0.

$ cargo install -f cargo-web
...
$ cargo install -f cargo-screeps
...
$ git pull
...
$ git rev-parse HEAD
ed32a3d92764fee96da94b75a329c41c8167a350
$ cargo web --version
cargo-web 0.6.15
$ cargo screeps --version
cargo-screeps 0.1.4
$ rustc --version
rustc 1.30.0-nightly (73c78734b 2018-08-05)
$ cargo screeps --build
cargo_screeps: compiling...
   Compiling proc-macro2 v0.4.12
   Compiling unicode-xid v0.1.0
   Compiling serde v1.0.71
   Compiling ryu v0.2.3
   Compiling num-traits v0.2.5
   Compiling itoa v0.4.2
   Compiling base-x v0.2.2
   Compiling stdweb v0.4.8
   Compiling discard v1.0.3
   Compiling cfg-if v0.1.5
   Compiling scoped-tls v0.1.2
   Compiling proc-macro2 v0.2.3
   Compiling log v0.4.3
   Compiling fern v0.5.6
   Compiling quote v0.4.2
   Compiling quote v0.6.6
   Compiling syn v0.12.15
   Compiling syn v0.14.8
   Compiling num-traits v0.1.43
   Compiling serde_json v1.0.26
   Compiling enum_primitive v0.1.1
   Compiling serde_derive v1.0.71
   Compiling stdweb-derive v0.4.0
   Compiling stdweb-internal-macros v0.1.0
   Compiling screeps-game-api v0.1.0
   Compiling screeps-starter-rust v0.0.0 (file:///home/daboross/Projects/Rust/screeps-starter-rust)
    Finished release [optimized] target(s) in 1m 24s
    Garbage collecting "screeps-starter-rust.wasm"...
    Processing "screeps-starter-rust.wasm"...
    Finished processing of "screeps-starter-rust.wasm"!
cargo_screeps: compiled.

Let me know if this works for you too!

I'm getting back into screeps recently and it'd be great to have some new users of the screeps-in-rust-via-wasm toolset to help test usability.

daboross commented 6 years ago

Ah, I hadn't pushed code. This repository should be actually updated now.

WooterTheTroubleshooter commented 6 years ago

Ok, so I have got it working now. I was running into some trouble with my own repository, however updating the original repository worked.

I'll post my actions here for others having the same issues.

Really interested to see if I am able to convert/redesign my current strategy using rust.

$ cargo screeps --build
cargo_screeps: compiling...
    Finished release [optimized] target(s) in 0.03s
    Garbage collecting "screeps-wooter.wasm"...
    Processing "screeps-wooter.wasm"...
    Finished processing of "screeps-wooter.wasm"!

error: 'cargo web' generated unexpected JS prefix! This means it's updated without 'cargo screeps' also having updates. Please report this issue to https://github.com/daboross/screeps-in-rust-via-wasm/issues and include the first ~30 lines of /home/wouter/Screeps/rust/target/wasm32-unknown-unknown/release/screeps-wooter.js
$ rm Cargo.lock
$ cargo screeps --build
cargo_screeps: compiling...
   Compiling proc-macro2 v0.4.12
   Compiling serde v1.0.71
   Compiling ryu v0.2.3
   Compiling cfg-if v0.1.5
   Compiling log v0.4.3
   Compiling fern v0.5.6
   Compiling quote v0.6.6
   Compiling syn v0.14.8
   Compiling serde_json v1.0.26
   Compiling serde_derive v1.0.71
   Compiling stdweb-internal-macros v0.1.0
   Compiling stdweb-derive v0.4.0
   Compiling stdweb v0.4.8
   Compiling screeps-game-api v0.1.0
   Compiling screeps-starter-rust v0.0.0 (file:///home/wouter/Screeps/rust)
    Finished release [optimized] target(s) in 1m 08s
    Garbage collecting "screeps-starter-rust.wasm"...
    Processing "screeps-starter-rust.wasm"...
    Finished processing of "screeps-starter-rust.wasm"!

error: error: multiple js files found in /home/wouter/Screeps/rust/target/wasm32-unknown-unknown/release
$ rm -rf target/wasm32-unknown-unknown/release/
$ cargo screeps --build
cargo_screeps: compiling...
   Compiling itoa v0.4.2
   Compiling discard v1.0.3
   Compiling cfg-if v0.1.5
   Compiling scoped-tls v0.1.2
   Compiling serde v1.0.71
   Compiling ryu v0.2.3
   Compiling num-traits v0.2.5
   Compiling stdweb v0.4.8
   Compiling log v0.4.3
   Compiling fern v0.5.6
   Compiling num-traits v0.1.43
   Compiling enum_primitive v0.1.1
   Compiling serde_json v1.0.26
   Compiling screeps-game-api v0.1.0
   Compiling screeps-starter-rust v0.0.0 (file:///home/wouter/Screeps/rust)
    Finished release [optimized] target(s) in 37.76s
    Garbage collecting "screeps-starter-rust.wasm"...
    Processing "screeps-starter-rust.wasm"...
    Finished processing of "screeps-starter-rust.wasm"!
cargo_screeps: compiled.
daboross commented 6 years ago

@WooterTheTroubleshooter Thanks for the update! I'll add the tip about cleaning the target dir to the README.

Just to let you know, there was one error in the code I'd written to fix cargo-screeps which made it only work for projects named screeps-starter-rust. With the latest release it should actually be fixed to work for any other projects with different names.

WooterTheTroubleshooter commented 6 years ago

@daboross Thank you, I was wondering about that.