moonrepo / proto

A pluggable multi-language version manager.
https://moonrepo.dev/proto
MIT License
631 stars 30 forks source link

proto upgrade failure when ran as a child process #568

Closed W1M0R closed 3 weeks ago

W1M0R commented 1 month ago

What version?

0.39.1

Which command?

proto upgrade

What happened?

The upgrade failed:

❯ proto upgrade
Error: fs::rename

  × Failed to rename ~\.proto\bin\proto.exe to ~\.proto\tools\proto\0.39.1\proto.exe.
  ╰─▶ Access is denied. (os error 5)
  help: Does the source file exist?
❯ rm ~\.proto\tools\proto\0.39.1\proto.exe
❯ proto upgrade
Upgraded proto to v0.39.2!

I tried upgrade proto a few times before I decided to manually delete the file. I'm not sure why upgrading 0.39.1->0.39.2 would initiate a rename of proto to 0.39.1.

Trace logs?

No response

Operating system?

Windows

Architecture?

x64

milesj commented 1 month ago

Yeah this is weird, let me look into it.

W1M0R commented 1 month ago

Maybe the way I am upgrading my proto environment could be contributing to the issue.

What do you think would happen in the following environment:

  1. just is provided by proto
  2. just has a recipe that updates proto, e.g. proto-upgrade
  3. proto is updated using just proto-upgrade

Effectively, the "process tree" probably looks something like this: proto-shim.exe->just.exe->proto.exe (that is, the proto upgrade is executing within the proto-shim hierarchy).

Here is a fake example execution trace to make the point:

❯ gcm just | select source   

Source
------
C:\Users\user2\.proto\shims\just.exe

❯ proto --version
proto 0.39.1

❯ just proto-upgrade
Error: fs::rename

  × Failed to rename ~\.proto\bin\proto.exe to ~\.proto\tools\proto\0.39.1\proto.exe.
  ╰─▶ Access is denied. (os error 5)
  help: Does the source file exist?

justfile:

proto-upgrade:
  proto upgrade

.prototools::

just = "1.32.0"
milesj commented 1 month ago

@W1M0R That may be. If you're still able to produce this, can you set PROTO_LOG=trace before upgrading? I'm curious exactly where the failure is happening.

milesj commented 1 month ago

Try 0.39.3

W1M0R commented 1 month ago

The upgrade to 0.39.3 from 0.39.2 via just (proto-shim) succeeded without issue.

❯ just sync      
proto upgrade
Upgraded proto to v0.39.3!
proto use
...

Thanks @milesj!

@W1M0R That may be. If you're still able to produce this, can you set PROTO_LOG=trace before upgrading? I'm curious exactly where the failure is happening.

Thanks for the tip. I'll keep this in mind if I see this error again.

milesj commented 1 month ago

I'll close this for now. If it happens again, feel free to reopen.

W1M0R commented 1 month ago

@milesj I just encountered this issue again. I have proto 0.39.3, and I execute the proto upgrade via a just recipe. Notice the first trace message indicates proto version 0.39.1. I remember that I briefly tested the proto version pinning behaviour when it came out, pinning it to 0.39.1, but then I removed the pin from my .prototools file. Maybe proto is still acting as if I've pinned it?

❯ just _proto-init
proto --version
proto 0.39.3
$Env:PROTO_LOG="trace"
proto upgrade
[DEBUG 2024-08-01 09:29:10.684] proto  Running proto v0.39.1  bin="C:\\Users\\user2\\.proto\\tools\\proto\\0.39.1\\proto.exe" args=["run", "just", "--", "_shell-refresh"] shim="just" shim_bin="C:\\Users\\user2\\.proto\\shims\\just.exe" pid=21476
[TRACE 09:29:10.687] starbase::app  Running startup phase
[DEBUG 09:29:10.691] proto_core::proto  Creating proto environment, detecting store  store="C:\\Users\\user2\\.proto"
[TRACE 09:29:10.692] starbase::app  Running analyze phase
[TRACE 09:29:10.693] proto_core::proto_config  Traversing upwards and loading .prototools files
[DEBUG 09:29:10.693] proto_core::proto_config  Loading .prototools  file="C:\\Users\\user2\\sdl\\src\\tms\\.prototools"
[TRACE 09:29:10.694] starbase_utils::fs  Reading file  file="C:\\Users\\user2\\sdl\\src\\tms\\.prototools"
[TRACE 09:29:10.694] schematic::config::loader  Loading partial configuration  config="ProtoConfig"
[TRACE 09:29:10.695] schematic::config::loader  Creating layer from source  config="ProtoConfig" source="<code>"
[TRACE 09:29:10.695] schematic::config::loader  Merging partial layers into a final result  config="ProtoConfig"
[DEBUG 09:29:10.696] proto_core::proto_config  Loading .prototools  file="C:\\Users\\user2\\sdl\\.prototools"
[TRACE 09:29:10.697] starbase_utils::fs  Reading file  file="C:\\Users\\user2\\sdl\\.prototools"
[TRACE 09:29:10.698] schematic::config::loader  Loading partial configuration  config="ProtoConfig"
[TRACE 09:29:10.698] schematic::config::loader  Creating layer from source  config="ProtoConfig" source="<code>"
[TRACE 09:29:10.699] schematic::config::loader  Merging partial layers into a final result  config="ProtoConfig"
[DEBUG 09:29:10.700] proto_core::proto_config  Loading .prototools  file="C:\\Users\\user2\\.proto\\.prototools"
[TRACE 09:29:10.701] starbase_utils::fs  Opening file  file="C:\\Users\\user2\\.proto\\.prototools"
[TRACE 09:29:10.701] starbase_utils::fs_lock  Locking file  file="C:\\Users\\user2\\.proto\\.prototools"
[TRACE 09:29:10.702] starbase_utils::fs_lock  Unlocking file  file="C:\\Users\\user2\\.proto\\.prototools"
[TRACE 09:29:10.703] schematic::config::loader  Loading partial configuration  config="ProtoConfig"
[TRACE 09:29:10.703] schematic::config::loader  Creating layer from source  config="ProtoConfig" source="<code>"
[TRACE 09:29:10.704] schematic::config::loader  Merging partial layers into a final result  config="ProtoConfig"
[DEBUG 09:29:10.704] proto_core::proto_config  Merging loaded configs
[DEBUG 09:29:10.704] proto_core::proto_config  Merged 3 configs
[DEBUG 09:29:10.705] proto_core::proto_config  Merging loaded configs without global
[DEBUG 09:29:10.705] proto_core::proto_config  Merged 2 configs
[TRACE 09:29:10.706] starbase::app  Running execute phase
[DEBUG 09:29:10.707] proto_core::tool_loader  Finding a configured plugin  tool="just"
[DEBUG 09:29:10.707] proto_core::tool_loader  Found a plugin  file="C:\\Users\\user2\\sdl\\.prototools" plugin="https://raw.githubusercontent.com/Phault/proto-toml-plugins/main/just/plugin.toml"
[TRACE 09:29:10.708] warpgate::loader  Creating plugin loader  cache_dir="C:\\Users\\user2\\.proto\\plugins"
[TRACE 09:29:10.709] warpgate::loader  Loading plugin just  id="just"
[TRACE 09:29:10.710] starbase_utils::fs  Reading file metadata  file="C:\\Users\\user2\\.proto\\plugins\\just-ee9b492977619f0aca55e132a87c7109e66fab246308d11168d39e9b4ceefe4e.toml"
[TRACE 09:29:10.710] warpgate::loader  Plugin already downloaded and cached  id="just" path="C:\\Users\\user2\\.proto\\plugins\\just-ee9b492977619f0aca55e132a87c7109e66fab246308d11168d39e9b4ceefe4e.toml"
[DEBUG 09:29:10.710] proto_core::tool_loader  Loading TOML plugin  source="C:\\Users\\user2\\.proto\\plugins\\just-ee9b492977619f0aca55e132a87c7109e66fab246308d11168d39e9b4ceefe4e.toml"
[DEBUG 09:29:10.711] proto_core::tool_loader  Finding a configured plugin  tool="internal-schema"
[DEBUG 09:29:10.711] proto_core::tool_loader  Using a built-in plugin  plugin="https://github.com/moonrepo/tools/releases/download/schema_tool-v0.14.1/schema_tool.wasm"
[TRACE 09:29:10.712] warpgate::loader  Loading plugin internal-schema  id="internal-schema"
[TRACE 09:29:10.713] starbase_utils::fs  Reading file metadata  file="C:\\Users\\user2\\.proto\\plugins\\internal-schema-590d05f47477efb4d5062bd942036e93888e08d9fa658615d412884ed7c29162.wasm"
[TRACE 09:29:10.713] warpgate::loader  Plugin already downloaded and cached  id="internal-schema" path="C:\\Users\\user2\\.proto\\plugins\\internal-schema-590d05f47477efb4d5062bd942036e93888e08d9fa658615d412884ed7c29162.wasm"
[TRACE 09:29:10.714] starbase_utils::fs  Reading file  file="C:\\Users\\user2\\.proto\\plugins\\just-ee9b492977619f0aca55e132a87c7109e66fab246308d11168d39e9b4ceefe4e.toml"
[TRACE 09:29:10.714] starbase_utils::toml  Reading TOML file  file="C:\\Users\\user2\\.proto\\plugins\\just-ee9b492977619f0aca55e132a87c7109e66fab246308d11168d39e9b4ceefe4e.toml"
[TRACE 09:29:10.715] starbase_utils::json  Formatting JSON
[TRACE 09:29:10.715] proto_core::tool_loader  Storing schema settings  schema={"name":"just","type":"cli","resolve":{"git-url":"https://github.com/casey/just"},"platform":{"linux":{"download-file":"just-{version}-{arch}-unknown-linux-musl.tar.gz"},"macos":{"download-file":"just-{version}-{arch}-apple-darwin.tar.gz"},"windows":{"download-file":"just-{version}-{arch}-pc-windows-msvc.zip"}},"install":{"download-url":"https://github.com/casey/just/releases/download/{version}/{download_file}"}}
[TRACE 09:29:10.716] warpgate::plugin  Storing plugin identifier  id="just"
[TRACE 09:29:10.717] warpgate::plugin  Storing host environment  env={"arch":"x64","libc":"unknown","os":"windows","home_dir":{"path":"/userhome/","virtual_prefix":"/userhome","real_prefix":"C:\\Users\\user2"}}
[DEBUG 09:29:10.718] proto_core::tool  Creating tool just and instantiating plugin
[TRACE 09:29:10.744] warpgate::plugin  Created plugin container  id="just" plugin="03f9f3bf-ea1a-47ac-b27d-ee8f644b388c"
[DEBUG 09:29:10.746] proto_core::tool  Created tool just and its WASM runtime
[TRACE 09:29:10.747] warpgate::plugin  Calling plugin function register_tool  id="just" plugin="03f9f3bf-ea1a-47ac-b27d-ee8f644b388c" input={"id":"just"}
[TRACE 09:29:10.748] warpgate::plugin  Called plugin function register_tool  id="just" plugin="03f9f3bf-ea1a-47ac-b27d-ee8f644b388c" output={"inventory":{},"name":"just","plugin_version":"0.14.1","type":"CLI"}
[DEBUG 09:29:10.749] proto_core::tool_manifest  Loading manifest.json  file="C:\\Users\\user2\\.proto\\tools\\just\\manifest.json"
[TRACE 09:29:10.749] starbase_utils::fs  Opening file  file="C:\\Users\\user2\\.proto\\tools\\just\\manifest.json"
[TRACE 09:29:10.750] starbase_utils::fs_lock  Locking file  file="C:\\Users\\user2\\.proto\\tools\\just\\manifest.json"
[TRACE 09:29:10.750] starbase_utils::fs_lock  Unlocking file  file="C:\\Users\\user2\\.proto\\tools\\just\\manifest.json"
[TRACE 09:29:10.751] proto_core::version_detector  Attempting to find version from .prototools files  tool="just"
[DEBUG 09:29:10.752] proto_core::version_detector  Detected version from .prototools file  tool="just" version="1.32.0" file="C:\\Users\\user2\\sdl\\.prototools"
[DEBUG 09:29:10.752] proto_core::tool  Resolving a semantic version or alias  tool="just" initial_version="1.32.0"
[DEBUG 09:29:10.753] proto_core::tool  Resolved to 1.32.0 (without validation)  tool="just" version="1.32.0"
[DEBUG 09:29:10.754] proto_core::tool  Checking if tool is installed  tool="just" install_dir="C:\\Users\\user2\\.proto\\tools\\just\\1.32.0"
[DEBUG 09:29:10.755] proto_core::tool  Tool has already been installed, locating binaries and shims  tool="just" install_dir="C:\\Users\\user2\\.proto\\tools\\just\\1.32.0"
[DEBUG 09:29:10.755] proto_core::tool  Locating executable for tool  tool="just"
[TRACE 09:29:10.756] warpgate::plugin  Calling plugin function locate_executables  id="just" plugin="03f9f3bf-ea1a-47ac-b27d-ee8f644b388c" input={"context":{"proto_version":"0.39.1","tool_dir":{"path":"/proto/tools/just/1.32.0","virtual_prefix":"/proto","real_prefix":"C:\\Users\\user2\\.proto"},"version":"1.32.0"}}
[TRACE 09:29:10.757] warpgate::plugin  Called plugin function locate_executables  id="just" plugin="03f9f3bf-ea1a-47ac-b27d-ee8f644b388c" output={"primary":{"exe_path":"just.exe"}}
[DEBUG 09:29:10.758] proto_core::tool  Found an executable  tool="just" exe_path="C:\\Users\\user2\\.proto\\tools\\just\\1.32.0\\just.exe"
[DEBUG 09:29:10.759] proto::commands::run  Running just  bin="C:\\Users\\user2\\.proto\\tools\\just\\1.32.0\\just.exe" args=["_shell-refresh"] pid=21476
[TRACE 09:29:10.761] starbase_utils::fs  Writing file  file="C:\\Users\\user2\\.proto\\tools\\just\\1.32.0\\.last-used"
proto upgrade
[DEBUG 2024-08-01 09:29:12.027] proto  Running proto v0.39.3  bin="C:\\Users\\user2\\.proto\\bin\\proto.exe" args=["upgrade"] shim="just" shim_bin="C:\\Users\\user2\\.proto\\shims\\just.exe" pid=13008
[TRACE 09:29:12.029] starbase::app  Running startup phase
[DEBUG 09:29:12.033] proto_core::proto  Creating proto environment, detecting store  store="C:\\Users\\user2\\.proto"
[TRACE 09:29:12.034] starbase::app  Running analyze phase
[TRACE 09:29:12.035] proto_core::proto_config  Traversing upwards and loading .prototools files
[DEBUG 09:29:12.035] proto_core::proto_config  Loading .prototools  file="C:\\Users\\user2\\sdl\\src\\tms\\.prototools"
[TRACE 09:29:12.036] starbase_utils::fs  Reading file  file="C:\\Users\\user2\\sdl\\src\\tms\\.prototools"
[TRACE 09:29:12.036] schematic::config::loader  Loading partial configuration  config="ProtoConfig"
[TRACE 09:29:12.037] schematic::config::loader  Creating layer from source  config="ProtoConfig" source="<code>"
[TRACE 09:29:12.039] schematic::config::loader  Merging partial layers into a final result  config="ProtoConfig"
[DEBUG 09:29:12.040] proto_core::proto_config  Loading .prototools  file="C:\\Users\\user2\\sdl\\.prototools"
[TRACE 09:29:12.040] starbase_utils::fs  Reading file  file="C:\\Users\\user2\\sdl\\.prototools"
[TRACE 09:29:12.041] schematic::config::loader  Loading partial configuration  config="ProtoConfig"
[TRACE 09:29:12.041] schematic::config::loader  Creating layer from source  config="ProtoConfig" source="<code>"
[TRACE 09:29:12.042] schematic::config::loader  Merging partial layers into a final result  config="ProtoConfig"
[DEBUG 09:29:12.043] proto_core::proto_config  Loading .prototools  file="C:\\Users\\user2\\.proto\\.prototools"
[TRACE 09:29:12.044] starbase_utils::fs  Opening file  file="C:\\Users\\user2\\.proto\\.prototools"
[TRACE 09:29:12.044] starbase_utils::fs_lock  Locking file  file="C:\\Users\\user2\\.proto\\.prototools"
[TRACE 09:29:12.045] starbase_utils::fs_lock  Unlocking file  file="C:\\Users\\user2\\.proto\\.prototools"
[TRACE 09:29:12.045] schematic::config::loader  Loading partial configuration  config="ProtoConfig"
[TRACE 09:29:12.046] schematic::config::loader  Creating layer from source  config="ProtoConfig" source="<code>"
[TRACE 09:29:12.047] schematic::config::loader  Merging partial layers into a final result  config="ProtoConfig"
[DEBUG 09:29:12.047] proto_core::proto_config  Merging loaded configs
[DEBUG 09:29:12.048] proto_core::proto_config  Merged 3 configs
[DEBUG 09:29:12.048] proto_core::proto_config  Merging loaded configs without global
[DEBUG 09:29:12.048] proto_core::proto_config  Merged 2 configs
[TRACE 09:29:12.049] starbase::app  Running execute phase
[TRACE 09:29:12.049] starbase_utils::net  Checking for an internet connection  timeout=750
[TRACE 09:29:12.050] starbase_utils::net::offline  Resolving 1.1.1.1:53
[TRACE 09:29:12.053] starbase_utils::net::offline  Resolving 1.0.0.1:53
[TRACE 09:29:12.054] starbase_utils::net::offline  Resolving 8.8.8.8:53
[TRACE 09:29:12.055] starbase_utils::net::offline  Resolving 8.8.4.4:53
[TRACE 09:29:12.829] starbase_utils::net::offline  Resolving 142.251.47.206:80
[TRACE 09:29:12.880] starbase_utils::net  Online!
[DEBUG 09:29:12.915] proto::helpers  Found latest version 0.39.4
[DEBUG 09:29:12.916] proto::commands::upgrade  Comparing target version 0.39.4 to current version 0.39.3
[DEBUG 09:29:12.917] proto::commands::upgrade  Download target: x86_64-pc-windows-msvc
[TRACE 09:29:12.918] proto_installer  Downloading proto release from https://github.com/moonrepo/proto/releases/download/v0.39.4/proto_cli-x86_64-pc-windows-msvc.zip  version="0.39.4" triple="x86_64-pc-windows-msvc"
──────────────────────────────────────────────────────────────────────────────── | 0 B / 19.85 MiB | 0 B/s | eta 0s     [TRACE 09:29:14.221] proto::commands::upgrade  Downloaded 0 of 20809450 bytes
[TRACE 09:29:14.223] starbase_utils::fs  Creating file  file="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc.zip"
╾─────────────────────────────────────────────────────────────────────────────── | 16.00 KiB / 19.85 MiB | 12.22 KiB/s |
...
── | 317.50 KiB / 19.85 MiB | 15.33 KiB/s | eta 22m[TRACE 09:29:14.261] proto::commands::upgrade  Downloaded 325121 of 20809450 bytes
[TRACE 09:29:14.263] proto::commands::upgrade  Downloaded 341505 of 20809450 bytes

...

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╾─ | 19.37 MiB / 19.85 MiB | 2.86 MiB/s | eta 0s[TRACE 09:29:16.218] proto::commands::upgrade  Downloaded 20313601 of 20809450 bytes
[TRACE 09:29:16.222] proto::commands::upgrade  Downloaded 20329985 of 20809450 bytes
[TRACE 09:29:16.224] proto::commands::upgrade  Downloaded 20346369 of 20809450 bytes
[TRACE 09:29:16.225] proto::commands::upgrade  Downloaded 20362753 of 20809450 bytes
[TRACE 09:29:16.225] proto::commands::upgrade  Downloaded 20379137 of 20809450 bytes
[TRACE 09:29:16.228] proto::commands::upgrade  Downloaded 20395521 of 20809450 bytes
[TRACE 09:29:16.229] proto::commands::upgrade  Downloaded 20411905 of 20809450 bytes
[TRACE 09:29:16.230] proto::commands::upgrade  Downloaded 20428289 of 20809450 bytes
[TRACE 09:29:16.231] proto::commands::upgrade  Downloaded 20444673 of 20809450 bytes
[TRACE 09:29:16.234] proto::commands::upgrade  Downloaded 20461057 of 20809450 bytes
[TRACE 09:29:16.234] proto::commands::upgrade  Downloaded 20477441 of 20809450 bytes
[TRACE 09:29:16.236] proto::commands::upgrade  Downloaded 20493825 of 20809450 bytes
[TRACE 09:29:16.237] proto::commands::upgrade  Downloaded 20510209 of 20809450 bytes
[TRACE 09:29:16.239] proto::commands::upgrade  Downloaded 20526593 of 20809450 bytes
[TRACE 09:29:16.240] proto::commands::upgrade  Downloaded 20542977 of 20809450 bytes
[TRACE 09:29:16.241] proto::commands::upgrade  Downloaded 20559361 of 20809450 bytes
[TRACE 09:29:16.242] proto::commands::upgrade  Downloaded 20575745 of 20809450 bytes
[TRACE 09:29:16.247] proto::commands::upgrade  Downloaded 20592129 of 20809450 bytes
[TRACE 09:29:16.249] proto::commands::upgrade  Downloaded 20608513 of 20809450 bytes
[TRACE 09:29:16.250] proto::commands::upgrade  Downloaded 20624897 of 20809450 bytes
[TRACE 09:29:16.251] proto::commands::upgrade  Downloaded 20641281 of 20809450 bytes
[TRACE 09:29:16.254] proto::commands::upgrade  Downloaded 20657665 of 20809450 bytes
[TRACE 09:29:16.256] proto::commands::upgrade  Downloaded 20674049 of 20809450 bytes
[TRACE 09:29:16.257] proto::commands::upgrade  Downloaded 20690433 of 20809450 bytes
[TRACE 09:29:16.258] proto::commands::upgrade  Downloaded 20706817 of 20809450 bytes
[TRACE 09:29:16.260] proto::commands::upgrade  Downloaded 20723201 of 20809450 bytes
[TRACE 09:29:16.262] proto::commands::upgrade  Downloaded 20739585 of 20809450 bytes
[TRACE 09:29:16.263] proto::commands::upgrade  Downloaded 20755969 of 20809450 bytes
[TRACE 09:29:16.263] proto::commands::upgrade  Downloaded 20772353 of 20809450 bytes
[TRACE 09:29:16.266] proto::commands::upgrade  Downloaded 20788737 of 20809450 bytes
[TRACE 09:29:16.266] proto::commands::upgrade  Downloaded 20805121 of 20809450 bytes
[DEBUG 09:29:16.267] proto::commands::upgrade  Unpacking download  archive="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc.zip"
[TRACE 09:29:16.268] proto_installer  Unpacking downloaded proto release  source="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc.zip" target="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc"
[TRACE 09:29:16.268] starbase_archive::archive  Unpacking archive  output_dir="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc" input_file="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc.zip"
[TRACE 09:29:16.268] starbase_archive::tree_differ  Creating a file tree differ for destination directory  dir="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc"
[TRACE 09:29:16.269] starbase_utils::fs  Opening file  file="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc.zip"
[TRACE 09:29:16.432] starbase_archive::zip  Opening zip  output_dir="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc"
[TRACE 09:29:16.436] starbase_utils::fs  Creating file  file="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc\\CHANGELOG.md"
[TRACE 09:29:16.438] starbase_utils::fs  Creating file  file="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc\\LICENSE"
[TRACE 09:29:16.440] starbase_utils::fs  Creating file  file="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc\\proto-shim.exe"
[TRACE 09:29:16.442] starbase_utils::fs  Creating file  file="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc\\proto.exe"
[TRACE 09:29:16.473] starbase_utils::fs  Creating file  file="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc\\README.md"
[TRACE 09:29:16.475] starbase_archive::zip  Unpacked 5 files
[TRACE 09:29:16.476] starbase_archive::tree_differ  Removing stale and invalid files
[TRACE 09:29:16.477] proto_installer  Relocating old proto binary to a new versioned location  source="C:\\Users\\user2\\.proto\\bin\\proto.exe" target="C:\\Users\\user2\\.proto\\tools\\proto\\0.39.3\\proto.exe"
[TRACE 09:29:16.478] starbase_utils::fs  Copying file  from="C:\\Users\\user2\\.proto\\bin\\proto.exe" to="C:\\Users\\user2\\.proto\\tools\\proto\\0.39.3\\proto.exe"
[TRACE 09:29:16.494] starbase_utils::fs  Writing file  file="C:\\Users\\user2\\.proto\\tools\\proto\\0.39.3\\.last-used"
[TRACE 09:29:16.495] proto_installer  Relocating old proto binary to a new versioned location  source="C:\\Users\\user2\\.proto\\bin\\proto-shim.exe" target="C:\\Users\\user2\\.proto\\tools\\proto\\0.39.3\\proto-shim.exe"
[TRACE 09:29:16.496] starbase_utils::fs  Copying file  from="C:\\Users\\user2\\.proto\\bin\\proto-shim.exe" to="C:\\Users\\user2\\.proto\\tools\\proto\\0.39.3\\proto-shim.exe"
[TRACE 09:29:16.499] starbase_utils::fs  Writing file  file="C:\\Users\\user2\\.proto\\tools\\proto\\0.39.3\\.last-used"
[TRACE 09:29:16.504] proto_installer  Moving unpacked proto binaries to the install directory  install_dir="C:\\Users\\user2\\.proto\\bin"
[TRACE 09:29:16.506] starbase_utils::fs  Copying file  from="C:\\Users\\user2\\.proto\\temp\\proto_cli-x86_64-pc-windows-msvc\\proto.exe" to="C:\\Users\\user2\\.proto\\bin\\proto.exe"
[TRACE 09:29:16.510] starbase::app  Running shutdown phase (because another phase failed)
Error: fs::copy

  × Failed to copy ~\.proto\temp\proto_cli-x86_64-pc-windows-msvc\proto.exe to ~\.proto\bin\proto.exe.
  ╰─▶ The process cannot access the file because it is being used by another process. (os error 32)
  help: Does the source file exist?

error: Recipe `_proto-init` failed on line 426 with exit code 1

Related links:

  1. 547

  2. https://github.com/moonrepo/proto/pull/560
milesj commented 1 month ago

Hrmm I'm not sure what the fix is here right now. When a process runs itself, self-upgrading (moving/copying the file) is possible, but it looks like it's not possible when spawned as a child process from something else. I'll need to research this a bit.

W1M0R commented 1 month ago

but it looks like it's not possible when spawned as a child process from something else. I'll need to research this a bit.

I don't need to (and probably shouldn't) automate proto upgrades the way I am doing now, via a proto shim just recipe. With this in mind, it's probably not necessary to spend much more time on this issue. If I do want to continue doing this via just, I could always install just outside of proto, which would prevent this kind of thing from happening.

In terms of the pinning behaviour, do you think it might be a bug that proto is Running proto v0.39.1, even though I have 0.39.3 installed and don't have it pinned in my .prototools file anymore? I don't see proto pinned in the global ~/.proto/.prototools either.

milesj commented 1 month ago

@W1M0R

Based on the logs, it seems right if the pin exists somewhere. Pinning proto only applies to shims, so the just shim is inheriting proto 0.39.1. When just calls proto, that uses the global proto which is 0.39.3. You can see this in the middle of the logs.

Are you using proto activate by chance? If not, it may be a bug, I'll dig in.

W1M0R commented 1 month ago

@milesj I'm not using proto activate.

milesj commented 3 weeks ago

Gonna close this as the original error seems to have gone away.