I've created an unlocked package. It installs fine in scratch, but when I install it to sandbox (or prod) I get a compile error:

Apex compile failure, Details: line 116, column 29: Variable does not exist: User.Address

Funny thing is that I don't have this variable or any reference to User.Address in my code. But I do have a dependency on SF CPQ, a managed package which have been installed already in sandbox/prod.

Where could it be coming from, and why would it be different for scratch vs. sandbox?

  • 1
    Is the class that fails to compile in your project? What's at the line referenced in the error? Sep 17, 2018 at 10:17
  • 3
    Are sandbox, prod and scratch all on the same API version?
    – David Reed
    Sep 17, 2018 at 10:26
  • @JohnTowers I've got two apex files, in one there's a comment on line 116, on the other just a debug statement using a object other than User. I'm not using User anywhere in my code except in a unit test class, which doesn't use the Address field. The same classes were running fine in sandbox before I converted to a DX project, did no changes, and created package. That's so strange. I'm thinking the offending line could be in a dependency (the managed package I've mentioned), since I can't find it in my code.
    – specimen
    Sep 17, 2018 at 11:52
  • @DavidReed API version 43 in sandbox, which is summer 18. Looks to be 43 in scratch orgs as well, although I must say I've seen the winter 18 logo on some scratch orgs, but the one I've installed the package in is Summar18 Api43, and also in the project file sourceApiVersion is 43
    – specimen
    Sep 17, 2018 at 13:43
  • I've got a feeling it has some relation with the dependencies. I've added a dependency to a managed package, because I'm using some objects from that. Maybe I should just drop the dependency, since I anyway must install that package manually in the scratch org? And use dependencies only for my own unlocked packages?
    – specimen
    Sep 17, 2018 at 14:06


You must log in to answer this question.

Browse other questions tagged .