Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kas: No such file or directory: 'git' #383907

Open
3 tasks done
cezdro opened this issue Feb 21, 2025 · 2 comments
Open
3 tasks done

kas: No such file or directory: 'git' #383907

cezdro opened this issue Feb 21, 2025 · 2 comments
Labels
0.kind: bug Something is broken

Comments

@cezdro
Copy link

cezdro commented Feb 21, 2025

Nixpkgs version

  • Unstable (25.05)

Describe the bug

Even if git is in $PATH, kas doesn't detect it. I tried using overridePythonAttrs to add git to dependencies, but even this did not help. What's makes it even stranger is that kas wrapper adds path to git at the very beginning:

#! /nix/store/4fvc5fm8bszmkydng1ivrvr5cbvr1g60-bash-5.2p37/bin/bash -e
PATH=${PATH:+':'$PATH':'}
PATH=${PATH/':''/nix/store/akrh5w7n6bwg4mnc1fd1s2v7q1v0f01z-git-minimal-2.47.1/bin'':'/':'}

Steps to reproduce

  1. Start a Nix shell: nix shell nixpkgs#kas
  2. Add an example .config.yaml:
    header:
      version: 14
    
    machine: qemux86-64
    distro: poky
    
    target: zlib-native
    
    repos:
      poky:
        url: https://git.yoctoproject.org/poky.git
        commit: fb91a49387cfb0c8d48303bb3354325ba2a05587
        layers:
          meta:
          meta-poky:
  3. Run kas build

Expected behaviour

Kas builds the project

Screenshots

No response

Relevant log output

$ kas build
2025-02-21 12:59:46 - INFO     - kas 4.5 started
2025-02-21 12:59:46 - WARNING  - kas: No supported distros found in ['nixos']. No default locales set.
2025-02-21 12:59:46 - INFO     - Cloning repository poky
2025-02-21 12:59:46 - ERROR    - [Errno 2] No such file or directory: 'git'
Traceback (most recent call last):
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/kas.py", line 205, in main
    kas(sys.argv[1:])
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/kas.py", line 194, in kas
    plugin.run(args)
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/plugins/build.py", line 105, in run
    macro.run(ctx, args.skip)
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/libcmds.py", line 114, in run
    command.execute(ctx)
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/libcmds.py", line 554, in execute
    repos_fetch(ctx.config.get_repos())
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/libkas.py", line 202, in repos_fetch
    loop.run_until_complete(asyncio.gather(*tasks))
  File "/nix/store/qrc496n6fsqp4p5m5h8wmw5d5jwyw5mr-python3-3.12.8/lib/python3.12/asyncio/base_events.py", line 686, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/repos.py", line 312, in fetch_async
    (retc, _) = await run_cmd_async(
                ^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/libkas.py", line 139, in run_cmd_async
    raise ex
  File "/nix/store/srmjq4vpcvpmz33ip985vhrjfdz4snq8-kas-4.5/lib/python3.12/site-packages/kas/libkas.py", line 131, in run_cmd_async
    process = await asyncio.create_subprocess_exec(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/qrc496n6fsqp4p5m5h8wmw5d5jwyw5mr-python3-3.12.8/lib/python3.12/asyncio/subprocess.py", line 224, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/qrc496n6fsqp4p5m5h8wmw5d5jwyw5mr-python3-3.12.8/lib/python3.12/asyncio/base_events.py", line 1749, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/qrc496n6fsqp4p5m5h8wmw5d5jwyw5mr-python3-3.12.8/lib/python3.12/asyncio/unix_events.py", line 211, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/qrc496n6fsqp4p5m5h8wmw5d5jwyw5mr-python3-3.12.8/lib/python3.12/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/nix/store/qrc496n6fsqp4p5m5h8wmw5d5jwyw5mr-python3-3.12.8/lib/python3.12/asyncio/unix_events.py", line 820, in _start
    self._proc = subprocess.Popen(
                 ^^^^^^^^^^^^^^^^^
  File "/nix/store/qrc496n6fsqp4p5m5h8wmw5d5jwyw5mr-python3-3.12.8/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/nix/store/qrc496n6fsqp4p5m5h8wmw5d5jwyw5mr-python3-3.12.8/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'

Additional context

No response

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.12.10, NixOS, 25.05 (Warbler), 25.05.20250121.9e4d519
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.25.4
  • nixpkgs: /nix/store/irknf7niks2djxz4csh7sr44wwrs082y-source

Notify maintainers

@bachp

Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

@cezdro cezdro added the 0.kind: bug Something is broken label Feb 21, 2025
@cezdro
Copy link
Author

cezdro commented Feb 21, 2025

Update

I managed to solve this issue with the following patch:

fix-path.patch

diff --git a/kas/context.py b/kas/context.py
index 0b456ff..15399d5 100644
--- a/kas/context.py
+++ b/kas/context.py
@@ -131,7 +131,7 @@ class Context:
 
         for key in ['http_proxy', 'https_proxy', 'ftp_proxy', 'no_proxy',
                     'SSH_AUTH_SOCK',
-                    'BB_NUMBER_THREADS', 'PARALLEL_MAKE']:
+                    'BB_NUMBER_THREADS', 'PARALLEL_MAKE', 'PATH']:
             val = os.environ.get(key, None)
             if val:
                 self.environ[key] = val
diff --git a/kas/libkas.py b/kas/libkas.py
index d9db5c6..5bd4046 100644
--- a/kas/libkas.py
+++ b/kas/libkas.py
@@ -282,7 +282,7 @@ def get_build_environ(build_system):
         raise InitBuildEnvError('Did not find any init-build-env script')
 
     with tempfile.TemporaryDirectory() as temp_dir:
-        script = f"""#!/bin/bash
+        script = f"""#!/usr/bin/env bash
         set -e
         source {init_script} $1 > /dev/null
         env
@@ -293,7 +293,7 @@ def get_build_environ(build_system):
         get_bb_env_file.chmod(0o775)
 
         env = {}
-        env['PATH'] = '/usr/sbin:/usr/bin:/sbin:/bin'
+        env['PATH'] = os.environ['PATH']
 
         (_, output) = run_cmd([str(get_bb_env_file), get_context().build_dir],
                               cwd=init_repo.path, env=env)

However, now I have another problem:

$ kas build
2025-02-21 14:43:08 - INFO     - kas 4.7 started
2025-02-21 14:43:08 - WARNING  - kas: No supported distros found in ['nixos']. No default locales set.
2025-02-21 14:43:08 - INFO     - Cloning repository poky
2025-02-21 14:43:39 - INFO     - Repository poky already contains fb91a49387cfb0c8d48303bb3354325ba2a05587 as commit
2025-02-21 14:43:40 - INFO     - Repository poky checked out to fb91a49387cfb0c8d48303bb3354325ba2a05587
2025-02-21 14:43:40 - INFO     - /home/cezdro/dev/kas-test/build$ /home/cezdro/dev/kas-test/poky/bitbake/bin/bitbake -c build zlib-native
Please make sure locale 'en_US.UTF-8' is available on your system
2025-02-21 14:43:40 - ERROR    - Command "/home/cezdro/dev/kas-test/poky/bitbake/bin/bitbake -c build zlib-native" failed with error 1

Of course, I know that this is for another ticket, but I'm leaving it here to let know, that even with this patch, kas still isn't fully working.

@bachp
Copy link
Member

bachp commented Feb 21, 2025

@cezdro I have only used this in conjunction with https://github.com/nix-community/nix-environments/tree/master/envs/yocto.

What environment are you running kas in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants