4

Reading through the answer about installing managed packages in scratch orgs and found this one especially helpful:

How to install managed package using Salesforce DX CLI?

My question is this:

How do you install a managed package when creating a scratch org via specifying in the scratch org definition file? Is it even possible?

The use case is when developing extension packages the scratch orgs will always have to have the base package installed and was looking to automate it a bit.

Kinda of getting lost in all the outdated info out there from the beta and such and can't seem to find anything that directly answers the question.

5
  • Have you tried force:mdapi:deploy followed by force:src:push? What was the result? Could you write a shell script?
    – sfdcfox
    Oct 14, 2017 at 5:31
  • 1
    @sfdcfox - Yea, that works but trying to get it al done when the org is created without having to do anything else. From what I read there is no setting in the definition file for InstalledPackage so it seems its always a multi-step process. Was hoping it could be defined in a JSON file so it is always installed on create based on the definition
    – Eric
    Oct 14, 2017 at 5:34
  • 1
    Yeah, I don't know why they didn't do it that way, but that seems to be the case. I'd love to be proven wrong, though.
    – sfdcfox
    Oct 14, 2017 at 5:49
  • @sfdcfox - if i had to guess it would be due to speed. I bet it would dramatically slow down scratch org creation and interfere with the processes
    – Eric
    Oct 14, 2017 at 5:57
  • I think speed shouldn't take priority if you dont get what you want. We should be able to define the structure of the scratch org, that we need. Like defining the required managed packages to be installed as a part of the scratch org, creation
    – OK999
    Nov 27, 2017 at 18:52

1 Answer 1

5

We do not currently define package info in the scratch org config.

Use the CLI command sfdx force:package:install ... immediately after creating the scratch org.

8
  • 2
    As a roadmap thing, for those of us developing extension packages the base package is required for all scratch orgs to push the metadata. Knowing it will take longer, it would be nice to be able to define required package installs in the definition Json to automate things a bit. That way we don't have to keep going to lookup the package Id for the version we need to install
    – Eric
    Oct 15, 2017 at 1:21
  • 1
    Totally understand. And we have plans to help address. For now, you can pre-build these scratch orgs via scripts and assign as needed. Thanks for the feedback! Oct 15, 2017 at 2:09
  • 1
    Also, a BIG issue with package install is that it installs for admins only without any way to specify All users. This is a shortcoming of the MDAPI as well and is most likely why the CLI does not support it. However, for legacy packages it is impossible to install a package via the CLI (admin only) and have it work. Need the option to specify for "all users" when installing. I know Perm Sets are the way to go moving forward but lots of legacy packages without them that must be installed for all users or they do not work.
    – Eric
    Oct 15, 2017 at 2:10
  • @WadeWegner So there's no any other way to have managed package installed when scratch org is created? i.e. CPQ is installing for 20-30 min which is way too long for us for CI. And we just need sobject from CPQ as we extend this functionality. Maybe there any other solution for that
    – Mystery
    Jul 2, 2018 at 12:11
  • 1
    +1 this would be super useful - how it progressing? :o)
    – Robs
    Nov 2, 2020 at 22:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .