paketo-buildpacks / maven

A Cloud Native Buildpack that builds Maven-based applications from source
Apache License 2.0
32 stars 14 forks source link

Buildpack error "unable to state file /usr/bin/python3.10" #361

Open rrileyca opened 1 month ago

rrileyca commented 1 month ago

When I run the maven buildpack, I get this cryptic error. Google turns up nothing. I'm not really sure where to start with this. I think the error is coming from within the container? If not it's extra strange because I have /usr/bin/python3.10.

I'm using pack --version 0.35.1

Paketo Buildpack for Maven 6.18.3
  unable to create application layer
  failed to generate expected metadata
  unable to create file listing for /workspace
  unable to create file listing
  error walking path /workspace
  unable to stat file /usr/bin/python3.10
  stat /usr/bin/python3.10: no such file or directory
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51

Full logs is below:

===> DETECTING
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
target distro name/version labels not found, reading /etc/os-release file
10 of 26 buildpacks participating
paketo-buildpacks/ca-certificates   3.8.6
paketo-buildpacks/bellsoft-liberica 10.9.0
paketo-buildpacks/syft              2.1.0
paketo-buildpacks/maven             6.18.3
paketo-buildpacks/executable-jar    6.11.3
paketo-buildpacks/apache-tomcat     8.2.0
paketo-buildpacks/apache-tomee      1.10.4
paketo-buildpacks/liberty           4.3.0
paketo-buildpacks/dist-zip          5.8.5
paketo-buildpacks/spring-boot       5.31.2
===> RESTORING
===> BUILDING
target distro name/version labels not found, reading /etc/os-release file

Paketo Buildpack for CA Certificates 3.8.6
  https://github.com/paketo-buildpacks/ca-certificates
  Build Configuration:
    $BP_EMBED_CERTS                    false  Embed certificates into the image
    $BP_ENABLE_RUNTIME_CERT_BINDING    true   Deprecated: Enable/disable certificate helper layer to add certs at runtime
    $BP_RUNTIME_CERT_BINDING_DISABLED  false  Disable certificate helper layer to add certs at runtime
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
  CA Certificates: Contributing to layer
    Added 151 additional CA certificate(s) to system truststore
    Writing env.build/SSL_CERT_DIR.append
    Writing env.build/SSL_CERT_DIR.delim
    Writing env.build/SSL_CERT_FILE.default

Paketo Buildpack for BellSoft Liberica 10.9.0
  https://github.com/paketo-buildpacks/bellsoft-liberica
  Build Configuration:
    $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
    $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
    $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
    $BP_JVM_VERSION              21                                                           the Java version
  Launch Configuration:
    $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
    $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
    $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
    $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
    $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
    $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
    $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
    $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
    $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
    $BPL_JMX_PORT                5000                                                         configure the JMX port
    $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
    $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
    $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
    $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
    Using Java version 21 from BP_JVM_VERSION
  BellSoft Liberica JDK 21.0.4: Contributing to layer
    Downloading from https://github.com/bell-sw/Liberica/releases/download/21.0.4+9/bellsoft-jdk21.0.4+9-linux-amd64.tar.gz
    Verifying checksum
    Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jdk
    Adding 297 container CA certificates to JVM truststore
    Writing env.build/JAVA_HOME.override
    Writing env.build/JDK_HOME.override
  BellSoft Liberica JRE 21.0.4: Contributing to layer
    Downloading from https://github.com/bell-sw/Liberica/releases/download/21.0.4+9/bellsoft-jre21.0.4+9-linux-amd64.tar.gz
    Verifying checksum
    Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jre
    Adding 297 container CA certificates to JVM truststore
    Writing env.launch/BPI_APPLICATION_PATH.default
    Writing env.launch/BPI_JVM_CACERTS.default
    Writing env.launch/BPI_JVM_CLASS_COUNT.default
    Writing env.launch/BPI_JVM_SECURITY_PROVIDERS.default
    Writing env.launch/JAVA_HOME.default
    Writing env.launch/JAVA_TOOL_OPTIONS.append
    Writing env.launch/JAVA_TOOL_OPTIONS.delim
    Writing env.launch/MALLOC_ARENA_MAX.default
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/java-opts
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jvm-heap
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/link-local-dns
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-configurer
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jmx
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jfr
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/openssl-certificate-loader
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-classpath-9
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/debug-9
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/nmt
  Java Security Properties: Contributing to layer
    Writing env.launch/JAVA_SECURITY_PROPERTIES.default
    Writing env.launch/JAVA_TOOL_OPTIONS.append
    Writing env.launch/JAVA_TOOL_OPTIONS.delim

Paketo Buildpack for Syft 2.1.0
  https://github.com/paketo-buildpacks/syft
    Downloading from https://github.com/anchore/syft/releases/download/v1.12.2/syft_1.12.2_linux_amd64.tar.gz
    Verifying checksum
    Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default

Paketo Buildpack for Maven 6.18.3
  https://github.com/paketo-buildpacks/maven
  Build Configuration:
    $BP_EXCLUDE_FILES                                                                                                   colon separated list of glob patterns, matched source files are removed
    $BP_INCLUDE_FILES                                                                                                   colon separated list of glob patterns, matched source files are included
    $BP_JAVA_INSTALL_NODE                 false                                                                         whether to install Yarn/Node binaries based on the presence of a package.json or yarn.lock file
    $BP_MAVEN_ACTIVE_PROFILES                                                                                           the active profiles (comma separated: such as: p1,!p2,?p3) to pass to Maven
    $BP_MAVEN_ADDITIONAL_BUILD_ARGUMENTS                                                                                the additionnal arguments (appended to BP_MAVEN_BUILD_ARGUMENTS) to pass to Maven
    $BP_MAVEN_BUILD_ARGUMENTS             -DskipTests=true -P make-exe-jar,kubernetes package -pl my/project -am -T 2C  the arguments to pass to Maven
    $BP_MAVEN_BUILT_ARTIFACT              my/project/target/project-1.0.5-SNAPSHOT.jar                                  the built application artifact explicitly.  Supersedes $BP_MAVEN_BUILT_MODULE
    $BP_MAVEN_BUILT_MODULE                                                                                              the module to find application artifact in
    $BP_MAVEN_DAEMON_ENABLED              false                                                                         use maven daemon
    $BP_MAVEN_POM_FILE                    pom.xml                                                                       the location of the main pom.xml file, relative to the application root
    $BP_MAVEN_SETTINGS_PATH                                                                                             the path to a Maven settings file
    $BP_MAVEN_VERSION                     3                                                                             the Maven version
    $BP_NODE_PROJECT_PATH                                                                                               configure a project subdirectory to look for `package.json` and `yarn.lock` files

Paketo Buildpack for Maven 6.18.3
  unable to create application layer
  failed to generate expected metadata
  unable to create file listing for /workspace
  unable to create file listing
  error walking path /workspace
  unable to stat file /usr/bin/python3.10
  stat /usr/bin/python3.10: no such file or directory
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51
dmikusa commented 1 month ago

That part of the code is walking your application files. I suspect that it's probably hitting a symlink that doesn't resolve because the target isn't in the image. I don't know why else it would be looking for that file, nothing in the buildpack directly uses or expects Python to be present.

What is your pack build command? If you're not specifically setting the --path argument, it will use the present directory as the content for your application. Either check that directory or the directory specified by --path and see if there are extra files that don't need to be sent for the build.

You can tell pack to ignore files via the project.toml file. You can usually speed up builds by ignoring unnecessary files as well because it's less for pack to copy into the container.

rrileyca commented 1 month ago

Thanks for the quick response.

The pack command looks like this:

pack build $IMAGE_NAME --path ~/git/myproject \
 --volume ${BINDINGS_DIR}:/platform/bindings \
 --volume ~/.pack-m2:/home/cnb/.m2:rw \
 -B paketobuildpacks/builder-jammy-full \
 -e PACK_VOLUME_KEY=packvolume \
 -e BP_JVM_VERSION=21 \
 -e BP_MAVEN_BUILT_ARTIFACT=${APP_TO_BUILD}/target/${APP_NAME}-1.0.5-SNAPSHOT.jar \
 -e BP_MAVEN_BUILD_ARGUMENTS="-DskipTests=true -P profile1,profile2 package -pl ${APP_TO_BUILD} -am -T 2C"

The m2 volume mount is a separate m2 folder from my ~/.m2 because I used to get all sorts of permission errors.

The ${BINDINGS_DIR} is used to mount TLS certificates.

dmikusa commented 1 month ago

I wouldn't expect that to cause the issues you're seeing. I would suggest checking what's in ~/git/myproject. Look for hidden folders, things unnecessary to your app being built and put them in the ignore list.

Everything in ~/git/myproject will be copied into the workspace of the build, unless you specifically ignore it.


Another thing you could try would be to point --path to the target JAR/WAR of your application build. Run Maven locally to build it, and then run pack build with the modified path. This will change so that the build is only the contents of your JAR/WAR, which should eliminate any stray files from making it into the container also.