Hey folks! I discovered pants today, and I'm reall...
# general
m
Hey folks! I discovered pants today, and I'm really enjoying it! I'm trying to stretch it to fit all of my python/pnpm-vite-typescript/terraform monorepo, but I'm struggling with
vite
at the moment, because
uname
can't be found in the pants sandbox. Details in 🧵 , can anyone offer advice?
After setting up javascript, and configuring my
BUILD
in my static website builder subdirectory, I’m getting errors about
uname
not being findable:
Copy code
/private/var/folders/cn/x01prt2d69gf01kxxl5_dw_40000gn/T/pants-sandbox-c8MpRY/website/node_modules/.bin/vite: line 4: uname: command not found
Which makes sense, as
vite
does use `uname`; `website/node_modules/.bin/vite | head -n5`:
Copy code
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*)
I’ve tried adding
uname
as a
system_binary
(including the
pants.backend.experimental.adhoc
backend in my
pants.toml
) but I get the same issue. My
website/BUILD
looks like this.
Copy code
javascript_sources()

package_json(
    name="website-package",
    scripts=[
      node_build_script(
            entry_point = "build",
            output_directories = ["dist/"],
        )
    ],
    dependencies=[":uname"],
)

system_binary(
    name="uname",
    binary_name="uname",
)
(My
package.json
includes
"script" { "build": "vite build" }
, so nothing fancy there) I’d really appreciate any help, as I’m pretty sure I’m just missing something trivial! šŸ˜… [edited to include the uname dependencies line, as recommended below!]
h
I suspect you’ll want to add a dependency on that
system_binary
target. So set
dependencies=[":uname"]
in the
package_json
target perhaps.
šŸ’” 1
(I’m handwaving here because I’m not very familiar with the js backend, but I would imagine that dep is necessary, even if not sufficient…)
m
Ahhh of course! That exactly doesn’t work, but I can definitely see why not having a dependency listed would stop the
uname
system_binary
from being visible to
vite
. I’ll keep exploring. (by the by,
pants run website:uname
does correctly return
uname
output, so that part is working!)
I’ve now also tried adding
pants.backend.build_files.fmt.ruff
as a backend (as referenced here), and manually ensuring
/usr/bin
is in my
system_binary_paths
(as that’s where my
uname
is) — no luck!
Copy code
[system-binaries]
system_binary_paths = [
  "/usr/bin",
  "/bin",
  "/usr/local/bin",
  "/opt/homebrew/bin",
]
I managed to get
vite
to see
uname
by manually adding to the
PATH
. adding a dependency to
uname
as a
system_binary
and/or setting the paths for system binaries didn’t work (above). This feels very unlikely to be the ā€œrightā€ way to do things, but I’m not at all certain that I’m using the
system_binary
config above correctly. I’d love pointers if I’m misunderstanding!
Copy code
package_json(
    name="website-package",
    scripts=[
      node_build_script(
            entry_point = "build", # this runs "vite build"
            output_directories = ["dist/"],
        )
    ],
    extra_env_vars=["PATH=/usr/bin"],
)
h
Yeah, I don’t think that PATH hack should be necessary
Can you throw this into a small toy github repo with a README, so we’re all looking at the same thing?
šŸ‘ 1
m
I’ll see if I can one working the same way 😊
Hey @happy-kitchen-89482 — I created a toy repo and figured out a little bit of the weirdness. • The uname error still seems confusing (it distracted me from the proper error, just beneath) • The blocking error was that I hadn’t added a dependency on other
files
I needed for my build. • Adding the
files
dependency hid/removed the
uname
error • Adding my
/usr/bin
into the
PATH
made the
uname
error go away, which drew my attention to the blocking error. I think there’s a certain amount of PEBKAC here šŸ˜… but the
uname
error from
pants
seems unexpected, and definitely confused me (a very novice pants user!)
Let me know if you have any trouble with setting this up; the
nvm
dance is always a bit weird!