question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Projects with "type": "zip" are extracted to a subpath, breaking devfiles

See original GitHub issue

Describe the bug

Since https://github.com/eclipse/che/issues/14206 is resolved, Theia can handle projects downloaded as zips. However, typically zips (e.g. from github) unzip to a folder including the branch name, which causes the project to be unzipped to a subpath – e.g.

/projects/console-java-simple/console-java-simple-master

instead of

/projects/console-java-simple/

This breaks many devfile commands that depend on the project being in a known location.

Che version

  • nightly

Steps to reproduce

Start a workspace using the devfile

metadata:
  name: zip-project
projects:
  - name: console-java-simple
    source:
      location: 'https://github.com/che-samples/console-java-simple/archive/master.zip'
      type: zip
components:
  - id: redhat/java11/latest
    type: chePlugin
  - mountSources: true
    memoryLimit: 512Mi
    type: dockerimage
    volumes:
      - name: m2
        containerPath: /home/user/.m2
    image: 'quay.io/eclipse/che-java11-maven:nightly'
    alias: maven
    env:
      - value: /home/user/.m2
        name: MAVEN_CONFIG
      - value: >-
          -XX:MaxRAMPercentage=50 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10
          -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4
          -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true
          -Xms20m -Djava.security.egd=file:/dev/./urandom -Duser.home=/home/user
        name: MAVEN_OPTS
      - value: >-
          -XX:MaxRAMPercentage=50 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10
          -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4
          -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true
          -Xms20m -Djava.security.egd=file:/dev/./urandom
        name: JAVA_OPTS
      - value: >-
          -XX:MaxRAMPercentage=50 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10
          -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4
          -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true
          -Xms20m -Djava.security.egd=file:/dev/./urandom
        name: JAVA_TOOL_OPTIONS
apiVersion: 1.0.0
commands:
  - name: maven build
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/console-java-simple'
        type: exec
        command: mvn clean install
        component: maven
  - name: maven build and run
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/console-java-simple'
        type: exec
        command: mvn clean install && java -jar ./target/*.jar
        component: maven

Expected behavior

Project is unzipped to the correct folder.

Runtime

  • OpenShift 3.11

Screenshots

Screenshot from 2019-10-07 15-59-54

Additional Context

Impacts https://github.com/eclipse/che/issues/14733

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
l0rdcommented, Oct 23, 2019

@amisevsk @ibuziuk you can use git archive instead of zip.

1reaction
amisevskcommented, Oct 23, 2019

PR open https://github.com/eclipse/che-devfile-registry/pull/127

@akurinnoy with the changes in the PR, no changes to the factory plugin are required.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I expand only a particular subdirectory of a zipTree?
If I want files d and e to be copied to another folder, I have to copy the entirety of file.zip to a...
Read more >
Extract files from zip without keeping the structure using ...
This opens file handles of members of the zip archive, extracts the filename and copies it to a target file (that's how ZipFile.extract...
Read more >
ExtractFiles@1 - Extract files v1 task | Microsoft Learn
Use this task to extract a variety of archive and compression files, such as .7z, .rar, .tar.gz, and .zip. Syntax. YAML Copy.
Read more >
Python's zipfile: Manipulate Your ZIP Files Efficiently
In this guided tutorial, you'll learn how to manipulate ZIP files using Python's zipfile module from the standard library.
Read more >
How can I force unzip / zip not to create a subdirectory when I ...
Stripping the version number from your project sources is a bad idea; you should just extract normally and use a ln -s if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found