Search Unity

Is it possible to set a dependency on the "latest" package version

Discussion in 'Package Manager' started by liortal, Nov 19, 2019.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    In gradle (and probably other systems), it's possible to denote a dependency not only by a specific version number but also using values such as "1.5+" or "LATEST".

    Is this possible using UPM?

    Our use case: our project's Git repository contains over 900 branches.
    The project has the game code as long as other stuff like editor extensions, code building the game and asset bundles, etc.

    I would like to extract the "external" stuff (e.g: build code) into its own UPM package (hosted on Github) so that we can actually include it in all development branches in that way and be able to upgrade it seamlessly as there are any updates.

    Doing so right now (without UPM) means we have to make code changes, then cherry pick or merge them back into any branch that requires them (and there are a lot of those).
     
  2. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    151
    Hi @liortal,

    Without going into too much detail I can tell you we are planning features around this request for the not-too-distant future :)
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Without going into detail you said it all basically ha ha :)

    The only question is whether this will land for 2018.4 releases as well, or only for the newer Unity versions ?
    The package manager is itself a package right? so i guess it can be updated without a full Unity upgrade.
     
  4. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    151
    Well exactly how we support this kind of workflow is to be determined. For example, we still plan to keep the dependency resolution deterministic so that anyone opening the same project will get the same dependencies. This is at odds with always getting the latest versions of dependencies every time you open a project. So all I'm saying for now is we're thinking of ways to support this request ;)
    Can't say for sure but this is a fairly major change so that limits how far back we are likely to backport.
    Package Manager is not currently a package that can be updated via Package Manager :)
     
    liortal likes this.
  5. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    530
    Any news on the "latest" feature? I am in 2019.3 right now and could really use it for my package to always have my users have the latest version @samuelb_unity :)

    I read a lot about the package manager and use it extensively. I have one observation: I think you are overthinking it and have somehow the impression you need to invent all mechanisms by yourself. I have used Maven in Java for ages now and it has all the package manager capabilities and more. Maven has exactly the same goal: provide a reproducible dependency chain. It allows you though to use snapshot releases, that are the equivalent to latest. Why not just reuse these battle-tested practices?
     
    liortal likes this.
  6. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    Unfortunately we don't have support these features yet, at least not exactly like this. What exactly is your use case? Do you mean that you would expect the Package Manager to automatically download the latest version of your package e.g. when users open Unity or at given intervals? Or would you expect users to have an update notification/mechanism for easily updating?

    While there are quite a lot of concepts and features that exist in other package managers today and it's true that we don't necessarily have to re-invent the wheel, the constraints of the Unity ecosystem are different enough from other package managers that it did not make sense to "just use Maven", or any other existing systems. (In fact, that's how the Unity Package Manager started: as a Unity-specific npm client.) For sure, we are constantly on the lookout for how things are done, and how we can adapt them into workflows that make sense with the Unity Editor and its tool pipelines. And then there are also features that are unique to Unity.
     
  7. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    530
    Thanks for stepping in @maximeb_unity. My use case is the following: I provide an sdk as a github package. Users should always be on the latest version except if they fix the link to a certain release with the existing hash syntax.

    In analogy to Maven (auto load snapshots after 24h, force update with -f) one flow could look like this: at project load time master is checked if there is a new revision and automatically installed. Also when manually checking for new versions in the package manager. And if you want to put a cherry on top you could use the github "prerelease" flag to determine if this is a snapshot release and do something with it, eg have a setting that disables snapshot usage. This way github packages would have an elegant way of having a beta channel.
     
  8. ndrm

    ndrm

    Joined:
    Jul 25, 2020
    Posts:
    8
  9. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    OK, I think I have a clearer idea of your use case.

    You can already implement something similar on your own (though it's a bit more work). Using a mix of [InitializeOnLoad], and some throttling logic (i.e. so it doesn't happen all the time but e.g. at most once a day), you can write code that will "re-add" the Git URL using
    Client.Add
    . This will make the Package Manager re-evaluate the Git dependency, so in the case of a branch, the latest commit on that branch will be used.

    Caveats:
    * Performance: currently we have no fast query implementation for known Git hosting services like Github, GitLab and Bitbucket, so anytime the Package Manager is asked to update a package (as in the example above), it will clone the repository again. We plan on improving this at some point, with lightweight checks using these services' APIs, better cloning/fetching strategies, etc.
    * UX: If you just call
    Client.Add
    without asking or telling users, that may be seen as poor UX. You might want your code to perform an online check, and only if it detects that the package should be updated prompt the user to suggest/inform them that they need to upgrade the SDK. For safety, you have similar SDK/API version checks implemented when using your service as well, and react to failures with the same upgrade notification.
     
  10. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    530
    Yes I actually do nearly the same already. Through a companion app I check online if there is an update and inform the user. Then I patch the package file manually and create a hash git url which triggers an update in unity. Works nicely except it's all hand coded instead of a unity functionality.
     
    maximeb_unity likes this.
  11. fschmeidl

    fschmeidl

    Joined:
    Aug 2, 2022
    Posts:
    3
    Two years later, I stumbled upon this post looking for exactly this feature. @maximeb_unity, @samuelb_unity Can you give an update on the current status?

    My use case is the following:
    We host several packages as scoped registries and use them in our projects. Some packages have dependencies to other packages and I would like to avoid to manually increment the version number in the dependencies of the other packages whenever I publish a new version of one package. Lets say, I publish a new version in package A. Package B has a dependency on Package A. In a project where I use Package B (and Package A was automatically included with the old version), the changes of package A will only arrive there when I also publish a new version of package B with a new version number for the dependency to package A. I could manually update Package A in the project, but don't I mitigate the concept of dependencies (to ensure everybody has the same package state)?
     
    Last edited: Dec 20, 2022
    neonblitzer and mailfromthewilds like this.
  12. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    217
    im working on a project built of my own mini-projects as well as packages from asset store. all of which are dependecies.

    Can't imagine going through a number of my mini-projects and incrementing the version of in package.json each time one of the assets im using has an update
     
  13. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    217
    Ooh, I can't wait :)