1

I am learning Rust, and saw a post on http://reddit.com/r/rust yesterday for Nickel. As a Node.js developer in my free time, I was interested in checking this out.

I downloaded the Rust 1.0.0-beta DMG from http://rust-lang.org.

I followed the Hello World tutorial precisely, and when I execute cargo run in my Terminal, I am receiving the following error:

Robs-MacBook-Pro:nickel-demo rob$ cargo run
   Compiling nickel-demo v0.0.1 (file:///Users/rob/Workbench/nickel-demo)
src/main.rs:4:1: 4:21 error: an external crate named `nickel` has already been imported into this module [E0259]
src/main.rs:4 extern crate nickel;
              ^~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `nickel-demo`.

The Hello World main.rs file for the Nickel Demo looks like this:

extern crate nickel;

#[macro_use] extern crate nickel_macros;
extern crate nickel;

use nickel::Nickel;

fn main() {
    let mut server = Nickel::new();

    server.utilize(router! {
        get "**" => |_req, _res| {
            "Hello world!"
        }
    });

    server.listen("127.0.0.1:6767");
}

As I was typing this code into my editor, I specifically thought it was weird that I was declaring extern crate nickel; twice in the file. After receiving the error I refactored the code to this:

extern crate nickel;

#[macro_use] extern crate nickel_macros;

use nickel::Nickel;

...

And I get this error:

Robs-MacBook-Pro:nickel-demo rob$ cargo run
   Compiling nickel-demo v0.0.1 (file:///Users/rob/Workbench/nickel-demo)
     Running `target/debug/nickel-demo`
Listening on http://127.0.0.1:6767
Ctrl-C to shutdown server
thread '<main>' panicked at 'arithmetic operation overflowed', /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.3.11/src/server/mod.rs:90
An unknown error occurred
tshepang
  • 12,111
  • 21
  • 91
  • 136
robabby
  • 2,160
  • 6
  • 32
  • 47
  • 1
    I work on the nickel team. I'm sorry you had such a bad first experience. The examples are out of date and I'm trying to get that fixed soon. However, the problem that you ran into seems to be a real bug in either hyper or rust itself I think. I created an issue to track it: https://github.com/nickel-org/nickel.rs/issues/185 – Christoph Apr 13 '15 at 13:25
  • @Christoph Yay, I helped find a bug! :) Thanks for following up with me, and for logging the issue. I look forward to a resolution. I just checked the Nickel GitHub page as well and it looks like the current build is failing, also. – robabby Apr 13 '15 at 13:40

1 Answers1

4

The arithmetic operation overflowed bug seems to be an upstream issue. It also affects hyper which nickel depends on.

See https://github.com/seanmonstar/num_cpus/issues/2

As a temporary workaround use cargo build --release to prevent the checks altogether.

Christoph
  • 26,519
  • 28
  • 95
  • 133