Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDiesel-cli requires empty Cargo.toml file before setup can be run #1300
Comments
This comment has been minimized.
|
The reason is this: You can run `diesel setup` in basically any directory of your project, and it will look for the root directory (which is where the migrations directory needs to live) by search for a Cargo.toml.
Immediate action item from this issues: Document this behavior.
Refactoring for the future: The code in diesel-cli that does this is actually not very clever, and I doubt it works will with a cargo workspace setup. Cargo has a `cargo locate-project` command, though, and we should consider switching to calling this.
… Am 11.11.2017 um 16:50 schrieb Sam Whited ***@***.***>:
Setup
Versions
• Diesel: 0.16.0
Feature Flags
• diesel: no-default-features, postgres
Problem Description
Diesel setup looks for Cargo.toml file unnecessarily.
What are you trying to accomplish?
Setup a database for the first time in a non-Rust project.
$ diesel setup
Unable to find Cargo.toml in this directory or any parent directories.
$ touch Cargo.toml
$ diesel setup
Creating database: demodb
I would not expect diesel to require or care about having an empty Cargo.toml file in the project directory. My database migrations may be stored in a separate repo from my project or my project might not be in Rust at all and merely using diesel-cli for migrations.
Checklist
• [x ] I have already looked over the issue tracker for similar issues.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
This comment has been minimized.
SamWhited
commented
Nov 11, 2017
|
That makes sense, and documentation would make this less confusing. Maybe it could also search for a |
This comment has been minimized.
SamWhited
commented
Nov 12, 2017
|
It just occured to me that there might be an easy fix for this: if you don't have a Cargo.toml and are in the root of the project you can tell you're in the root because the |
This comment has been minimized.
Except the command you're complaining about is
You can always specify the directory with the
You probably just want |
sgrif
closed this
Jan 8, 2018
This comment has been minimized.
SamWhited
commented
Jan 8, 2018
•
It's also used to create the database initially, so if we're spinning up the database for the first time (eg. on a new devvm) and the migrations are already created it will currently complain that cargo.toml doesn't exist even though it has a way to detect the root directory and the project doesn't need a cargo.toml. Maybe it could look for the migrations directory and cargo.toml? Then it could still be used to create the database and wouldn't panic every time with a confusing error message. diesel database setup is a good workaround though, I can live with that, but when you look in the help "setup" appears the obvious command to run, and having that panic and spit out a confusing error message still doesn't feel ideal. |
This comment has been minimized.
|
As I said, if you just want to create the database and not setup the whole project (which involves creating the migrations directory, generating default migrations, etc), you should run
I don't think it's common to use Diesel without cargo, so I doubt this is something many are likely to run into. |
SamWhited commentedNov 11, 2017
•
edited
Setup
Versions
Feature Flags
Problem Description
Diesel setup looks for
Cargo.tomlfile unnecessarily.What are you trying to accomplish?
Setup a database for the first time in a non-Rust project.
I would not expect diesel to require or care about having an empty Cargo.toml file in the project directory. My database migrations may be stored in a separate repo from my project or my project might not be in Rust at all and merely using diesel-cli for migrations.
Checklist