Skip to content

proto use: unexpected lookup into parent folder and parsing a random package.json causing unexpected error #922

@k0pernikus

Description

@k0pernikus

Setting up a new machine with proto and in a project's dir calling:

PS C:\Users\Philipp\PycharmProjects\fizzbuzz> cat .\.prototools
uv = "0.9.26"
PS C:\Users\Philipp\PycharmProjects\fizzbuzz> proto install uv  --pin

│ SUCCESS                                                                                                                                                                                                                                                                                                          
│ uv 0.9.26 has been installed to C:\Users\Philipp\.proto\tools\uv\0.9.26!

PS C:\Users\Philipp\PycharmProjects\fizzbuzz> cat .\.prototools
uv = "0.9.26"
PS C:\Users\Philipp\PycharmProjects\fizzbuzz> proto use
Error: proto::commands::install::requirements_not_met

  × yarn requires node to function correctly, but it has not been installed.
  help: Try configuring a version of the required tool in .prototools

I did not require yarn, I was very confused why this was required.

proto status revealed that a parent folder was sourced:

PS C:\Users\Philipp\PycharmProjects\fizzbuzz> proto diagnose 

│ SUCCESS                                                                                                                                                                                                                                                                                                          
│ No issues detected with your proto installation!

PS C:\Users\Philipp\PycharmProjects\fizzbuzz> proto status                     
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│Tool        Configured    Resolved      Installed                                                                                     Config                                                                                                                                                                     │
│─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│
│uv          0.9.26        0.9.26        C:\Users\Philipp\.proto\tools\uv\0.9.26                                                       C:\Users\Philipp\PycharmProjects\fizzbuzz\.prototools                                                                                                                      │
│yarn        4.12.0        4.12.0        No                                                                                            C:\Users\Philipp\package.json                                                                                                                                              │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
PS C:\Users\Philipp\PycharmProjects\fizzbuzz> 

I was under the assumption that proto would source only .prototools files in the local dir. I did not expect it to go up beyond the current path, and even more so that it would parse a package.json file and treat it as a depenedency:

PS C:\Users\Philipp\PycharmProjects\fizzbuzz> cat ..\..\package.json

{
  "packageManager": "yarn@4.12.0"
}

Reading up on the docs I thought I could do:

[settings]
detect-strategy = "only-prototools"

uv = "0.9.26"

yet this leads to

proto use
Error: config::parse::failed

  × Failed to parse ProtoConfig.
  ╰─▶   × settings.uv: unknown field `uv`, expected one of `auto-clean`, `auto-install`, `build`, `builtin-plugins`, `cache-duration`, `detect-strategy`, `http`, `lockfile`, `unstable-lockfile`, `offline`, `pin-latest`, `registries`, `unstable-registries`, `telemetry`, `url-rewrites`
         ╭─[.prototools.toml:4:1]
       3 │
       4 │ uv = "0.9.26"
         · ─┬
         ·  ╰── Fix this
         ╰────

Deleting the package and just using

[settings]
detect-strategy = "only-prototools"

and then calling

 proto install uv  --pin

│ INFO                                                                                                                                                                                                                                                                                                             
│ uv 0.9.26 has already been installed at C:\Users\Philipp\.proto\tools\uv\0.9.26!

led to a working setup and the file that now looks like:

uv = "0.9.26"
[settings]
detect-strategy = "only-prototools"

My expectation:

  • order in prototools should not matter
    • alternative: error should indicate the section it is looking for
  • proto having a default that only-prototools provides
    • i know other package manager like yarn / npm do it as well, I hate that
    • if they do, they should issue an info / warning as this is potential unwanted behavior

I am thankful you provided proto status as it helped me resolve this issue. Though first I tried proto diagnose. I was expecting this to give me a hint about the parent source json file.


This part of the docs also highlights the behavior:
https://moonrepo.dev/docs/proto/detection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions