Skip to content

Conversation

@Philipp-M
Copy link

I had issues when using this with NixOS and the android-sdk in the /nix/store which is completely read-only.

It copied the file from there and kept the permissions of it, running cargo apk a second time resulted in an Permissions denied error, because the file couldn't be overwritten.

This fix just sets the permissions to standard 644 permissions, which is AFAIK recommended for files like .so.
I think this could also be fixed, by just setting the user write permission bit of the file (a matter of preference I guess).

…nix/store) to avoid a Permissions Denied Error
std::fs::copy(path, out)?;
fs::copy(path, out.clone())?;
#[cfg(target_family = "unix")]
fs::set_permissions(out, fs::Permissions::from_mode(0o644))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should at the very least have a comment documenting this workaround for Nix 😉

@kuviman
Copy link

kuviman commented Jun 28, 2023

Not sure if it matters but there is Permissions::set_readonly in std which makes it not unix-specific. There is tho a note that it is equivalent to chmod a+w, which is different from 644.

@justinmoon
Copy link

This would be nice to have. I just hit this error using Nix. I could try to take it over if @kuviman has moved on ...

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

Successfully merging this pull request may close these issues.

4 participants