Yay: ERROR: PKGBUILD contains CRLF characters and cannot be sourced.

Created on 13 Sep 2019  路  5Comments  路  Source: Jguer/yay

Affected Version

yay v9.2.1 - libalpm v11.0.3

Issue

Since around a month or so every package install of AUR packages failed so far with (before I had newer gotten the error):
==> ERROR: PKGBUILD contains CRLF characters and cannot be sourced.

The only workaround to this is to clone the repo and clone the dependency repos manually and execute 'dos2unix PKGBUILD' for each, defeating the purpose of yay.

Steps to reproduce

  1. $yay -S anbox
  2. "ERROR: PKGBUILD contains CRLF characters and cannot be sourced."

Output

yay -S anbox-git ~/Build/AUR
:: There are 2 providers available for anbox-image:
:: Repository AUR
1) anbox-image 2) anbox-image-gapps

Enter a number (default=1):
:: There are 2 providers available for properties-cpp:
:: Repository AUR
1) properties-cpp 2) properties-cpp-bzr

Enter a number (default=1):
:: Checking for conflicts...
:: Checking for inner conflicts...
[Aur: 2] anbox-image-1:2018.07.19-1 anbox-git-1:r1096.ea2b7a3-1
[Aur Make: 1] properties-cpp-0.0.1-1

==> Remove make dependencies after install? [y/N]
3 anbox-image (Build Files Exist)
2 properties-cpp (Build Files Exist)
1 anbox-git (Build Files Exist)
==> Packages to cleanBuild?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==>
:: PKGBUILD up to date, Skipping (1/3): anbox-git
:: PKGBUILD up to date, Skipping (2/3): anbox-image
:: PKGBUILD up to date, Skipping (3/3): properties-cpp
3 anbox-image (Build Files Exist)
2 properties-cpp (Build Files Exist)
1 anbox-git (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==>
:: Parsing SRCINFO (1/3): anbox-image
:: Parsing SRCINFO (2/3): properties-cpp
:: Parsing SRCINFO (3/3): anbox-git
==> ERROR: PKGBUILD contains CRLF characters and cannot be sourced.
Error downloading sources: anbox-image

Most helpful comment

Thank you all for the hints.
It was indeed a autocrlf related issue. To get it work, I also needed also to clean the build caches for already fetched packages.

For future reference for people with the same issue:

  1. ensure right autocrlf value (not set, or 'input) e.g. via git config --edit --global
  2. remove / rename yay cache e.g. via sudo rm -r ~/.cache/yay
  3. (required?) clear makepkg builddir folder (see value BUILDDIR in /etc/makepkg.conf for the builddir path)

All 5 comments

this is not a yay restriction but a makepkg one. arch build tools inherently require unix line endings

I have tried the example case you've provided yay -S anbox-git and cannot reproduce this bug. Something along your pipe must be replacing \n with CRLF, have you checked if you have anything in your gitconfig set to use CRLF (core.autocrlf)?

EDIT: leaving this here https://help.github.com/en/articles/configuring-git-to-handle-line-endings

Yeah I swear we had a similar issue before where that was the cause.

Thank you all for the hints.
It was indeed a autocrlf related issue. To get it work, I also needed also to clean the build caches for already fetched packages.

For future reference for people with the same issue:

  1. ensure right autocrlf value (not set, or 'input) e.g. via git config --edit --global
  2. remove / rename yay cache e.g. via sudo rm -r ~/.cache/yay
  3. (required?) clear makepkg builddir folder (see value BUILDDIR in /etc/makepkg.conf for the builddir path)

I just found out why this happens:

  • Set up git under Windows
  • Copy ~/.gictonfig to Linux
Was this page helpful?
1 / 5 - 1 ratings

Related issues

drrlvn picture drrlvn  路  4Comments

GermanG picture GermanG  路  4Comments

mmirate picture mmirate  路  3Comments

renom picture renom  路  3Comments

x70b1 picture x70b1  路  4Comments