Can't specify revision for git package dependency with SSH

I have created a package following the docs and published this in a Gitlab repository.

Now I’m trying to add this package as a dependency for my project like this:

"com.sample.package": "git@gitlab.com:myusername/packages/mypackage.git",

This works as expected and the package is added to the project. Now we want to specify a revision as described in the docs:

So we tried:

"com.sample.package": "git@gitlab.com:myusername/packages/mypackage.git#v1.0.2",
"com.sample.package": "git+git@gitlab.com:myusername/packages/mypackage.git#v1.0.2",
"com.sample.package": "ssh://git@gitlab.com:myusername/packages/mypackage.git#v1.0.2",
"com.sample.package": "git+ssh://git@gitlab.com:myusername/packages/mypackage.git#v1.0.2",

where “v1.0.2” is a tag that exists in our repo.

This is the error we’re getting in the inspector, for ANY of the tests I listed above:

An error occurred while resolving packages:
  Project has invalid dependencies:
    com.sample.package: Version 'git@gitlab.com:myusername/packages/mypackage.git#v1.0.2' is invalid. Expected one of: a 'SemVer' compatible value; a value starting with 'file:'; a Git URL starting with 'git:' or 'git+', or ending with '.git'.

In the docs there are no examples with SSH and specifying revisions, is this supported? We’re not willing to change to HTTP because SSH is easier for us to make the Gitlab CI work.

We were struggling with this issue today too and found your post. After some work with the UPM extension, we found the cause and fix.

Overall problem is that GitHub or GitLab give you ssh urls with colon (:slight_smile: after the host name.

Problem is due to the colon at the end of the gitlab.com:, if you change it to forward slash / the problem will be fixed and also add ssh:// in the front.

So instead of:

git@gitlab.com:myusername/packages/mypackage.git#v1.0.2

change the : after the host name to a / and add ssh://

ssh://git@gitlab.com/myusername/packages/mypackage.git#v1.0.2

@gnp89