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

diesel_cli connection info string error #1188

Closed
dlukes opened this Issue Sep 22, 2017 · 15 comments

Comments

Projects
None yet
3 participants
@dlukes

dlukes commented Sep 22, 2017

I'm trying to set up a new database using diesel_cli, but I get the following error:

$ diesel setup --database-url postgres://myuser:mypassword@localhost/mydb
Creating database: mydb
missing "=" after "postgres://myuser:mypassword@localhost/postgres" in connection info string

I'm not sure where I should put the = sign, especially since the connection info string reported in the error refers to the postgres database, whereas the database URL I specified refers to the database I'm trying to initialize... Thanks for any pointers!

Versions

  • Rust: 1.22.0-nightly
  • Diesel: 0.16.0
  • Database: PostgreSQL 9.6.5
  • Operating System Ubuntu 12.04.5 LTS

Feature Flags

  • diesel_cli: sqlite, postgres
@Eijebong

This comment has been minimized.

Member

Eijebong commented Sep 22, 2017

I think you just need to put it between quotes --database-url "postgres://myuser:mypassword@localhost/mydb"

@dlukes

This comment has been minimized.

dlukes commented Sep 22, 2017

Doesn't seem to help :( I also tried using an env variable and the .env file, but the result is the same.

@Eijebong

This comment has been minimized.

Member

Eijebong commented Sep 22, 2017

Oh sorry, I can't read... It's not the shell that's saying that, it's PG itself. Do you have any special character in the password ? If so I think you need to percent encode them

@dlukes

This comment has been minimized.

dlukes commented Sep 22, 2017

That was my thinking as well initially :) To be more precise, I didn't know specifically I needed to percent encode them (thanks for the info!) but I figured special characters might be a problem, so I changed my password and still no dice... And even when I put a wrong password in there with just ASCII letters, the error is still the same (i.e. it doesn't seem to even get to the stage where it tries to connect to the database cluster).

If it's relevant somehow, this is a PostgreSQL server installed from source, running under my user on a server I don't have root on. Connecting to databases with the psql command line tool works fine.

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 22, 2017

Can you confirm that you installed diesel_cli with PG support enabled? (Either by doing cargo install diesel_cli or `cargo install diesel_cli --no-default-features --features "postgres")

@dlukes

This comment has been minimized.

dlukes commented Sep 22, 2017

I wanted both sqlite and postgres support, so what I did was cargo install diesel_cli --no-default-features --features 'sqlite postgres'. Maybe I'll try reinstalling with just postgres then?

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 22, 2017

It should work fine if compiled with both SQLite and PG support.

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 22, 2017

Unfortunately I'm unable to reproduce. Does your username or password contain any special characters?

@dlukes

This comment has been minimized.

dlukes commented Sep 22, 2017

Does your username or password contain any special characters?

Username is plain ASCII letters, the password I originally tried it with contains also numbers and a period, but I changed it and the behavior remained the same (see previous comment).

FWIW, when I try to use a sqlite database instead of postgres, the database is successfully created but running the initial migration fails with a syntax error, which is weird because when I feed the migration script to the command line sqlite3 client, it doesn't choke on it.

So maybe something went wrong during compilation? As I mentioned, both the sqlite and postgres libraries are installed in nonstandard locations, I had to set LIBRARY_PATH for cargo to find them, but once I'd done that, the compilation seemingly went fine and no errors were reported.

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 22, 2017

Can you provide the output of otool -L $(which diesel) or the equivalent command on your OS to show the shared libraries used in the diesel binary?

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 22, 2017

Also just to confirm, you're seeing this error message when using exactly the URL postgres://myuser:mypassword@localhost/mydb?

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 22, 2017

One other thing you could try is changing the scheme to postgresql -- The short form was only recognized by libpq shipped with PG 9.2 and later (though if you're using an earlier version of libpq than that you'll likely have other issues).

I suspect that you're loading some older versions of libpq (possibly system libraries), and need to set your LD_LIBRARY_PATH before running it

@dlukes

This comment has been minimized.

dlukes commented Sep 22, 2017

Also just to confirm, you're seeing this error message when using exactly the URL postgres://myuser:mypassword@localhost/mydb?

yes

Can you provide the output of otool -L $(which diesel) or the equivalent command on your OS to show the shared libraries used in the diesel binary?

This was good thinking, thank you very much! I did ldd $(which diesel) and it dawned on me based on the output that I'd compiled diesel against my custom-installed version of various libraries sitting alongside the sqlite and postgres libraries, but at runtime, diesel was finding the system versions of those :)

So thanks again, after setting LD_LIBRARY_PATH, everything works as expected. The error must have been the result of some weird interaction with the older versions of the libraries. Closing.

@dlukes dlukes closed this Sep 22, 2017

@dlukes

This comment has been minimized.

dlukes commented Sep 22, 2017

I suspect that you're loading some older versions of libpq (possibly system libraries), and need to set your LD_LIBRARY_PATH before running it

Yes you're exactly right :) Thanks again!

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 22, 2017

No problem

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