Ogeon / rust-on-raspberry-pi

[OUTDATED] Instructions for how to cross compile Rust projects for the Raspberry Pi
292 stars 15 forks source link

Docker image: problems with permissions on OS X #10

Closed ravicious closed 8 years ago

ravicious commented 8 years ago

First I want to say that I tried many different ways to cross-compile Rust code to RasPi 3B and this one seems to be the most promising so far.

I'm on OS X 10.11.3, Docker 1.10.2, Rust 1.7.0. I have successfully built the Docker image, but I ran into some permission problems as I tried to cross-compile my project.

If I run cargo build on host environment and then try to run the image, I get the following error:

$ docker run -v /Users/rav/Projects/rust/guessing_game:/home/cross/project rust-17-pi-cross build 
*** Extracting target dependencies ***

*** Cross compiling project ***
could not remove build directory

To learn more, run the command again with --verbose.

If I run cargo clean first, then I get this error:

$ docker run -v /Users/rav/Projects/rust/guessing_game:/home/cross/project rust-17-pi-cross build --verbose
*** Extracting target dependencies ***

*** Cross compiling project ***
    Updating registry `https://github.com/rust-lang/crates.io-index`
couldn't prepare build directories

Caused by:
  Permission denied (os error 13)

I looked for ways to solve it on Docker level, but none of them helped (like adding :z to the end of the volume path). Also, I believe most of them assume the image is running SELinux, while this Dockerfile uses Debian.

Pinging @schnupperboy, as from the issue tracker I see he's the one who added Docker support, so maybe he knows something that I don't. :wink:

Ogeon commented 8 years ago

I'm afraid I can't tell, off the top of my head, what the problem may be, but I'm thinking that it would be a good idea to set up some Travis tests for this, if it's solved.

ravicious commented 8 years ago

I just ran into "Web Development with Docker on Mac OS X":

If you want to access files within the /Users share from your Docker container, then you should do so as a user with uid 1000, otherwise you will likely have permissions errors.

I added RUN usermod -u 1000 cross to the Dockerfile right after the line that creates the group and the user. Currently the image is building, I'll let you know if it helps.

Ogeon commented 8 years ago

That would be great.

ravicious commented 8 years ago

It solved my problem! I feel so relieved now, thank you for maintaining this repo! I was able to compile and then run the program on Raspi after changing the uid. The submitted PR #11 fixes that.

Ogeon commented 8 years ago

Nice! I was just about to merge it. It's also nice to know that it's possible to get it working on OS X. Was there anything special you had to do to get it working? Something that might be useful to add to the guide?

schnupperboy commented 8 years ago

@ravicious Thanks for investigating this issue and glad to hear that it works now. I added a comment to your PR.

@Ogeon I will have a look later this week on how to set up a Travis test for the Docker build with a Linux host OS. Also, I will open a new issue for this.

But i'm afraid that there is no way you can set up a Travis test with a OS X host environment since Docker requires running a Linux virtual machine as a workaround on OS X. AFAIK Travis CI simply does not support this.

Ogeon commented 8 years ago

I will have a look later this week on how to set up a Travis test for the Docker build with a Linux host OS. Also, I will open a new issue for this.

That would be fantastic. I'm just afraid that the build process may be too long for Travis. It's still worth a try, so I'll go ahead and enable Travis for this repo (edit: done).

But i'm afraid that there is no way you can set up a Travis test with a OS X host environment since Docker requires running a Linux virtual machine as a workaround on OS X. AFAIK Travis CI simply does not support this.

Looks like that's the case, unfortunately. Still, it's better to have any tests, than none.

ravicious commented 8 years ago

@schnupperboy Cool, I updated the PR!

@Ogeon

Was there anything special you had to do to get it working? Something that might be useful to add to the guide?

The process was pretty straightforward and I didn't have to do anything special other than installing the Docker Toolbox and following its "Getting started" guide.

Ogeon commented 8 years ago

It may be good to at least mention that the toolbox is necessary if it's not part of what's usually installed with Docker.

ravicious commented 8 years ago

I don't think the whole toolbox is necessary, it was just the first "official" way to install Docker I found.

Thanks for merging both PRs!

Ogeon commented 8 years ago

I don't think the whole toolbox is necessary, it was just the first "official" way to install Docker I found.

I guess people will figure it out, then.

Thanks for merging both PRs!

Thanks for helping :smile: