Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Package Manager does not import from tarball

Discussion in 'Package Manager' started by Felix_K, Nov 14, 2022.

  1. Felix_K

    Felix_K

    Joined:
    May 30, 2017
    Posts:
    4
    I want to import a package from a tarball (.tar.gz) that I built myself from a package folder. (Importing from the package folder works.)
    However, I keep getting the following error

    [Package Manager Window] Cannot perform upm operation: Unable to add package [file:C:/Users/Willz/Downloads/PICOUnityIntegrationSDKv212/PICOUnityIntegrationSDKv212.tar.gz]:
    The file [C:\Users\Willz\AppData\Local\Temp\.tmp-20500-BThbXAHBaaKY\package.json] cannot be found [NotFound].
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()​

    I'm on Windows11 and Unity 2021.3.12.
    If I open the tarball it looks ok and the
    package.json
    is where it is supposed to be. Also there are no spaces or other problematic symbols (no " or ') in the path.

    Does someone have any clues about what is happening?
    (For now I can, of course, import from the normal folder. However, I'd like to embed the tarball in my project as a dependency. But this is a tangent here.)
     
  2. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    489
    Hi @Felix_K,

    Did you nest all the files under a "package" directory inside the tarball? That's necessary for the files to be extracted correctly. For instance, the path of
    package.json
    inside the tarball should actually be
    package/package.json
    . Can you verify if this is the case?
     
  3. Felix_K

    Felix_K

    Joined:
    May 30, 2017
    Posts:
    4
    Hi @maximeb_unity , thanks for the quick response. I tried both, tarballing the directory
    /packageName
    as well as the content of that directory. So in the first case,
    package.json
    would be in the root of the unpacked folder, in the 2nd it'd be under
    packageName/package.json
    . Neithor of these approaches worked.
    Am I screwing up somewhere else when creating the tarball? I'm using 7zip—first converting to
    .tar
    , then in a second step to
    .tar.gz
    —both using the default settings.

    I can also share the tarballs if that is of any help.

    Thx for helping out!
     
    Last edited: Nov 15, 2022
  4. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    489
    Hi @Felix_K,

    Sorry if I was unclear. The folder it needs to be is really exactly
    package
    , not
    (name of your package)
    . For instance, if you were to "right-click -> extract here" in 7-zip, it would extract the package contents to a folder named "package", even if your package name is e.g. "my-package".

    You can also use the PackageManager scripting API (
    UnityEditor.PackageManager.Client.Pack
    ) or use
    npm pack
    to produce a tarball with the right folder hierarchy.
     
    Felix_K likes this.
  5. Felix_K

    Felix_K

    Joined:
    May 30, 2017
    Posts:
    4
    Thanks for the clarification @maximeb_unity . In the end, using the Unity API solved it for me. The only real difference to the folder structure I built that I see is that it's a
    .tgz
    file instead of a
    .tar.gz
    , which I thought are the same. Whatever. Now it works. Thx!
     
  6. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    489
    Hi @Felix_K

    The standard extension that UPM uses for tarballs is indeed the ".tgz" short form but it should also work with ".tar.gz" (in fact, I just tested this successfully). In any case, I'm glad your problem is solved!