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

cargo chef cook altering Cargo.toml and breaking projects in workspace #31

Closed
pythoneer opened this issue Dec 9, 2020 · 3 comments
Closed

Comments

@pythoneer
Copy link

pythoneer commented Dec 9, 2020

EDIT:

I realized that issue #27 is absolutely relevant here. I think its all just fine the way things are working and i guess i understand the reasons behind it – delete all the "code" and just fill the target folder with the compiled dependencies. The "real" code comes back later in the build stage. Silly me. I just tried it with a little project and it worked (just using the docker commands) and i wanted it to extend to a more complex one and in the middle of development "take a look" at what cargo-chef would do to see if there are some problems already i need to fix before going the full docker route.

And now that i think i know how this hole thing is working – i feel a little bit stupid. But i agree with the comments in the other issue that a warning would be helpful to make the people using it aware that a) you're not supposed to use it "locally" and b) it will delete and alter your files on purpose and maybe with an explanation why. I'll try to get my test project working without "test cooking" locally and use it like it is supposed to :P

---- original message

I think this is related to issue #4 but i have the additional problem that cargo chef cook is also breaking my project by altering the respective Cargo.toml files from each project under a workspace. I have prepared a test project for you to replicate https://github.com/pythoneer/docker_build_test

cargo make build runs fine
cargo chef prepare --recipe-path recipe.json looks like its doing OK (can't tell if the *.json is correct)
cargo chef cook --recipe-path recipe.json breaks the project and
cargo make build does not build the project anymore because the Cargo.toml files are just wrong now

I don't know if this is not supposed to work in the first place because i haven't found a hint in the README (maybe the section about Limitations and caveats but to be honest i don't really understand that 100%)

I hope this helps. If you need any more information i am glad to help.

(love your book 👍 )

@pythoneer
Copy link
Author

pythoneer commented Dec 9, 2020

Sry, i now realized that cargo chef cook is also deleting the content of project files like shared/src/lib.rs and server/src/main.rs .. therefore my test project is currently broken ... i'll fix it later because i am unfortunately on my way now.

EDIT:

I restored the example and can confirm that the changes are happening i assumed above. After running cargo chef cook --recipe-path recipe.json not only the Cargo.toml files are altered (incorrectly) source files are also altered, either completely emptied out or weirdly replaced with different code.

after running the command client/src/lib.rs is just empty as is shared/src/lib.rs. In server/src/main.rs all source code is replaced simply with

fn main() {}

As additional information – and why i relate this to issue #4 – i am importing shared into the client and server with shared = { path = "../shared" }

@LukeMathWalker
Copy link
Owner

This is by design, as discussed in #4 - cargo-chef is designed for usage in containers to leverage Docker layer caching, where changes to the source are considered ephemeral given that the container itself is ephemeral.

Some of the improvements discussed in #4 should hopefully avoid this surprise in the future.

@pythoneer
Copy link
Author

Thanks for you answer i think that concludes my journey here :) ... i'll close this issue as it is redundant and almost a duplicate from issue #4 / #27

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