Skip to content

thread 'main' panicked at 'called Result::unwrap() when running migrate command #411

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

Closed
ducks opened this issue Aug 25, 2016 · 24 comments
Closed

Comments

@ducks
Copy link

ducks commented Aug 25, 2016

Hi all,

I'm trying to compile the rust backend and get down to the migrate command.

./target/debug/migrate

but then I get the following error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ConnectParams(StringError("url: Invalid character in scheme."))', ../src/libcore/result.rs:789
note: Run with `RUST_BACKTRACE=1` for a backtrace.

I updated the DATABASE_URL var in .env but that was all I changed.
I followed the naming suggestion and even just named the db 'cargo_registry'.

I'm running rustup using nightly.

Thanks!

@ducks
Copy link
Author

ducks commented Aug 25, 2016

stack backtrace:
   1:        0x10f696bda - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:        0x10f69d07f - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:        0x10f69c485 - std::panicking::default_hook::h9e30d428ee3b0c43
   4:        0x10f69ca96 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:        0x10f69c934 - std::panicking::begin_panic::hcb11a4dc6d779ae5
   6:        0x10f69c852 - std::panicking::begin_panic_fmt::h310416c62f3935b3
   7:        0x10f69c7b7 - rust_begin_unwind
   8:        0x10f6c7c20 - core::panicking::panic_fmt::hc5789f4e80194729
   9:        0x10ef709d2 - core::result::unwrap_failed::h451ad2af54f32921
  10:        0x10ef661a3 - _<core..result..Result<T, E>>::unwrap::ha9d67f84b238aecd
  11:        0x10ef7db00 - server::main::hdab9661dc694288c
  12:        0x10f69d63a - __rust_maybe_catch_panic
  13:        0x10f69bfc6 - std::rt::lang_start::h352a66f5026f54bd
  14:        0x10ef7ee89 - main

@alexcrichton
Copy link
Member

What's the DATABASE_URL you're using? For me it's:

export DATABASE_URL="postgres://postgres@localhost/cargo_registry"

@ducks
Copy link
Author

ducks commented Aug 26, 2016

Hmm, It looks like there is a slight typo in the comment

# Location of the *postgres* database. For example, if you have created a
# blank database locally named `cargo_registry`, this would be
# `postgres://postgres:@localhost/cargo_registry`.

There seems to be an extra : before the @.

I changed it to the following but I am still getting the same error it seems.
Is there anything else I would need to add in the .env?

export DATABASE_URL="postgres://postgres@localhost/cargo_registry"

I would be happy to file a ticket and submit a PR for the typo.

@alexcrichton
Copy link
Member

Ah that'd do it, and indeed PRs would be most welcome!

@ducks
Copy link
Author

ducks commented Aug 26, 2016

I am still getting the error for some reason.

I kind of feel like I'm missing something read doing something stupid.

The scheme should be the 'postgres://' but according to https://github.com/sfackler/rust-postgres/blob/master/src/url.rs#L201, '+', '-', '.', ':' are the only non alpha numeric chars allowed.

@alexcrichton
Copy link
Member

Could you try running with RUST_BACKTRACE=1 to precisely see what's panicking?

@ducks
Copy link
Author

ducks commented Aug 26, 2016

I'd posted that in a comment right below the original post.

@ducks
Copy link
Author

ducks commented Aug 26, 2016

Dunno how much it matters but here is the full stack trace from this AM.

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ConnectParams(StringError("url: Invalid character in scheme."))', ../src/libcore/result.rs:789
stack backtrace:
   1:        0x1055ce20a - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:        0x1055d00ff - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:        0x1055cf625 - std::panicking::default_hook::h9e30d428ee3b0c43
   4:        0x1055cfb76 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:        0x1055cfa14 - std::panicking::begin_panic::hcb11a4dc6d779ae5
   6:        0x1055cf932 - std::panicking::begin_panic_fmt::h310416c62f3935b3
   7:        0x1055cf897 - rust_begin_unwind
   8:        0x1055fa570 - core::panicking::panic_fmt::hc5789f4e80194729
   9:        0x10537f9f2 - core::result::unwrap_failed::h65351e0da6613351
  10:        0x105379571 - _<core..result..Result<T, E>>::unwrap::hbb69348fa5958082
  11:        0x105399ead - migrate::main::hfd66cb172e0f79db
  12:        0x1055d06ba - __rust_maybe_catch_panic
  13:        0x1055cf166 - std::rt::lang_start::h352a66f5026f54bd
  14:        0x1053adf19 - main

@alexcrichton
Copy link
Member

Hm not sure what's going on here :. Maybe it's something different from Linux postgres and OSX postgres?

@ducks
Copy link
Author

ducks commented Aug 26, 2016

That would not shock me. I have had problems before with osx vs linux.
I'll retry in debian.

Thanks.

@ducks
Copy link
Author

ducks commented Aug 27, 2016

Well that's a bit frustrating :)
I am getting the same error in debian it seems.

The top of .env

# Location of the *postgres* database. For example, if you have created a
# blank database locally named `cargo_registry`, this would be
# `postgres://postgres:@localhost/cargo_registry`.
export DATABASE_URL="postgres://postgres@localhost/cargo_registry"

The error does look different today so maybe something in nightly?

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ConnectParams(StringError("url: Invalid character in scheme."))', ../src/libcore/result.rs:789
stack backtrace:
   1:     0x7f6215d164f3 - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:     0x7f6215d1955d - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:     0x7f6215d18890 - std::panicking::default_hook::h9e30d428ee3b0c43
   4:     0x7f6215d18de8 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:     0x7f6215d18c82 - std::panicking::begin_panic::hcb11a4dc6d779ae5
   6:     0x7f6215d18bc0 - std::panicking::begin_panic_fmt::h310416c62f3935b3
   7:     0x7f6215d18b41 - rust_begin_unwind
   8:     0x7f6215d5374f - core::panicking::panic_fmt::hc5789f4e80194729
   9:     0x7f6215adb0a2 - core::result::unwrap_failed::h65351e0da6613351
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libcore/macros.rs:29
  10:     0x7f6215ad4c21 - _<core..result..Result<T, E>>::unwrap::hbb69348fa5958082
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libcore/result.rs:727
  11:     0x7f6215af47cd - migrate::main::h26e8889f6fcdab56
                        at /home/ducks/devel/rust/crates.io/src/bin/migrate.rs:17
  12:     0x7f6215d21026 - __rust_maybe_catch_panic
  13:     0x7f6215d18101 - std::rt::lang_start::h352a66f5026f54bd
  14:     0x7f6215b070c3 - main
  15:     0x7f621465cb44 - __libc_start_main
  16:     0x7f6215acaea8 - <unknown>
  17:                0x0 - <unknown>

Thanks again for the help

@ducks
Copy link
Author

ducks commented Aug 27, 2016

Well I got the migrate to work by using the raw url string instead of the cargo_registry::env but that seems wrong.

Ideas why that would work?

@ducks
Copy link
Author

ducks commented Aug 27, 2016

I then get an error with the server

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 12, message: "Failed to resolve address for \"file: nodename nor servname provided, or not known" }', ../src/libcore/result.rs:789
stack backtrace:
   1:        0x1104ebbda - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:        0x1104f207f - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:        0x1104f1485 - std::panicking::default_hook::h9e30d428ee3b0c43
   4:        0x1104f1a96 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:        0x1104f1934 - std::panicking::begin_panic::hcb11a4dc6d779ae5
   6:        0x1104f1852 - std::panicking::begin_panic_fmt::h310416c62f3935b3
   7:        0x1104f17b7 - rust_begin_unwind
   8:        0x11051cc20 - core::panicking::panic_fmt::hc5789f4e80194729
   9:        0x10fdc6252 - core::result::unwrap_failed::h451ad2af54f32921
  10:        0x10fdbba23 - _<core..result..Result<T, E>>::unwrap::ha9d67f84b238aecd
  11:        0x10fdd3360 - server::main::hdab9661dc694288c
  12:        0x1104f263a - __rust_maybe_catch_panic
  13:        0x1104f0fc6 - std::rt::lang_start::h352a66f5026f54bd
  14:        0x10fdd46e9 - main

I'm new to civet web server so have very little knowledge of it.

Still diggin' though.

@alexcrichton
Copy link
Member

Could you try printing out {:?} of the return value of the env function? Maybe some stray characters are making their way int here or something like that?

@ducks
Copy link
Author

ducks commented Aug 27, 2016

You nailed that one :)

"\"postgres://postgres@localhost/cargo_registry\""

The only diffs in my branch is that println and some Cargo.lock stuff so I'm not too sure what might be broken on my side. I can get the full diff or just push my branch?

Lemme know what else I can do or provide.

@alexcrichton
Copy link
Member

Aha that'd do it! What shell are you using?

@ducks
Copy link
Author

ducks commented Aug 29, 2016

zsh

@alexcrichton
Copy link
Member

Hm ok, you can probably do this by just removing the quotes in the export statement, although in theory that may not be necessary.

@ducks
Copy link
Author

ducks commented Aug 29, 2016

That does indeed return the correct string.

Gonna open an issue to update the comment in .env.sample for zsh users/anyone that might get that error :)

@ducks
Copy link
Author

ducks commented Aug 29, 2016

ugh, that also fixed my issues when starting the server as well.

thanks so much again for the help!

@ducks ducks closed this as completed Aug 29, 2016
@alexcrichton
Copy link
Member

Glad to hear! Want to send a PR to the .env file in the repo?

@ducks
Copy link
Author

ducks commented Aug 29, 2016

Hmm. Do you mean the .env.sample file?

@alexcrichton
Copy link
Member

Ah yes indeed!

@ducks
Copy link
Author

ducks commented Aug 29, 2016

Cool cool. PR inbound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants