Skip to content
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

Program exits with error code 3 when rocket.toml only has [global.databases] defined with no clear error message #2149

Closed
hmathsan opened this issue Apr 22, 2022 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@hmathsan
Copy link

Description

If rocket.toml only has the [global.databases] defined and it is on the first line of the file, the program will exit with code 3. But if there's a simple line break before [global.databases], the program will run as expected.

To Reproduce

cargo.toml:

[dependencies]
rocket = "0.5.0-rc.1"
diesel = { version = "^1.4.4", features = [ "postgres", "chrono" ] }

[dependencies.rocket_sync_db_pools]
version = "0.1.0-rc.1"
default-features = false
features = ["diesel_postgres_pool"]

main.rs:

use rocket_sync_db_pools::database;

#[macro_use] extern crate rocket;

#[database("postgres")]
struct PostgresDatabase(diesel::PgConnection);

#[launch]
fn rocket() -> _ {
    rocket::build()
        .attach(PostgresDatabase::fairing())
}

If rocket.toml is like this, the program will not start with error error: process didn't exit successfully: target\debug\rocket_bug_test.exe (exit code: 3)

[global.databases]
postgres = { url = "postgres://postgres:password@localhost:5432/challenge_alura" }

But if there's something before [global.databases] such as a simple line break, like this:

[global.databases]
postgres = { url = "postgres://postgres:password@localhost:5432/challenge_alura" }

The program will start as expected:

Configured for debug.
   >> address: 127.0.0.1
   >> port: 8000
   >> workers: 16
   >> ident: Rocket
   >> keep-alive: 5s
   >> limits: bytes = 8KiB, data-form = 2MiB, file = 1MiB, form = 32KiB, json = 1MiB, msgpack = 1MiB, string = 8KiB
   >> tls: disabled
   >> temp dir: C:\Users\ADMINI~1\AppData\Local\Temp\
   >> log level: normal
   >> cli colors: true
   >> shutdown: ctrlc = true, force = true, grace = 2s, mercy = 3s
Fairings:
   >> Shield (liftoff, response, singleton)
   >> 'postgres' Database Pool (ignite)
Shield:
   >> X-Content-Type-Options: nosniff
   >> X-Frame-Options: SAMEORIGIN
   >> Permissions-Policy: interest-cohort=()
Rocket has launched from http://127.0.0.1:8000

Expected Behavior

Rocket should start with rocket.toml only containing [global.databases] configuration.

Environment:

  • OS Distribution and Kernel: Windows 11 21H2
  • Rocket Version: 0.5.0-rc.1

Additional Context

I'm working on a personal project that used tokio_postgres and I was migrating to diesel. I followed Diesel's and Rocket's guides on how to get started. On the process the application simply refused to start with no clear error message. With trial and error I discovered the bug described above.

Before posting this issue I created a new blank project simply containing rocket, diesel and rocket_sync_db_pools to test if I had any dependencies conflicting with Rocket and the error still occurred the same way as the other project.

@hmathsan hmathsan added the triage A bug report being investigated label Apr 22, 2022
@SergioBenitez
Copy link
Member

SergioBenitez commented Apr 22, 2022

I can't replicate this on Windows 10 with Postgres 14. Could you post screen recordings of the failure (with the bad Rocket.toml) and the success (with the good Rocket.toml)? Also, try running with ROCKET_LOG_LEVEL=debug in the former case to see if you get any output.

@SergioBenitez
Copy link
Member

Spoke too soon: I was able to replicate this, but it has nothing to do with the format of the Rocket.toml file. Both versions spuriously cause the error. As such, this is a duplicate of #1931. Closing as such.

@SergioBenitez SergioBenitez added duplicate This issue or pull request already exists and removed triage A bug report being investigated labels Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants