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

Installing diesel_cli without e.g. feature `sqlite` can lead to cryptic errors #310

Closed
deadalusai opened this Issue Apr 27, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@deadalusai

deadalusai commented Apr 27, 2016

I have installed diesel_cli without SQLite support (as the SQLite libraries are not installed on my system):

cargo install diesel_cli --no-default-features --features "postgres"

Invoking diesel with an invalid database url generates a cryptic error message:

> diesel database setup --database-url=https://localhost/test-db
thread '<main>' panicked at 'internal error: entered unreachable code: The backend function should ensure we never get here.', C:\Users\benjaminf\.cargo\registry\src\github.com-88ac128001ac3a9a\diesel_cli-0.6.1\src\database.rs:73

While the fix is simple (use the correct protocol), I did have to examine the source code to puzzle out the error message. Perhaps an improved error message could be implemented?

panic!(format!("The {0} backend is not supported. You must recompile with feature `{0}` enabled", other))
@sgrif

This comment has been minimized.

Member

sgrif commented Apr 27, 2016

@mcasper We should probably improve the check if SQLite isn't present, since we won't have that branch as a catch-all.

@deadalusai Your issue is that you're not giving a valid PG URL. It should start with postgres:// or postgresql://

sgrif added a commit that referenced this issue Apr 27, 2016

Give an error message when an invalid PG url is given to CLI
Right now we assume URLs that aren't for PG are for SQLite instead.
However, the CLI crate can be compiled without SQLite support. In this
case, we end up hitting the `unreachable` branch in our match statement.
I'd like to eventually change this code to use an enum, similar to
codegen. In the short term though, we just need to improve the error
message.

Fixes #310

sgrif added a commit that referenced this issue Apr 27, 2016

Give an error message when an invalid PG url is given to CLI
Right now we assume URLs that aren't for PG are for SQLite instead.
However, the CLI crate can be compiled without SQLite support. In this
case, we end up hitting the `unreachable` branch in our match statement.
I'd like to eventually change this code to use an enum, similar to
codegen. In the short term though, we just need to improve the error
message.

Fixes #310

@sgrif sgrif closed this in #311 Apr 27, 2016

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