volta icon indicating copy to clipboard operation
volta copied to clipboard

`volta run yarn` works under Node 18.14, does nothing under Node 18.15, 18.16

Open cakoose opened this issue 11 months ago • 8 comments

Platform:

  • macOS 13.4.1
  • Volta 1.1.1, installed via Homebrew

Notes:

  • Normally, I just run yarn. I'm running volta run yarn here so I can pass the --verbose flag for more debugging info.
  • This used to work for me. I'm not sure why it stopped working. It works for my coworkers in the same repo. Is there anything else I can do to help debug?

Works with Node 18.14.0

$ volta pin [email protected]
success: pinned [email protected] (with [email protected]) in package.json
$ volta run --verbose -- yarn run asdf
[verbose] Found default configuration at '/Users/kannan/.volta/tools/user/platform.json'
[verbose] [email protected] has already been fetched, skipping download
[verbose] [email protected] has already been fetched, skipping download
[verbose] Active Image:
    Node: 18.14.0 from project configuration
    npm: 9.3.1 from project configuration
    pnpm: None
    Yarn: 1.22.19 from project configuration
Usage Error: Couldn't find a script named "asdf".

$ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] <scriptName> ...
[verbose] No custom hooks found

Doesn't seem to actually run Yarn when I set the Node version to 88.15.0

$ volta pin [email protected]
success: pinned [email protected] (with [email protected]) in package.json
$ volta run --verbose -- yarn run asdf
[verbose] Found default configuration at '/Users/kannan/.volta/tools/user/platform.json'
[verbose] [email protected] has already been fetched, skipping download
[verbose] [email protected] has already been fetched, skipping download
[verbose] Active Image:
    Node: 18.15.0 from project configuration
    npm: 9.5.0 from project configuration
    pnpm: None
    Yarn: 1.22.19 from project configuration
[verbose] No custom hooks found

Same as above with Node 18.16.0

$ volta pin [email protected]
success: pinned [email protected] (with [email protected]) in package.json
$ volta run --verbose -- yarn run asdf
[verbose] Found default configuration at '/Users/kannan/.volta/tools/user/platform.json'
[verbose] [email protected] has already been fetched, skipping download
[verbose] [email protected] has already been fetched, skipping download
[verbose] Active Image:
    Node: 18.16.0 from project configuration
    npm: 9.5.1 from project configuration
    pnpm: None
    Yarn: 1.22.19 from project configuration
[verbose] No custom hooks found

cakoose avatar Jul 14 '23 08:07 cakoose

Also, just noticed that I get a non-zero exit code:

$ volta run --verbose -- yarn
[verbose] [email protected] has already been fetched, skipping download
[verbose] [email protected] has already been fetched, skipping download
[verbose] Active Image:
    Node: 18.16.1 from project configuration
    npm: 9.5.1 from project configuration
    pnpm: None
    Yarn: 1.22.19 from project configuration
[verbose] No custom hooks found
$ echo $?
126
$ which -a yarn
/Users/kannan/.volta/bin/yarn
$ yarn
$ echo $?
1

cakoose avatar Jul 14 '23 22:07 cakoose

Yarn internally uses V8's code cache. Maybe a stale cache is causing problems. The v8-compile-cache package explains how to clear and disable it. Could be worth a try.

ide avatar Sep 12 '23 07:09 ide

@cakoose Did you ever get to the bottom of this? I'm experiencing something similar - however only in a child folder. Reinstalling volta didn't seem to help.

jinder avatar Oct 25 '23 16:10 jinder

No, I never found the issue, but it mysteriously started working again some time later so I haven't looked into it further.

@ide mentioned v8-compile-cache, so maybe that's a place to start? One idea is to try deleting Yarn's v8-compile-cache folder, though I'm not sure where that is 🤔

Maybe run yarn under a syscall tracing tool to see what files it accesses? Could use strace on Linux/BSD or dtruss/ktrace on MacOS. (Probably important to passing in the options to ensure any child processes are also traced.)

cakoose avatar Oct 25 '23 18:10 cakoose

I actually found deleting my .yarnrc.yml file made it work again - but there was nothing obviously wrong in it.

jinder avatar Oct 25 '23 19:10 jinder

@jinder: Interesting!

The ".yarnrc.yml" file does have the Yarn berry version, e.g.

yarnPath: .yarn/releases/yarn-3.5.0.cjs

So maybe deleting it and re-running Yarn caused it to download a new version, which may have invalidated any old cached data?

cakoose avatar Oct 25 '23 20:10 cakoose

Try rm -fr "$TMPDIR/v8-compile-cache-*".

IME a source of these problems is due to mismatches between Intel and Apple silicon software, namely Homebrew and Volta itself. If you've migrated your macOS setup from an Intel computer to an Apple silicon one, I've found it helpful to completely delete Homebrew and Volta and the software they've installed, and then reinstall them.

ide avatar Oct 25 '23 21:10 ide

Mine occurred on a Windows-only setup. My guess is it's something to do with Yarn's own version pinning which doesn't really play that well with Volta.

jinder avatar Oct 25 '23 21:10 jinder