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

First time running a moon command after setup-toolchain fails #18

Closed
Blissful89 opened this issue Jan 8, 2025 · 16 comments
Closed

First time running a moon command after setup-toolchain fails #18

Blissful89 opened this issue Jan 8, 2025 · 16 comments

Comments

@Blissful89
Copy link

Describe the bug

I am using setup-toolchain to run moon query in the pipeline. Ever since the new releases the last couple of days, the first run of my ci fails. I have to give a second "kick" and retry to make it work.

Steps to reproduce

This is a simplified setup of our workflow. Note that we disable cache to prevent caches clashing and creating a race condition with a setup-toolchain with auto-install: true

      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Inject Moon
        uses: moonrepo/setup-toolchain@v0
        with:
          cache: false

      - name: Getting affected workspaces 🔍...
        id: query
        run: |
          affected=$(moon query touched-files | moon query projects --affected --json)
          echo "The following workspaces are affected:"
          echo $affected
        shell: bash

Expected behavior

Usually we place the affected output into the $GITHUB_OUTPUT.

image

Screenshots

We now get an error stating:

Run affected=$(moon query touched-files | moon query projects --affected --json)
Error: fs::rename

  × Failed to rename ~/.proto/tools/proto/0.44.4/proto to ~/.proto/temp/proto.
  ╰─▶ Is a directory (os error 21)
  help: Does the source file exist?

Error: Process completed with exit code 1.
image
@Blissful89
Copy link
Author

@milesj thanks for helping me with moonrepo/moon#1783. Hopefully you also have a bit of time to look into this one?

@milesj
Copy link
Contributor

milesj commented Jan 8, 2025

@Blissful89 this is odd.

If you set PROTO_LOG=trace MOON_LOG=trace does it show anything?

@Blissful89
Copy link
Author

Blissful89 commented Jan 9, 2025

@milesj. Sorry for the delay, I live in the eu-timezone. It is hard to replicate, because it only does it the first run through.
Heres a trace log of the error:

Run affected=$(moon query touched-files | moon query projects --affected --json)
[DEBUG 2025-01-09 06:28:40.349] moon  Running moon v1.31.1 (with ~/.proto/bin/moon)  args=["moon", "query", "projects", "--affected", "--json"]
[DEBUG 06:28:40.349] moon_app::session  Creating new application session 
[TRACE 06:28:40.349] moon_console::console  Creating buffered console 
[DEBUG 2025-01-09 06:28:40.350] moon  Running moon v1.31.1 (with ~/.proto/bin/moon)  args=["moon", "query", "touched-files"]
[DEBUG 06:28:40.350] moon_app::session  Creating new application session 
[TRACE 06:28:40.350] moon_console::console  Creating buffered console 
[TRACE 06:28:40.350] starbase::app  Running startup phase 
[DEBUG 06:28:40.350] moon_app::systems::startup  Attempting to find workspace root from current working directory  working_dir="/home/runner/work/brainbooster/brainbooster"
[TRACE 06:28:40.350] starbase_utils::fs  Traversing upwards to find a file/root  file=".moon" dir="/home/runner/work/brainbooster/brainbooster"
[DEBUG 06:28:40.350] moon_app::systems::startup  Found workspace root  workspace_root="/home/runner/work/brainbooster/brainbooster" working_dir="/home/runner/work/brainbooster/brainbooster"
[DEBUG 06:28:40.350] moon_env  Creating moon environment, detecting store  store="/home/runner/.moon"
[DEBUG 06:28:40.350] proto_core::proto  Creating proto environment, detecting store  store="/home/runner/.proto" home="/home/runner"
[DEBUG 06:28:40.350] moon_app::systems::startup  Loading .moon/workspace.yml (required) 
[TRACE 06:28:40.350] starbase::app  Running startup phase 
[DEBUG 06:28:40.350] moon_app::systems::startup  Attempting to find workspace root from current working directory  working_dir="/home/runner/work/brainbooster/brainbooster"
[TRACE 06:28:40.350] starbase_utils::fs  Traversing upwards to find a file/root  file=".moon" dir="/home/runner/work/brainbooster/brainbooster"
[DEBUG 06:28:40.350] moon_app::systems::startup  Found workspace root  workspace_root="/home/runner/work/brainbooster/brainbooster" working_dir="/home/runner/work/brainbooster/brainbooster"
[DEBUG 06:28:40.350] moon_env  Creating moon environment, detecting store  store="/home/runner/.moon"
[DEBUG 06:28:40.350] proto_core::proto  Creating proto environment, detecting store  store="/home/runner/.proto" home="/home/runner"
[DEBUG 06:28:40.350] moon_app::systems::startup  Loading .moon/workspace.yml (required) 
[TRACE 06:28:40.350] schematic::config::loader  Loading configuration  config="WorkspaceConfig"
[TRACE 06:28:40.350] schematic::config::loader  Creating layer from source  config="WorkspaceConfig" source="/home/runner/work/brainbooster/brainbooster/.moon/workspace.yml"
[DEBUG 06:28:40.350] moon_app::systems::startup  Attempting to load .moon/tasks.yml and .moon/tasks/**/*.yml (optional) 
[DEBUG 06:28:40.350] moon_app::systems::startup  Attempting to load .moon/toolchain.yml (optional) 
[TRACE 06:28:40.351] schematic::config::loader  Merging partial layers into a final result  config="WorkspaceConfig"
[TRACE 06:28:40.351] schematic::config::loader  Loading configuration  config="WorkspaceConfig"
[TRACE 06:28:40.351] schematic::config::loader  Creating layer from source  config="WorkspaceConfig" source="/home/runner/work/brainbooster/brainbooster/.moon/workspace.yml"
[DEBUG 06:28:40.351] proto_core::proto_config  Loading .prototools  file="/home/runner/work/brainbooster/brainbooster/.prototools"
[TRACE 06:28:40.351] starbase_utils::fs  Reading file  file="/home/runner/work/brainbooster/brainbooster/.prototools"
[TRACE 06:28:40.351] schematic::config::loader  Loading partial configuration  config="ProtoConfig"
[TRACE 06:28:40.351] schematic::config::loader  Creating layer from source  config="ProtoConfig" source="<code>"
[TRACE 06:28:40.351] schematic::config::loader  Merging partial layers into a final result  config="WorkspaceConfig"
[TRACE 06:28:40.351] schematic::config::loader  Merging partial layers into a final result  config="ProtoConfig"
[DEBUG 06:28:40.351] proto_core::proto_config  Loading local config only 
[DEBUG 06:28:40.352] proto_core::proto_config  Merged 1 configs 
[TRACE 06:28:40.352] schematic::config::loader  Loading configuration  config="ToolchainConfig"
[TRACE 06:28:40.352] schematic::config::loader  Creating layer from source  config="ToolchainConfig" source="/home/runner/work/brainbooster/brainbooster/.moon/toolchain.yml"
[TRACE 06:28:40.352] schematic::config::loader  Loading partial configuration  config="InheritedTasksConfig"
[TRACE 06:28:40.352] schematic::config::loader  Creating layer from source  config="InheritedTasksConfig" source="/home/runner/work/brainbooster/brainbooster/.moon/tasks/terraform.yml"
[TRACE 06:28:40.352] schematic::config::loader  Merging partial layers into a final result  config="ToolchainConfig"
[TRACE 06:28:40.352] moon_config::toolchain_config  Inheriting node version ~23 from .prototools 
[TRACE 06:28:40.352] moon_config::toolchain_config  Inheriting node plugin from proto  plugin="https://github.com/moonrepo/plugins/releases/download/node_tool-v0.13.0/node_tool.wasm"
[TRACE 06:28:40.352] moon_config::toolchain_config  Inheriting python version ~3.13 from .prototools 
[TRACE 06:28:40.352] moon_config::toolchain_config  Inheriting python plugin from proto  plugin="https://github.com/moonrepo/plugins/releases/download/python_tool-v0.12.2/python_tool.wasm"
[TRACE 06:28:40.352] moon_config::toolchain::node_config  Inheriting pnpm version ~9 from .prototools 
[TRACE 06:28:40.352] moon_config::toolchain::node_config  Inheriting pnpm plugin from proto  plugin="https://github.com/moonrepo/plugins/releases/download/node_depman_tool-v0.[14](https://github.com/brainboost-eu/brainbooster/actions/runs/12684789866/job/35354042071#step:4:15).1/node_depman_tool.wasm"
[TRACE 06:28:40.352] schematic::config::loader  Merging partial layers into a final result  config="InheritedTasksConfig"
[DEBUG 06:28:40.352] moon_app::systems::startup  Attempting to load .moon/tasks.yml and .moon/tasks/**/*.yml (optional) 
[TRACE 06:28:40.352] schematic::config::loader  Loading partial configuration  config="InheritedTasksConfig"
[TRACE 06:28:40.352] schematic::config::loader  Creating layer from source  config="InheritedTasksConfig" source="/home/runner/work/brainbooster/brainbooster/.moon/tasks/terraform.yml"
[TRACE 06:28:40.353] schematic::config::loader  Merging partial layers into a final result  config="InheritedTasksConfig"
[DEBUG 06:28:40.353] moon_app::systems::startup  Loaded 1 task configs to inherit  scopes=["terraform"]
[DEBUG 06:28:40.353] moon_app::systems::startup  Attempting to load .moon/toolchain.yml (optional) 
[DEBUG 06:28:40.353] moon_app::systems::startup  Loaded 1 task configs to inherit  scopes=["terraform"]
[DEBUG 06:28:40.353] moon_vcs::git  Using git as a version control system 
[DEBUG 06:28:40.353] moon_vcs::git  Attempting to find a .git directory or file  starting_dir="/home/runner/work/brainbooster/brainbooster"
[DEBUG 06:28:40.353] moon_vcs::git  Found a .git directory (repository root)  git="/home/runner/work/brainbooster/brainbooster/.git"
[DEBUG 06:28:40.353] moon_vcs::git  Loading ignore rules from .gitignore  ignore_file="/home/runner/work/brainbooster/brainbooster/.gitignore"
[DEBUG 06:28:40.354] starbase_shell::shell  Attempting to detect the current shell 
[DEBUG 06:28:40.354] starbase_shell::shell  Detecting from operating system 
[DEBUG 06:28:40.354] proto_core::proto_config  Loading .prototools  file="/home/runner/work/brainbooster/brainbooster/.prototools"
[TRACE 06:28:40.354] starbase_utils::fs  Reading file  file="/home/runner/work/brainbooster/brainbooster/.prototools"
[TRACE 06:28:40.354] schematic::config::loader  Loading partial configuration  config="ProtoConfig"
[TRACE 06:28:40.354] schematic::config::loader  Creating layer from source  config="ProtoConfig" source="<code>"
[TRACE 06:28:40.355] schematic::config::loader  Merging partial layers into a final result  config="ProtoConfig"
[DEBUG 06:28:40.355] proto_core::proto_config  Loading local config only 
[DEBUG 06:28:40.355] proto_core::proto_config  Merged 1 configs 
[TRACE 06:28:40.355] schematic::config::loader  Loading configuration  config="ToolchainConfig"
[TRACE 06:28:40.355] schematic::config::loader  Creating layer from source  config="ToolchainConfig" source="/home/runner/work/brainbooster/brainbooster/.moon/toolchain.yml"
[TRACE 06:28:40.355] schematic::config::loader  Merging partial layers into a final result  config="ToolchainConfig"
[TRACE 06:28:40.355] moon_config::toolchain_config  Inheriting node version ~23 from .prototools 
[TRACE 06:28:40.355] moon_config::toolchain_config  Inheriting node plugin from proto  plugin="https://github.com/moonrepo/plugins/releases/download/node_tool-v0.13.0/node_tool.wasm"
[TRACE 06:28:40.355] moon_config::toolchain_config  Inheriting python version ~3.13 from .prototools 
[TRACE 06:28:40.355] moon_config::toolchain_config  Inheriting python plugin from proto  plugin="https://github.com/moonrepo/plugins/releases/download/python_tool-v0.12.2/python_tool.wasm"
[TRACE 06:28:40.355] moon_config::toolchain::node_config  Inheriting pnpm version ~9 from .prototools 
[TRACE 06:28:40.355] moon_config::toolchain::node_config  Inheriting pnpm plugin from proto  plugin="https://github.com/moonrepo/plugins/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm"
[DEBUG 06:28:40.355] moon_vcs::git  Using git as a version control system 
[DEBUG 06:28:40.355] moon_vcs::git  Attempting to find a .git directory or file  starting_dir="/home/runner/work/brainbooster/brainbooster"
[DEBUG 06:28:40.355] moon_vcs::git  Found a .git directory (repository root)  git="/home/runner/work/brainbooster/brainbooster/.git"
[DEBUG 06:28:40.355] moon_vcs::git  Loading ignore rules from .gitignore  ignore_file="/home/runner/work/brainbooster/brainbooster/.gitignore"
[DEBUG 06:28:40.356] starbase_shell::shell  Attempting to detect the current shell 
[DEBUG 06:28:40.356] starbase_shell::shell  Detecting from operating system 
[TRACE 06:28:40.370] starbase_shell::shell::unix  Running ps command to find shell  pid=1787 next_pid=1786 comm="moon"
[TRACE 06:28:40.370] starbase_shell::shell::unix  Running ps command to find shell  pid=1788 next_pid=1786 comm="moon"
[TRACE 06:28:40.380] starbase_shell::shell::unix  Running ps command to find shell  pid=1786 next_pid=1785 comm="bash"
[DEBUG 06:28:40.380] starbase_shell::shell  Detected bash shell 
[DEBUG 06:28:40.380] moon_process::command_inspector  Running command git remote get-url origin  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[TRACE 06:28:40.380] starbase_shell::shell::unix  Running ps command to find shell  pid=1786 next_pid=1785 comm="bash"
[DEBUG 06:28:40.380] starbase_shell::shell  Detected bash shell 
[DEBUG 06:28:40.381] moon_process::command_inspector  Running command git remote get-url origin  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[TRACE 06:28:40.382] starbase::app  Running analyze phase 
[DEBUG 06:28:40.382] moon_cache::cache_engine  Creating cache engine  cache_dir="/home/runner/work/brainbooster/brainbooster/.moon/cache"
[TRACE 06:28:40.382] starbase_utils::fs  Creating directory  dir="/home/runner/work/brainbooster/brainbooster/.moon/cache"
[TRACE 06:28:40.382] starbase_utils::fs  Writing file  file="/home/runner/work/brainbooster/brainbooster/.moon/cache/CACHEDIR.TAG"
[DEBUG 06:28:40.382] moon_cache::hash_engine  Creating hash engine  hashes_dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/hashes" outputs_dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/outputs"
[TRACE 06:28:40.382] starbase_utils::fs  Creating directory  dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/hashes"
[TRACE 06:28:40.382] starbase_utils::fs  Creating directory  dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/outputs"
[DEBUG 06:28:40.383] moon_cache::state_engine  Creating states engine  states_dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/states"
[TRACE 06:28:40.383] starbase_utils::fs  Creating directory  dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/states"
[DEBUG 06:28:40.383] moon_app::systems::analyze  Checking if proto is installed  proto="/home/runner/.proto/tools/proto/0.44.4/proto"
[DEBUG 06:28:40.383] moon_app::systems::analyze  Installing proto 
[TRACE 06:28:40.383] starbase_utils::net  Checking for an internet connection  timeout=750
[TRACE 06:28:40.384] starbase_utils::net::offline  Resolving 1.1.1.1:53 
[TRACE 06:28:40.384] starbase::app  Running analyze phase 
[DEBUG 06:28:40.384] moon_cache::cache_engine  Creating cache engine  cache_dir="/home/runner/work/brainbooster/brainbooster/.moon/cache"
[DEBUG 06:28:40.384] moon_cache::hash_engine  Creating hash engine  hashes_dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/hashes" outputs_dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/outputs"
[DEBUG 06:28:40.384] moon_cache::state_engine  Creating states engine  states_dir="/home/runner/work/brainbooster/brainbooster/.moon/cache/states"
[DEBUG 06:28:40.384] moon_app::systems::analyze  Checking if proto is installed  proto="/home/runner/.proto/tools/proto/0.44.4/proto"
[DEBUG 06:28:40.384] moon_app::systems::analyze  Installing proto 
[TRACE 06:28:40.384] starbase_utils::net  Checking for an internet connection  timeout=750
[TRACE 06:28:40.384] starbase_utils::net::offline  Resolving 1.1.1.1:53 
[TRACE 06:28:40.386] starbase_utils::net  Online! 
[TRACE 06:28:40.386] starbase_utils::net  Online! 
[DEBUG 06:28:40.389] moon_app::systems::analyze  Downloading proto archive (x86_64-unknown-linux-gnu) 
[TRACE 06:28:40.389] proto_installer  Downloading proto release from https://github.com/moonrepo/proto/releases/download/v0.44.4/proto_cli-x86_64-unknown-linux-gnu.tar.xz  version="0.44.4" triple="x86_64-unknown-linux-gnu"
[DEBUG 06:28:40.389] moon_app::systems::analyze  Downloading proto archive (x86_64-unknown-linux-gnu) 
[TRACE 06:28:40.389] proto_installer  Downloading proto release from https://github.com/moonrepo/proto/releases/download/v0.44.4/proto_cli-x86_64-unknown-linux-gnu.tar.xz  version="0.44.4" triple="x86_64-unknown-linux-gnu"
[TRACE 06:28:40.403] starbase_utils::net  Downloading file from remote URL to local file  source_url="https://github.com/moonrepo/proto/releases/download/v0.44.4/proto_cli-x86_64-unknown-linux-gnu.tar.xz" dest_file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[TRACE 06:28:40.404] starbase_utils::net  Downloading file from remote URL to local file  source_url="https://github.com/moonrepo/proto/releases/download/v0.44.4/proto_cli-x86_64-unknown-linux-gnu.tar.xz" dest_file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[TRACE 06:28:40.597] starbase_utils::fs  Creating file  file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[TRACE 06:28:40.614] starbase_utils::fs  Creating file  file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[DEBUG 06:28:40.646] moon_app::systems::analyze  Unpacking archive and installing proto 
[TRACE 06:28:40.647] proto_installer  Unpacking downloaded and installing proto release  source="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz" target="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu"
[TRACE 06:28:40.647] starbase_archive::archive  Unpacking archive  output_dir="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu" input_file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[TRACE 06:28:40.647] starbase_archive::tree_differ  Creating a file tree differ for destination directory  dir="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu"
[TRACE 06:28:40.647] starbase_utils::fs  Opening file  file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[TRACE 06:28:40.647] starbase_utils::fs  Creating directory  dir="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu"
[TRACE 06:28:40.647] starbase_archive::tar  Opening tarball  output_dir="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu"
[DEBUG 06:28:40.656] moon_app::systems::analyze  Unpacking archive and installing proto 
[TRACE 06:28:40.656] proto_installer  Unpacking downloaded and installing proto release  source="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz" target="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu"
[TRACE 06:28:40.656] starbase_archive::archive  Unpacking archive  output_dir="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu" input_file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[TRACE 06:28:40.656] starbase_archive::tree_differ  Creating a file tree differ for destination directory  dir="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu"
[TRACE 06:28:40.656] starbase_utils::fs  Opening file  file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[TRACE 06:28:40.656] starbase_archive::tar  Opening tarball  output_dir="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu"
[TRACE 06:28:41.346] starbase_archive::tar  Unpacked 6 files 
[TRACE 06:28:41.347] starbase_archive::tree_differ  Removing stale and invalid files 
[TRACE 06:28:41.347] proto_installer  Moving unpacked proto binaries to the install directory  install_dir="/home/runner/.proto/tools/proto/0.44.4"
[TRACE 06:28:41.347] starbase_utils::fs  Creating directory  dir="/home/runner/.proto/tools/proto/0.44.4"
[TRACE 06:28:41.347] starbase_utils::fs  Copying file  from="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu/proto_cli-x86_64-unknown-linux-gnu/proto" to="/home/runner/.proto/tools/proto/0.44.4/proto"
[TRACE 06:28:41.386] starbase_archive::tar  Unpacked 6 files 
[TRACE 06:28:41.386] starbase_archive::tree_differ  Removing stale and invalid files 
[TRACE 06:28:41.387] proto_installer  Moving unpacked proto binaries to the install directory  install_dir="/home/runner/.proto/tools/proto/0.44.4"
[TRACE 06:28:41.387] starbase_utils::fs  Reading file metadata  file="/home/runner/.proto/tools/proto/0.44.4/proto"
[TRACE 06:28:41.387] starbase_utils::fs  Renaming file  from="/home/runner/.proto/tools/proto/0.44.4/proto" to="/home/runner/.proto/temp/proto"
[TRACE 06:28:41.387] starbase::app  Running shutdown phase (because another phase failed) 
[TRACE 06:28:41.387] starbase::app  Error: Failed to rename ~/.proto/tools/proto/0.44.4/proto to ~/.proto/temp/proto. 
[TRACE 06:28:41.387] moon_console::console  Closing console and flushing buffered output 
[TRACE 06:28:41.387] moon_console::buffer  Closing stderr stream 
[TRACE 06:28:41.387] moon_console::buffer  Closing stdout stream 
[TRACE 06:28:41.394] starbase_utils::fs  Updating file permissions  file="/home/runner/.proto/tools/proto/0.44.4/proto" mode="0o755"
[TRACE 06:28:41.394] starbase_utils::fs  Copying file  from="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu/proto_cli-x86_64-unknown-linux-gnu/proto-shim" to="/home/runner/.proto/tools/proto/0.44.4/proto-shim"
[TRACE 06:28:41.395] starbase_utils::fs  Updating file permissions  file="/home/runner/.proto/tools/proto/0.44.4/proto-shim" mode="0o755"
[TRACE 06:28:41.395] starbase_utils::fs  Removing directory  dir="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu"
[TRACE 06:28:41.401] starbase_utils::fs  Removing file  file="/home/runner/.proto/temp/proto_cli-x86_64-unknown-linux-gnu.tar.xz"
[TRACE 06:28:41.403] starbase_utils::fs  Writing file  file="/home/runner/.proto/temp/.last-used"
[DEBUG 06:28:41.403] moon_app::systems::analyze  Successfully installed proto! 
[DEBUG 06:28:41.403] moon_app::systems::analyze  Registering platforms based on toolchain configuration  platforms=[Node, Python]
[TRACE 06:28:41.403] starbase::app  Running execute phase 
[DEBUG 06:28:41.403] moon_app::queries::touched_files  Querying for touched files 
[DEBUG 06:28:41.403] moon_process::command_inspector  Running command git --version  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[DEBUG 06:28:41.405] moon_process::command_inspector  Running command git branch --show-current  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[DEBUG 06:28:41.407] moon_process::command_inspector  Running command git rev-parse --is-shallow-repository  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[TRACE 06:28:41.408] moon_app::queries::touched_files  Against remote using base "develop" with head "HEAD" 
[DEBUG 06:28:41.408] moon_process::command_inspector  Running command git merge-base develop HEAD  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[DEBUG 06:28:41.410] moon_process::command_inspector  Running command git merge-base origin/develop HEAD  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[DEBUG 06:28:41.4[16](https://github.com/brainboost-eu/brainbooster/actions/runs/12684789866/job/35354042071#step:4:17)] moon_process::command_inspector  Running command git merge-base upstream/develop HEAD  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[DEBUG 06:28:41.418] moon_process::command_inspector  Running command git merge-base HEAD origin/develop  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[DEBUG 06:28:41.423] moon_process::command_inspector  Running command git --no-pager diff --name-status --no-color --relative --ignore-submodules -z b2b8ee5916d6b2aae1ee509116a65f35097bbd72  env_vars={} working_dir=Some("/home/runner/work/brainbooster/brainbooster")
[TRACE 06:28:41.453] starbase::app  Setting exit code  code=1
Error: fs::rename
  × Failed to rename ~/.proto/tools/proto/0.44.4/proto to ~/.proto/temp/proto.
  ╰─▶ Is a directory (os error [21](https://github.com/brainboost-eu/brainbooster/actions/runs/12684789866/job/35354042071#step:4:22))
  help: Does the source file exist?
[DEBUG 06:28:41.642] moon_app::queries::touched_files  Filtering based on touched status all 
[DEBUG 06:28:41.642] moon_app::queries::touched_files  Found touched files  files=["infrastructure/terraform/azure/modules/services/virtual_subnet/outputs.tf", ".changeset/tiny-snails-behave.md", "infrastructure/terraform/azure/modules/services/key_vault/main.tf", "infrastructure/terraform/azure/modules/blocks/key_vault_secret/outputs.tf", "infrastructure/terraform/azure/modules/blocks/storage_account_network_rules/main.tf", "apps/django/docker/entrypoint.sh", "infrastructure/terraform/azure/modules/blocks/key_vault_access_policy/variables.tf", "infrastructure/terraform/azure/modules/blocks/frontdoor_endpoint/variables.tf", "infrastructure/terraform/azure/modules/blocks/private_endpoint_asg_association/variables.tf", "infrastructure/terraform/azure/modules/services/app_gateway/main.tf", "infrastructure/terraform/azure/modules/blocks/user_assigned_identity/main.tf", "infrastructure/terraform/azure/modules/services/frontdoor_rule_set/variables.tf", ".github/workflows/main.workflow.yml", "infrastructure/terrafor
Error: Process completed with exit code 1.

@milesj
Copy link
Contributor

milesj commented Jan 9, 2025

It looks like those 2 commands are running in parallel, instead of the 1st running and then piping to the 2nd.

That's probably what is causing this, some kind of race condition. I'm not sure why exactly that pipe would run in parallel...

@Blissful89
Copy link
Author

Blissful89 commented Jan 9, 2025

I am indeed running different setup-toolchain dependent workflows in parallel. Is that problematic? I did set the cache: false on this run so I thought it would not interfere with anything.
image

@milesj
Copy link
Contributor

milesj commented Jan 9, 2025

Is that running on the same box, or on different boxes? I can never tell with GH.

But yeah, it's a bit problematic, since moon does a bunch of stuff for setting up the workspace/toolchain, which can conflict. You can maybe have both of these steps depend on a parent step that does purely the setup stuff? Probably moon setup.

@Blissful89
Copy link
Author

I am just running on default runners. The lint task has a different set of requirements of active tooling, therefor I do

      # lint / unit test / anything that needs tooling
      - name: Inject Moon
        uses: moonrepo/setup-toolchain@v0
        with:
          auto-install: true

Whilst I don't need all those tooling in the moon query projects task, so I do

      # moon query task
      - name: Inject Moon
        uses: moonrepo/setup-toolchain@v0
        with:
          cache: false

They both run in parallel because lint does not need to know the affected projects, so it is just running a "simple" moon ci :lint. This means that I have two jobs running in parallel, on different runners:

jobs:
  affected:
    runs-on: ubuntu-latest
    name: Getting affected projects 🔍...

  unit:
    runs-on: ubuntu-latest
    name: Running ${{ matrix.workspace.name }} unit tests 🌡️...
    if: needs.affected.outputs.matrix != '[]'
    needs: [affected]
    strategy:
      matrix:
        workspace: ${{ fromJSON(needs.affected.outputs.matrix) }}

  lint:
    runs-on: ubuntu-latest
    name: Running affected lint 🔬...

In schematics thats:

affected
    /unit
lint

Our linting process is extra tedious, because we are running multiple code inspections, so I would prefer to keep that task in parallel. It is taking long enough as it is.

@milesj
Copy link
Contributor

milesj commented Jan 10, 2025

Ok that should be on 2 separate machines, so they wouldn't conflict.

The logs are very confusing though, especially these lines:

[DEBUG 2025-01-09 06:28:40.349] moon  Running moon v1.31.1 (with ~/.proto/bin/moon)  args=["moon", "query", "projects", "--affected", "--json"]
[DEBUG 2025-01-09 06:28:40.350] moon  Running moon v1.31.1 (with ~/.proto/bin/moon)  args=["moon", "query", "touched-files"]

2 instances of moon is running, 1 millisecond apart, while the query projects command is running first, and query touched-files is second, but in your snippet, it should be reversed???

This may be a bug in moon in regards to piping and not waiting for stdin correctly? I'll dig further.

@milesj
Copy link
Contributor

milesj commented Jan 10, 2025

After sleeping on this and reading a bit of docs, I think I know what's going on. So when commands are piped, they run in parallel (I thought there was some delay), but the 2nd command waits for the stdout of the 1st through stdin.

This is all working correctly, but, the proto install happens before the stdin check occurs, so we're hitting this race condition where they both are modifying the file system at the same time. I'm going to add some file system locks to help alleviate this.

I'm surprised this hasn't cropped up sooner? Did you upgrade moon recently?

@Blissful89
Copy link
Author

Blissful89 commented Jan 10, 2025

Actually yes. I recently upgraded from 1.29 to 1.31. I also reported a bug in moon itself regarding task inherritence. (Which you solved practically instantly by the way 😅)

edit maybe also important information is when this started occuring I also recently flushed the github caches. So it wasn't doing proto installs for a while because it was using the caches.

@milesj
Copy link
Contributor

milesj commented Jan 11, 2025

This should help: moonrepo/moon#1788

@Blissful89
Copy link
Author

This should help: moonrepo/moon#1788

Do I need to update my .prototools to a new moon version to verify this?

@milesj
Copy link
Contributor

milesj commented Jan 11, 2025

Yeah once I release it.

@Blissful89
Copy link
Author

@milesj . I see a release of 1.31.2. I will go and update our pipelines and see if it has effect.

@Blissful89
Copy link
Author

Blissful89 commented Jan 13, 2025

update - Just pinned 1.31.2, ran pipeline 5-6 times. Seems issue is resolved:
image

Thanks a lot for the fix @milesj . Rock solid response from you guys!

@milesj
Copy link
Contributor

milesj commented Jan 13, 2025

Awesome, glad it worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants