Closed mhristache closed 7 years ago
Thank you for the bug report!
The easiest way to make it work is to place your libraries inside the directory that you're building.
[dependencies.<project_name>]
path = "./<project_name>"
If this is impossible, and you can't publish the library to crates.io, then your next best option is to modify the docker command line to pass something like -v "$(dirname $(pwd))":/home/rust/src --workdir /home/rust/src/mymainproject"
to Docker. This mounts the parent directory into docker, then uses --workdir
to switch to the actual directory you want to build.
There's a bunch of variations on this idea you can play with; see the Docker CLI ref and let me know what works for you.
Oh, also, you could write a shell script to do complex builds, put it in the directory you mount as /home/rust/src
, and call it instead of Cargo.
First of all, thanks for the quick reply and for your time.
I tried the first suggestion (-v "$(dirname $(pwd))":/home/rust/src --workdir /home/rust/src/mymainproject
)and seem to work fine.
But now I get a new error:
error: failed to open: /home/rust/src/<project>/target/debug/.cargo-lock
Apparently user rust
does not have write permission in the project dir. How is this supposed to work? FYI, UID 1000 is already used on my system.
Thanks
Right now, the default setup only works for UID 1000, which I agree is a bit of a weakness. You'll probably need to run sudo chown -R myuser:mygroup .
inside your project directory to put things back the way they were, and try adding -u $(id -u $USER)
to your Docker command line. If this isn't enough to get it working, you may need to rebuild the Docker image to use a different UID, or pass flags like -v ~/.cargo:/home/rust/.cargo
.
Oh, or you can build a derived Docker file, copy the source code into the image using ADD
, run the build, and copy the binary back out with docker cp
. Basically, the trickier the stuff you want to do, the more you'll need to learn about Docker. :-/
Hi
I tried to use
rust-musl-builder
but it failed when updating the dependencies In Cargo.toml:I am using local libraries in the project I am trying to build, so I have something like this in Cargo.toml:
The path cannot be found because the local directory where the main project is stored is mounted inside the docker container, but the local libs are outside.
Not sure how/if this kind of setup can be supported in a nice way but I am reporting it anyhow :).