Repository: archlinux/archinstall

Issue:
Pacstrap failing 
```
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 418, in _pacstrap
    SysCommand(f'/usr/bin/pacstrap -C /etc/pacman.conf -K {self.target} {" ".join(packages)} --noconfirm', peek_output=True)
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 448, in __init__
    self.create_session()
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 499, in create_session
    with SysCommandWorker(
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 275, in __exit__
    raise SysCallError(
archinstall.lib.exceptions.SysCallError: ['/usr/bin/pacstrap', '-C', '/etc/pacman.conf', '-K', '/mnt/archinstall', 'z', 'r', 'a', 'm', '-', 'g', 'e', 'n', 'e', 'r', 'a', 't', 'o', 'r', '--noconfirm'] exited with abnormal exit code [1]: b"==> Creating install root at /mnt/archinstall\r\n==> Installing packages to /mnt/archinstall\r\nerror: argument '-' specified without input on stdin\r\n\x1b[?25l\x1b[?25h==> ERROR: Failed to install packages to new root\r\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 418, in _pacstrap
    SysCommand(f'/usr/bin/pacstrap -C /etc/pacman.conf -K {self.target} {" ".join(packages)} --noconfirm', peek_output=True)
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 448, in __init__
    self.create_session()
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 499, in create_session
    with SysCommandWorker(
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 275, in __exit__
    raise SysCallError(
archinstall.lib.exceptions.SysCallError: ['/usr/bin/pacstrap', '-C', '/etc/pacman.conf', '-K', '/mnt/archinstall', 'z', 'r', 'a', 'm', '-', 'g', 'e', 'n', 'e', 'r', 'a', 't', 'o', 'r', '--noconfirm'] exited with abnormal exit code [1]: b"==> Creating install root at /mnt/archinstall\r\n==> Installing packages to /mnt/archinstall\r\nerror: argument '-' specified without input on stdin\r\n\x1b[?25l\x1b[?25h==> ERROR: Failed to install packages to new root\r\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 418, in _pacstrap
    SysCommand(f'/usr/bin/pacstrap -C /etc/pacman.conf -K {self.target} {" ".join(packages)} --noconfirm', peek_output=True)
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 448, in __init__
    self.create_session()
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 499, in create_session
    with SysCommandWorker(
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 275, in __exit__
    raise SysCallError(
archinstall.lib.exceptions.SysCallError: ['/usr/bin/pacstrap', '-C', '/etc/pacman.conf', '-K', '/mnt/archinstall', 'z', 'r', 'a', 'm', '-', 'g', 'e', 'n', 'e', 'r', 'a', 't', 'o', 'r', '--noconfirm'] exited with abnormal exit code [1]: b"==> Creating install root at /mnt/archinstall\r\n==> Installing packages to /mnt/archinstall\r\nerror: argument '-' specified without input on stdin\r\n\x1b[?25l\x1b[?25h==> ERROR: Failed to install packages to new root\r\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 418, in _pacstrap
    SysCommand(f'/usr/bin/pacstrap -C /etc/pacman.conf -K {self.target} {" ".join(packages)} --noconfirm', peek_output=True)
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 448, in __init__
    self.create_session()
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 499, in create_session
    with SysCommandWorker(
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 275, in __exit__
    raise SysCallError(
archinstall.lib.exceptions.SysCallError: ['/usr/bin/pacstrap', '-C', '/etc/pacman.conf', '-K', '/mnt/archinstall', 'z', 'r', 'a', 'm', '-', 'g', 'e', 'n', 'e', 'r', 'a', 't', 'o', 'r', '--noconfirm'] exited with abnormal exit code [1]: b"==> Creating install root at /mnt/archinstall\r\n==> Installing packages to /mnt/archinstall\r\nerror: argument '-' specified without input on stdin\r\n\x1b[?25l\x1b[?25h==> ERROR: Failed to install packages to new root\r\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/archinstall", line 8, in <module>
    sys.exit(run_as_a_module())
  File "/usr/lib/python3.10/site-packages/archinstall/__init__.py", line 266, in run_as_a_module
    importlib.import_module(mod_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/archinstall/scripts/guided.py", line 279, in <module>
    perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt')))
  File "/usr/lib/python3.10/site-packages/archinstall/scripts/guided.py", line 135, in perform_installation
    with Installer(
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 137, in __exit__
    raise exc_val
  File "/usr/lib/python3.10/site-packages/archinstall/scripts/guided.py", line 171, in perform_installation
    installation.setup_swap('zram')
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 803, in setup_swap
    self._pacstrap('zram-generator')
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 425, in _pacstrap
    return self._pacstrap(packages)
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 425, in _pacstrap
    return self._pacstrap(packages)
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 425, in _pacstrap
    return self._pacstrap(packages)
  File "/usr/lib/python3.10/site-packages/archinstall/lib/installer.py", line 427, in _pacstrap
    raise RequirementError("Pacstrap failed. See /var/log/archinstall/install.log or above message for error details.")
archinstall.lib.exceptions.RequirementError: Pacstrap failed.
```

Here is the log:- [logfile](https://bpa.st/5F7ME)


Discussion:
Piggybacking on this issue, my current method of testing for bugs is to build an iso with the provided build_iso script and then try to install arch from the generated iso and report errors if any. Is there a better or more robust method than this to find out bugs? 
Similar issue as #1778 I assume, I can take a look in the morning when I wake up but gotta crash for today.

> Piggybacking on this issue, my current method of testing for bugs is to build an iso with the provided build_iso script and then try to install arch from the generated iso and report errors if any. Is there a better or more robust method than this to find out bugs?

The quickest but most risky way is to run a loopback device with `# losetup -fP device.img` and perform archinstall operations against `/dev/loopX`. It's pretty safe unless when there's been changes to the disk section of the code (which we have the last week or so).

The second quickest is to create an automated ISO that auto-launches `archinstall` from a git source.
I have a script I run called [archoffline](https://github.com/Torxed/archoffline) and if you have networking available I use [archtest.py](https://github.com/Torxed/Scripts/blob/master/python/archtest.py) which simply builds latest `releng` (official ISO config) with `git clone archinstall` in `/root/` and every tty0 login it `git pull` the latest updates and launches `python guided.py` from within the git repo. It's near zero latency on testing - but requires a bit of fiddling before you get used to it.
I think that was my change :( I'll raise a fix 

Resolving patch:
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -392,8 +392,8 @@ def enable_testing_repositories(self, enable_multilib_testing=False):
 					pacman_conf.write(line)
 
 	def _pacstrap(self, packages: Union[str, List[str]]) -> bool:
-		if type(packages[0]) in (list, tuple):
-			packages = packages[0]
+		if isinstance(packages, str):
+			packages = [packages]
 
 		for plugin in plugins.values():
 			if hasattr(plugin, 'on_pacstrap'):
@@ -568,13 +568,12 @@ def enable_periodic_trim(self) -> None:
 		self.enable_service("fstrim.timer")
 
 	def enable_service(self, services: Union[str, List[str]]) -> None:
-		if type(services[0]) in (list, tuple):
-			services = services[0]
-		if type(services) == str:
-			services = [services, ]
+		if isinstance(services, str):
+			services = [services]
 
 		for service in services:
 			self.log(f'Enabling service {service}', level=logging.INFO)
+
 			try:
 				self.arch_chroot(f'systemctl enable {service}')
 			except SysCallError as error:


Test patch: