7

I have a DX project that heavily relies on the MetadataService class. The files reside in a GitHub repository. I'm trying to figure out why the project fails to get pushed to the scratch org when using git clone.

Here are the steps to re-create it the issue.

git clone https://github.com/xxx/repo.git
cd repo
sfdx force:org:create -s -f config/project-scratch-def.json -a scratchTest
sfdx force:source:push -u scratchTest

This will generate the following error: Class MetadataService : Script too large: public class MetadataService { public static String SOAP_M_URI = 'h... (31:14)

However if I decide to download the repository as a .ZIP file, extract and push it to the scratch org it works just fine.

I'm struggling to find the root cause of the issue and I'm not sure whether its a sfdx issue or git.

4
  • 1
    Do you use Win or *nix? If Win, please check line endings when you push from a cloned repo and from the downloaded one. I'm not sure how sfdx treats them, so I'm just trying to guess. Line endings is one of the common problems with git
    – nchursin
    Dec 23, 2018 at 8:14
  • 1
    @blank thank you! Git was using CR+LF and that was enough to push the MetadataService.class over the 1MB limit. I've changed back to LF and everything seems to be working fine. For reference here's how I did it: 1. git config --global core.eol lf 2. git config --global core.autocrlf input Dec 25, 2018 at 15:41
  • Glad to help! I had a bunch of troubles with line endings, but actually nothing like this. Please, mark the answer I posted as the correct one, so others could find it easily
    – nchursin
    Dec 25, 2018 at 15:58
  • 1
    The actual solution should be to break this huge file down into multiple. I created an issue in the repo github.com/financialforcedev/apex-mdapi/issues/240 Jun 21, 2019 at 11:13

1 Answer 1

8

The problem is line endings. Windows uses CR;LF, while *nix uses LF. Obviously, Win line endings use more space.

So the solution is to change all line endings to the *nix one (LF).

I'd actually recommend always use *nix line endings, as they generally produce less problems. To change your git config to use LFs do:

  1. git config --global core.eol lf
  2. git config --global core.autocrlf input

This would tell git to prefer LF line endings but to convert them only on commits

Update

A more stable solution would be to add the .gitattributes file with the following content:

* text=auto
*.cls text

This would make all the *.cls file to get the LF line endings on check-in. And will solve the above issue for all users working with the repo.

2
  • 4
    The actual solution should be to break this huge file down into multiple. I created an issue in the repo github.com/financialforcedev/apex-mdapi/issues/240 Jun 21, 2019 at 11:13
  • 1
    @RobertSösemann, I just posted a comment to your issue (3 years later lol). The real solution is to prevent lineendings change on a repo basis using the .gitattributes file.
    – nchursin
    May 4, 2022 at 8:01

You must log in to answer this question.

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