leoafarias / fvm

Flutter Version Management: A simple CLI to manage Flutter SDK versions.
https://fvm.app
MIT License
4.44k stars 213 forks source link

[Question] Cannot change ownership to uid 397546, gid 5000: Invalid argument #587

Open RodrigoDornelles opened 6 months ago

RodrigoDornelles commented 6 months ago

I don't know if it's a problem with flutter or fvm, but using only flutter had no problems.

Before creating a bug report please make check the following

FVM Version: 2.4.1
___________________________________________________

FVM config found:
___________________________________________________

Project: app
Directory: /app
Version: 3.13.9
Project Flavor: None selected
___________________________________________________

Version is currently cached locally.

Cache Path: /root/fvm/versions/3.13.9
Channel: false
SDK Version: 3.13.9

IDE Links
VSCode: .fvm/flutter_sdk
Android Studio: /app/.fvm/flutter_sdk

Configured env paths:
___________________________________________________

Flutter:

Dart:

FVM_HOME:
not set

Describe the bug I can install flutter but not use it normally

To Reproduce fvm install 3.13.9 fvm use 3.13.9 fvm pub get

Expected behavior Normal use

Logs

root@9b15a017dc87:/app# fvm flutter pub get
Downloading Gradle Wrapper...                                      411ms
/bin/tar: gradle/wrapper/gradle-wrapper.properties: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradle/wrapper/gradle-wrapper.jar: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradle/wrapper: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradle: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradlew: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradlew.bat: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: NOTICE: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: Exiting with failure status due to previous errors
Downloading Gradle Wrapper...                                       87ms
/bin/tar: gradle/wrapper/gradle-wrapper.properties: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradle/wrapper/gradle-wrapper.jar: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradle/wrapper: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradle: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradlew: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: gradlew.bat: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: NOTICE: Cannot change ownership to uid 397546, gid 5000: Invalid argument
/bin/tar: Exiting with failure status due to previous errors
Flutter could not download and/or extract https://storage.googleapis.com/flutter_infra_release/gradle-wrapper/fd5c1f2c013565a3bea56ada6df9d2b8e96d56aa/gradle-wrapper.tgz. Ensure you have network connectivity and all of the required dependencies listed at flutter.dev/setup.
The original exception was: ProcessException: The command failed
  Command: tar -xzf /tmp/flutter-fvm/versions/3.13.9/bin/cache/downloads/storage.googleapis.com/flutter_infra_release/gradle-wrapper/fd5c1f2c013565a3bea56ada6df9d2b8e96d56aa/gradle-wrapper.tgz -C /tmp/flutter-fvm/versions/3.13.9/bin/cache/artifacts/gradle_wrapper.

Desktop (please complete the following information):

Additional context running in docker as root

vbrandl commented 2 weeks ago

I have the same problem using podman and running as non-root (inside the container/build process, I am root, but I run docker build as non-root user). When building my dockerfile, I get the described permission errors. Running the build as root works, but I'd prefer building using a non-root user...

Were you able to fix this?

mcmah309 commented 1 week ago

I have the same issue as well. Running as root does not fix it for me.

RodrigoDornelles commented 1 week ago

@vbrandl @mcmah309 I have an opensource docker image that works around this problem.

https://github.com/RodrigoDornelles/docker-images/blob/db6f47bde097cf55a0ad87bf5de4bac715ea2147/sdkman/docker-entrypoint.sh#L13

how to use:

podman run --rm -v /tmp:/tmp -v $(pwd):/app -w /app rodrigodornelles/sdkman:latest
sdk install java 17.0.9-oracle
fei 3.13.9
flutter pub get
flutter build apk
mcmah309 commented 1 week ago

You're the man! :raised_hands:

I pulled your solution out into a script that works on my container instance

#!/bin/bash
# `./fvm_tar_workaround.sh on`  # To install the custom tar
# `./fvm_tar_workaround.sh off` # To remove the custom tar
set -euo pipefail

install_custom_tar() {
  # Create the custom tar script with the flag as default
  echo -e "#!/bin/bash\nset -e\n/bin/tar \"\$@\" --no-same-owner" > /tmp/tar
  chmod +x /tmp/tar
  if [ ! -d /usr/local/bin ]; then
    mkdir -p /usr/local/bin
  fi
  mv /tmp/tar /usr/local/bin/tar
  if ! echo "$PATH" | grep -q "/usr/local/bin"; then
    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc
  fi
  if which tar | grep -q "/usr/local/bin/tar"; then
    echo "Custom tar command installed successfully."
  else
    echo "Failed to install the custom tar command."
  fi
}

uninstall_custom_tar() {
  if [ -f /usr/local/bin/tar ]; then
    rm /usr/local/bin/tar
    echo "Custom tar command removed successfully."
  else
    echo "Custom tar command is not installed."
  fi
}

if [ "$1" == "on" ]; then
  install_custom_tar
elif [ "$1" == "off" ]; then
  uninstall_custom_tar
else
  echo "Usage: $0 {on|off}"
  exit 1
fi

I'm not familiar with the fvm implementation, so not sure what needs to get done on that side to fix this bug