Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ruby): Make coinstallable #35742

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

EyeCantCU
Copy link
Member

@EyeCantCU EyeCantCU commented Dec 3, 2024

This makes Ruby 3.1-3.3 coinstallable, allowing for multiple versions of Ruby to be installed at the same time. This will help us simplifiy a lot of package manifests we have for Ruby as we'll be able to build gems for multiple Ruby versions within the same definition, without creating an entirely separate manifest

To full leverage this, we'll need to make SCA changes: chainguard-dev/melange#1676

And then rebuild the world for Ruby (purging the cmd:ruby dependency that all packages have right now, causing the resolver to fail unless you explicitly request a version of Ruby that aligns with the gem)

@octo-sts octo-sts bot added the bincapz/pass bincapz/pass Bincapz (aka. malcontent) scan didn't detect any CRITICALs on the scanned packages. label Dec 4, 2024
@EyeCantCU EyeCantCU force-pushed the coinstallable-ruby branch 4 times, most recently from 9e5f587 to e0657c0 Compare December 4, 2024 22:19
Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the build error, let me analyze and provide a solution:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: The symlink creation step in the ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs when trying to create symbolic links for Ruby binaries. The script is attempting to create links that already exist, likely due to multiple binary files being linked to the same destination.

• Suggested Fix: Modify the symlink creation loop in the ruby-3.1-base subpackage pipeline to handle existing files:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}

          mv ${{targets.destdir}}/* ${{targets.contextdir}}

          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin

          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Added -f flag to ln commands to force overwrite of existing symlinks
  • This prevents the error when attempting to create duplicate symlinks
  • Maintains the same functionality while handling pre-existing files

• Additional Notes:

  • The original error occurs during the subpackage creation phase
  • This is a common issue when dealing with multiple versions of Ruby in the same system
  • The solution ensures idempotent symlink creation

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Configuration

• Failure Point: Symbolic link creation in ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symlink creation step where it's trying to create links that already exist, likely due to multiple symlinks being created for the same target.

• Suggested Fix: Modify the symlink creation logic in the subpackage pipeline to handle existing files:

subpackages:
  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/ || true
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}} || true
          done

• Explanation:

  • Added -f flag to ln commands to force overwrite existing links
  • Added || true to prevent failures if links already exist
  • This ensures idempotent symlink creation while preserving the intended functionality

• Additional Notes:

  • The error suggests there may be duplicate symlink creation attempts
  • Using -f flag is safe here since we're in a clean build environment
  • The original functionality is maintained while handling edge cases

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Build Configuration

• Failure Point: Symbolic link creation in ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symlink creation step in the ruby-3.1-base subpackage pipeline. The build is attempting to create symbolic links that already exist, likely due to duplicate link creation attempts.

• Suggested Fix: Modify the symlink creation logic in the ruby-3.1-base subpackage pipeline to check for existing links:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Added -f flag to ln commands to force overwrite of existing links
  • This prevents the error when links already exist while ensuring proper symlink creation
  • Using symbolic links (-s) with force (-f) is a common pattern for managing executable links

• Additional Notes:

  • The error suggests there may be leftover files from previous build attempts
  • The force flag is safe here since we're in a clean build environment
  • This is a common issue when creating multiple symlinks in package management

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the error output, I'll analyze and provide a solution:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Configuration/Pipeline

• Failure Point: Symbolic link creation in the ruby-3.1-base subpackage pipeline

• Root Cause Analysis:
The error occurs during the symlink creation step where multiple attempts are being made to create the same symbolic links, likely due to overlapping operations in the subpackage pipeline.

• Suggested Fix:
Modify the subpackage pipeline to ensure clean target directories and prevent duplicate symlink creation:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          
          # Clean move all contents
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          # Ensure clean directory state
          rm -rf ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          # Create symlinks with explicit checks
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            if [ ! -e "${{targets.destdir}}/usr/bin/$bn" ]; then
              ln -s /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/$bn
            fi
            if [ ! -e "${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}" ]; then
              ln -s /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
            fi
          done

• Explanation:

  • The error occurs because the symlink creation is attempting to create links that already exist
  • The modified pipeline ensures clean directory states before creating symlinks
  • Added explicit checks before creating each symlink to prevent conflicts
  • The rm -rf step ensures no stale symlinks exist before creating new ones

• Additional Notes:

  • This is a common issue in package management systems when handling symlinks
  • The solution maintains the intended functionality while preventing duplicate operations
  • Consider adding error handling for edge cases

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the error output, I'll analyze and provide a solution:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: Symbolic link creation during ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symlink creation step in the ruby-3.1-base subpackage pipeline. The issue appears to be an attempt to create duplicate symbolic links or a collision in the link targets.

• Suggested Fix:
Modify the subpackage pipeline to ensure unique symlink creation:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          # Add removal of existing links
          rm -f ${{targets.destdir}}/usr/bin/*
          rm -f ${{targets.contextdir}}/usr/bin/*
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  1. The error indicates a file collision during symlink creation
  2. Adding rm -f commands ensures no stale links exist before creating new ones
  3. Using ln -sf forces symlink creation even if target exists
  4. This approach prevents link collisions while maintaining proper package structure

• Additional Notes:

  • The -f flag with ln and rm makes the operations more robust
  • This solution maintains the intended functionality while preventing link conflicts
  • Consider adding error checking around the link creation process

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: Symbolic link creation in ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the creation of symbolic links in the subpackage pipeline. The issue appears to be caused by an attempt to create a duplicate symbolic link or the target directory already containing links.

• Suggested Fix: Modify the subpackage pipeline to handle existing files:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation: Adding the -f flag to ln commands will force the creation of symbolic links even if the target already exists. This prevents the error when links may already be present while ensuring the correct links are established.

• Additional Notes:

  • The error suggests there may be remnants from previous builds or conflicting link creation
  • Using force (-f) is safe in this context since we're in a clean build environment
  • The symbolic links are important for proper Ruby version management

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: Symbolic link creation in ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the creation of symbolic links in the subpackage pipeline. The issue appears to be an attempt to create a symbolic link that already exists, likely due to multiple links being created for the same target.

• Suggested Fix:
Modify the subpackage pipeline section to ensure unique symlinks:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          # Add check to avoid duplicate symlinks
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            if [ ! -e "${{targets.destdir}}/usr/bin/$bn" ]; then
              ln -s /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/$bn
            fi
            if [ ! -e "${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}" ]; then
              ln -s /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
            fi
          done

• Explanation: The modified script adds checks before creating symbolic links to prevent attempts to create duplicate links. This should resolve the "File exists" error while maintaining the required functionality.

• Additional Notes:

  • The error suggests that the build system is trying to create symbolic links that already exist
  • This could happen if multiple Ruby versions are installed or if the symlink creation logic is running multiple times
  • The fix ensures idempotency in the symlink creation process

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: Symlink creation during ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symlink creation step in the ruby-3.1-base subpackage pipeline where it's trying to create symbolic links for Ruby binaries but encountering existing files

• Suggested Fix:
Modify the symlink creation section in the ruby-3.1-base subpackage pipeline to handle existing files:

  - name: "${{package.name}}-base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  1. Adding -f flag to ln commands forces creation of symlinks even if destination exists
  2. This prevents the error when files already exist while ensuring correct symlinks are created
  3. Using symbolic links with -sf is standard practice for managing multiple versions of binaries

• Additional Notes:

  • The error suggests there may be leftover files from previous build attempts
  • The -f flag is a safe approach since we're working in an isolated build environment
  • This is a common pattern when packaging different versions of the same software

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: Symlink creation in ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symlink creation step in the ruby-3.1-base subpackage pipeline. It's trying to create a symlink that already exists, likely due to the way the binary links are being created.

• Suggested Fix: Modify the symlink creation logic in the ruby-3.1-base subpackage pipeline to handle existing files:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation: Adding the -f flag to the ln commands will force the creation of the symlinks even if they already exist, preventing the "File exists" error. This is safe in this context since we're working in a clean build environment and want to ensure the links are created correctly.

• Additional Notes:

  • The error occurs in the final packaging step, after the successful build of Ruby
  • The symlink creation is part of setting up the proper binary paths for the Ruby installation
  • Using force flag is appropriate here since we control the entire build environment

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Build Configuration

• Failure Point: Symbolic link creation in the ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symbolic link creation step where it's trying to create links that already exist. This typically happens when the link targets are being created multiple times or there's a collision in the link creation process.

• Suggested Fix: Modify the subpackage pipeline to ensure clean link creation:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/$bn
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Added -f flag to ln commands to force creation of links even if they exist
  • This ensures clean link creation without failures from pre-existing links
  • The symbolic links will be properly overwritten if they already exist

• Additional Notes:

  • The error suggests there might be multiple attempts to create the same links
  • Using force flag (-f) is a common solution for package management systems
  • Alternative approach would be to remove existing links first, but force flag is cleaner

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the error log, I'll analyze and provide a solution:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Configuration/Pipeline

• Failure Point: Symbolic link creation in the ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symbolic link creation step where it's trying to create links that already exist, suggesting a collision in the symlink creation process

• Suggested Fix: Modify the symlink creation logic in the subpackage pipeline to handle existing files:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Adding the -f flag to the ln commands will force the creation of symbolic links even if they already exist
  • This prevents the error when trying to create links that may have been created in a previous step
  • The symlinks will be properly updated to point to the correct targets

• Additional Notes:

  • The error suggests there might be a race condition or duplicate operation in the pipeline
  • Using force flag is safe in this context since we're in a clean build environment
  • This is a common issue when dealing with multiple binary versions and symlinks

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: Subpackage pipeline for ruby-3.1-base during symlink creation

• Root Cause Analysis: The error occurs during the symlink creation step in the ruby-3.1-base subpackage pipeline. The script is attempting to create symbolic links but encountering existing files, likely due to duplicate link creation attempts.

• Suggested Fix: Modify the symlink creation logic in the ruby-3.1-base subpackage pipeline to handle existing files:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Adding -f flag to ln commands forces the creation of links even if target exists
  • This prevents the error when files already exist while ensuring correct symlink creation
  • The symlinks will point to the correct Ruby executable locations

• Additional Notes:

  • The error suggests there may be multiple attempts to create the same symlinks
  • Using force flag is safe here since we're in a clean build environment
  • The symlinks are important for proper Ruby version management

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the error output, I'll analyze and provide a solution:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Configuration/Pipeline

• Failure Point: Subpackage pipeline for ruby-3.1-base during symbolic link creation

• Root Cause Analysis: The error occurs in the subpackage pipeline when trying to create symbolic links. The issue appears to be with duplicate link creation attempts or an existing file interfering with the linking process.

• Suggested Fix: Modify the subpackage pipeline to handle existing files more gracefully:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Added -f flag to ln commands to force overwrite of existing links
  • This prevents failures when links already exist
  • The symbolic links will be properly created even if destination exists

• Additional Notes:

  • The error suggests there may be leftover files from previous build attempts
  • Using force flag is safe here since we're in a clean build environment
  • Alternative approach would be to rm existing files first, but force flag is more efficient

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the build error, I'll analyze and provide a solution:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: Symbolic link creation during ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs in the subpackage pipeline when trying to create symbolic links. Multiple attempts to create the same symbolic link are occurring, likely due to the loop creating both regular and versioned links.

• Suggested Fix: Modify the subpackage pipeline to avoid duplicate link creation:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            if [ -f "$bin" ]; then
              bn="$(basename $bin)"
              ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/$bn
              ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
            fi
          done

• Explanation:

  • Added a check if [ -f "$bin" ] to only process regular files
  • Using ln -sf to force link creation and overwrite existing links
  • Ensuring unique paths for versioned and non-versioned links

• Additional Notes:

  • The original error occurs because the symlink creation attempts to create duplicate links
  • The modified version adds safety checks and forces link creation
  • Using -f with ln ensures idempotency of the operation

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the error output, I'll analyze and provide a solution:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Configuration

• Failure Point: Symlink creation during ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symlink creation step in the ruby-3.1-base subpackage pipeline. The issue appears to be an attempt to create duplicate symlinks or a collision in the symlink creation process.

• Suggested Fix:
Modify the subpackage pipeline script to handle existing files:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  1. Adding -f flag to ln commands will force the creation of symlinks even if they already exist
  2. This prevents the error when trying to create duplicate symlinks
  3. Using symbolic (-s) links ensures proper package management and updates

• Additional Notes:

  • The error suggests there might be leftover files from previous build attempts
  • The -f flag is a safe solution as we're working in an ephemeral build environment
  • This is a common issue when creating multiple symlinks in package management systems

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the error output, I'll analyze and provide a solution:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: Symbolic link creation in the ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symlink creation step in the subpackage pipeline. The issue appears to be an attempt to create duplicate symlinks or a collision in the symlink creation process.

• Suggested Fix: Modify the symlink creation logic in the ruby-3.1-base subpackage pipeline to handle existing files:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}

          mv ${{targets.destdir}}/* ${{targets.contextdir}}

          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin

          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Added -f flag to ln commands to force overwrite of existing symlinks
  • This prevents the "File exists" error while ensuring proper symlink creation
  • The symbolic links will be created even if target files already exist

• Additional Notes:

  • Using -f with ln is safe in this context since we're in a clean build environment
  • The error suggests there might be multiple attempts to create the same symlinks
  • This solution ensures idempotency in the symlink creation process

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Build Configuration

• Failure Point: Symbolic link creation in ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the creation of symbolic links in the subpackage pipeline. The issue appears to be an attempt to create a duplicate symbolic link where one already exists.

• Suggested Fix: Modify the subpackage pipeline to handle existing links:

  - name: "${{package.name}}-base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin

          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation: Adding the -f flag to the ln commands will force the creation of the symbolic links, overwriting any existing ones. This prevents the "File exists" error while ensuring the links are created correctly.

• Additional Notes:

  • The error suggests that the build process is trying to create links that already exist
  • Using ln -sf is a common solution for handling pre-existing symlinks in package management
  • This approach maintains idempotency in the build process

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Build Configuration

• Failure Point: Symlink creation in ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the symbolic link creation step in the ruby-3.1-base subpackage pipeline. The script is attempting to create symbolic links that already exist, likely due to multiple binary targets being linked to the same destination.

• Suggested Fix: Modify the symlink creation logic in the ruby-3.1-base subpackage pipeline to handle existing links:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Adding the -f flag to ln commands will force the creation of symbolic links even if they already exist
  • This prevents the error when attempting to create duplicate links
  • The symbolic links will be properly updated even if they existed from a previous step

• Additional Notes:

  • The error suggests there may be multiple attempts to create the same links
  • Using -f is a safe approach since we're in an isolated build environment
  • The links are being created with correct relative paths

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

• Detected Error: "ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists"

• Error Category: Build Configuration

• Failure Point: Symlink creation in ruby-3.1-base subpackage pipeline

• Root Cause Analysis: The error occurs during the creation of symlinks in the subpackage pipeline. The script is attempting to create symbolic links that already exist, likely due to multiple binary files trying to create links with the same name.

• Suggested Fix: Modify the symlink creation logic in the subpackage pipeline to handle existing files:

  - name: "${{package.name}}-base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Adding -f flag to ln commands forces creation of symlinks even if target exists
  • This prevents the error when links already exist while ensuring correct symlinks are created
  • The symlinks are still created with the correct targets, just forcing overwrite if needed

• Additional Notes:

  • This is a common issue when packaging Ruby due to its multiple executables and versioned binaries
  • The fix maintains the package structure while handling file conflicts gracefully
  • Alternative approach would be to remove existing links first, but forcing is cleaner

• References:

Copy link
Contributor

octo-sts bot commented Dec 4, 2024

Gen AI suggestions to solve the build error:

Based on the build error, I'll analyze and provide a solution:

• Detected Error: ln: /home/build/melange-out/ruby-3.1-base/usr/bin/.1: File exists

• Error Category: Configuration

• Failure Point: During the ruby-3.1-base subpackage pipeline when creating symbolic links

• Root Cause Analysis: The symbolic link creation is failing because the target file already exists. This happens in the subpackage pipeline where it's trying to create links for the Ruby binaries.

• Suggested Fix:
Modify the subpackage pipeline section to ensure unique symlinks:

  - name: "${{package.name}}-base"
    description: "Ruby ${{vars.major-minor-version}} base"
    pipeline:
      - runs: |
          mkdir -p ${{targets.contextdir}}
          mv ${{targets.destdir}}/* ${{targets.contextdir}}
          
          mkdir -p ${{targets.destdir}}/usr/bin
          mkdir -p ${{targets.contextdir}}/usr/bin
          
          # Add removal of existing links
          rm -f ${{targets.destdir}}/usr/bin/*
          rm -f ${{targets.contextdir}}/usr/bin/*
          
          for bin in ${{targets.contextdir}}/usr/libexec/ruby/${{vars.stdlib-version}}/*; do
            bn="$(basename $bin)"
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.destdir}}/usr/bin/
            ln -sf /usr/libexec/ruby/${{vars.stdlib-version}}/$bn ${{targets.contextdir}}/usr/bin/$bn${{vars.major-minor-version}}
          done

• Explanation:

  • Adding rm -f commands ensures no pre-existing links exist
  • Using ln -sf forces symlink creation even if target exists
  • This prevents the "File exists" error while maintaining proper linking

• Additional Notes:

  • The error occurs during the final packaging phase, not during the build itself
  • This is a common issue when dealing with multiple Ruby versions or previous failed builds
  • The fix preserves the intended functionality while making it more robust

• References:

@EyeCantCU EyeCantCU force-pushed the coinstallable-ruby branch 3 times, most recently from fcc8bf5 to dd1c8f9 Compare December 5, 2024 01:23
@EyeCantCU
Copy link
Member Author

Note, making these changes now, before SCA changes are merged, will not impact existing packages. But after SCA changes land, it would be ideal that we rebuild the Ruby world

This makes Ruby 3.1-3.3 coinstallable, allowing for multiple versions of
Ruby to be installed at the same time. This will help us simplifiy a lot
of package manifests we have for Ruby as we'll be able to build gems for
multiple Ruby versions within the same definition, without creating an
entirely separate manifest

To full leverage this, we'll need to make SCA changes:

chainguard-dev/melange#1676

And then rebuild the world for Ruby (purging the cmd:ruby dependency
that all packages have right now, causing the resolver to fail unless
you explicitly request a version of Ruby that aligns with the gem)

Signed-off-by: RJ Sampson <[email protected]>
ruby-3.3.yaml Show resolved Hide resolved
@EyeCantCU EyeCantCU merged commit 7876bce into wolfi-dev:main Dec 6, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bincapz/pass bincapz/pass Bincapz (aka. malcontent) scan didn't detect any CRITICALs on the scanned packages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants