akhildevelops / devcontainer-features

devcontainer features
MIT License
8 stars 6 forks source link

/opt/android should be owned by dev container user instead of root to be writeable #7

Open vorburger opened 3 months ago

vorburger commented 3 months ago

I just wanted to let you know that I've (only very briefly, without doing any further debugging) tried this feature out, for https://github.com/google/android-fhir/issues/2481, and it seems to me that there is a file permission issue?

In https://github.com/google/android-fhir/pull/2482 (here) I originally tried:

"features": {
    "ghcr.io/akhildevelops/devcontainer-features/android-cli:0": {}

This installed just fine, but when a Gradle Script tried to write to $ANDROID_HOME, which with this is set to /opt/android it failed, because that directory is owned by root but the UID when running a GitHub Codespace Dev Container is vscode.

./gradlew dokkaHtml

(...)

> Configure project :workflow:benchmark
Checking the license for package Android SDK Build-Tools 33.0.1 in /opt/android/licenses
License for package Android SDK Build-Tools 33.0.1 accepted.
Preparing "Install Android SDK Build-Tools 33.0.1 v.33.0.1".
Warning: Failed to read or create install properties file.

FAILURE: Build failed with an exception.

* Where:
Build file '/workspaces/android-fhir/workflow/benchmark/build.gradle.kts' line: 3

* What went wrong:
An exception occurred applying plugin request [id: 'androidx.benchmark']
> Failed to apply plugin 'androidx.benchmark'.
   > Could not create task ':lockClocks'.
      > Failed to install the following SDK components:
            build-tools;33.0.1 Android SDK Build-Tools 33.0.1
        The SDK directory is not writable (/opt/android)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 11s
5 actionable tasks: 5 up-to-date

I was able to work-around this with sudo chown -R vscode:vscode /opt/android/, but doing that probably shouldn't be required.

akhildevelops commented 3 months ago

Thanks.... Can you please provide a PR for this.