You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code inside main does not seem to have any effect, I started with a few hundred lines but now I just have a logging statement and it still happens.
It's not just stdout that's broken, the runtime was also way too short to be executing the original code.
But on my local system, if I don't do one of the above, I consistently get a binary that does nothing.
It might be platform dependent - I could swear a very similar Dockerfile worked on Windows, but now it's failing on Ubuntu. But I am no longer near the Windows machine so I can't verify this.
Notes
Output of cargo version: cargo 1.36.0 (c4fcfb7 2019-05-15)
mverleg
changed the title
Two steps build in docker produces broken binary in Docker
Two steps relase build in docker produces noop binary
Jul 25, 2019
Cargo detects if it needs to rebuild based on mtime of the files. Your dummy main.rs has a timestamp newer than the source added by the COPY command (AFAIK, COPY retains the original timestamps). You'll need to add something like touch src/main.rs after copying to ensure that the timestamp is newer than the dummy.
Ow that makes a lot of sense, I overlooked that. I had previously used the same setup with multiple source files and never thought about it breaking down if it's just main.rs. Thanks!
Steps
TLDR version:
clone https://github.com/markKL1/java_gym_1_rust_solution --branch binary_noop_issue
docker build -t rust_gym_1 . && docker run rust_gym_1
Long version:
I have a Dockerfile like this:
(Where the two
build
s are for caching (#2644) so I want to keep that.)Cargo.toml:
src/main.rs:
Then I run (in Bash):
Problem
This build succeeds, but the executable does nothing, just exits without any output and with exit code 0.
Analysis
I have found things that fix it:
build
).touch
a source file andbuild
a third time.The code inside main does not seem to have any effect, I started with a few hundred lines but now I just have a logging statement and it still happens.
It's not just stdout that's broken, the runtime was also way too short to be executing the original code.
But on my local system, if I don't do one of the above, I consistently get a binary that does nothing.
It might be platform dependent - I could swear a very similar Dockerfile worked on Windows, but now it's failing on Ubuntu. But I am no longer near the Windows machine so I can't verify this.
Notes
Output of
cargo version
: cargo 1.36.0 (c4fcfb7 2019-05-15)Linking info (possibly related issue):
This seems like a pretty nasty issue to debug, and at the same time pretty niche...
I'm not sure if it's Docker or Cargo or something else.
The text was updated successfully, but these errors were encountered: