When you enable the org-wide setting in the Dev Hub menu, the only user profile that will have the permission enabled is the default Sys Admin profile. If you use another profile in production, you need to grant the "Create and Update Second-Generation Packages" permission for the profile being used or otherwise add the permission to yourself.
I was stuck myself, but found this article to help:
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_dev2gp_before.htm
You'll likely also want to give yourself/profile the "Promote a package version to released" permission.
Perhaps I'm being really dumb here, but can't you get the 04t
id for the package by reading it off the installation URL? e.g. if I try to install Lightning Flow Sample Pack from AppExchange, I end up at:
lightning.force.com/packagingSetupUI/ipLanding.app?apvId=04t1I000003coh8QAA&src=U
From which I can just read the 04t
. I've successfully built 2GP packages that depend on my own 1st generation packages with just
"dependencies": [
{
"subscriberPackageVersionId": "04t..."
}
],
So, hopefully, you can do something like that.
Updates
Some updates from our discussion in comments:
If you don't know the installation URL, you can obtain the 04t
key by running:
force:package:installed:list
on the scratch org. In Eric's case, adding the package key to his sfdx-project.json
still resulting in a failure during package building.
For reference, here's the whole sfdx-project.json
from a 2GP package of mine that depends on managed 1GP packages:
{
"packageDirectories": [
{
"path": "force-app",
"package": "My Package",
"versionName": "ver 0.6",
"versionNumber": "0.6.0.NEXT",
"default": true,
"dependencies": [
{
"subscriberPackageVersionId": "04t1..."
},
{
"subscriberPackageVersionId": "04t5..."
}
],
"ancestorVersion": "0.5.0.1"
}
],
"namespace": "nebc",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "43.0",
"packageAliases": {
"My Package": "0Ho...",
"My Package@0.1.0-1": "04t...rQAC",
"My Package@0.1.0-2": "04t...1QAC",
"My Package@0.2.0-1": "04t...6QAC",
"My Package@0.4.0-1": "04t...QQAS",
"My Package@0.5.0-1": "04t...VQAS",
"My Package@0.6.0-1": "04t...bQAC"
}
}
Best Answer
Ok, looks like I have to create Developer Edition org and register a namespace there and then link it to my Dev Hub org due to documentation
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_reg_namespace.htm