Open angel-luis opened 3 months ago
It looks like yarn versions are stepping on each other. You're mentioning that you're using yarn v1 but this log is from Yarn v4:
yarn dlx create-turbo@canary test-turbo-canary ➤ YN0000: · Yarn 4.2.2 ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + create-turbo@npm:2.0.3-canary.0, @tootallnate/quickjs-emscripten@npm:0.23.0, and 104 more. ➤ YN0000: └ Completed in 1s 457ms ➤ YN0000: ┌ Fetch step ➤ YN0013: │ 106 packages were added to the project (+ 13.68 MiB). ➤ YN0000: └ Completed ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed ➤ YN0000: · Done in 1s 583ms
It looks like yarn versions are stepping on each other. You're mentioning that you're using yarn v1 but this log is from Yarn v4:
yarn dlx create-turbo@canary test-turbo-canary ➤ YN0000: · Yarn 4.2.2 ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + create-turbo@npm:2.0.3-canary.0, @tootallnate/quickjs-emscripten@npm:0.23.0, and 104 more. ➤ YN0000: └ Completed in 1s 457ms ➤ YN0000: ┌ Fetch step ➤ YN0013: │ 106 packages were added to the project (+ 13.68 MiB). ➤ YN0000: └ Completed ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed ➤ YN0000: · Done in 1s 583ms
Yes, I'm using v1 since with corepack enabled
is the version Node gives you. yarn -v
prints me 1.22.22
when I'm in the root dir, previously to install yarn dlx create-turbo@latest
. Probably corepack changes automatically to the new version when using dlx
command, but I'm not sure how corepack works in this aspect.
Using for example, yarn dlx create-turbo@latest --example with-tailwind
works fine. And I remember about 2 weeks ago to install turbo without any problem.
Thanks for that detail. Continuing to look at what's going on here.
I'm a bit of a loss on this one. I'm using create-turbo@2.0.4-canary.3
and can't seem to reproduce this while using yarn 1 globally with Corepack enabled or disabled.
The only error I can produce is using yarn dlx create-turbo@2.0.4-canary.3
with global yarn 4, which yields this error:
Error: Command failed with exit code 1: yarn install --no-immutable
Usage Error: The nearest package directory (/Users/anthonyshew/projects/debugs/yarnw) doesn't seem to be part of the project declared in /Users/anthonyshew/projects.
- If /Users/anthonyshew/projects isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If /Users/anthonyshew/projects is intended to be a project, it might be that you forgot to list debugs/yarnw in its workspace configuration.
- Finally, if /Users/anthonyshew/projects is fine and you intend debugs/yarnw to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.
$ yarn install [--json] [--immutable] [--immutable-cache] [--refresh-lockfile] [--check-cache] [--check-resolutions] [--inline-builds] [--mode #0]
at eN (/private/var/folders/0r/90dc16493lx7gw025k4z8sw40000gn/T/xfs-22628b3e/dlx-41955/.yarn/cache/create-turbo-npm-2.0.4-canary.3-7b93c2fe3a-235ccc7432.zip/node_modules/create-turbo/dist/cli.js:12:57)
at /private/var/folders/0r/90dc16493lx7gw025k4z8sw40000gn/T/xfs-22628b3e/dlx-41955/.yarn/cache/create-turbo-npm-2.0.4-canary.3-7b93c2fe3a-235ccc7432.zip/node_modules/create-turbo/dist/cli.js:12:8077
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Fl (/private/var/folders/0r/90dc16493lx7gw025k4z8sw40000gn/T/xfs-22628b3e/dlx-41955/.yarn/cache/create-turbo-npm-2.0.4-canary.3-7b93c2fe3a-235ccc7432.zip/node_modules/create-turbo/dist/cli.js:60:2092)
at async Command.y0 (/private/var/folders/0r/90dc16493lx7gw025k4z8sw40000gn/T/xfs-22628b3e/dlx-41955/.yarn/cache/create-turbo-npm-2.0.4-canary.3-7b93c2fe3a-235ccc7432.zip/node_modules/create-turbo/dist/cli.js:87:2101)
at async Command.parseAsync (/private/var/folders/0r/90dc16493lx7gw025k4z8sw40000gn/T/xfs-22628b3e/dlx-41955/.yarn/cache/commander-npm-11.1.0-56e979613c-13cc6ac875.zip/node_modules/commander/lib/command.js:936:5) {
shortMessage: 'Command failed with exit code 1: yarn install --no-immutable',
command: 'yarn install --no-immutable',
escapedCommand: 'yarn install --no-immutable',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: "\x1B[31m\x1B[1mUsage Error\x1B[22m\x1B[39m: The nearest package directory (/Users/anthonyshew/projects/debugs/yarnw) doesn't seem to be part of the project declared in /Users/anthonyshew/projects.\n" +
'\n' +
"- If /Users/anthonyshew/projects isn't intended to be a project, remove any yarn.lock and/or package.json file there.\n" +
'- If /Users/anthonyshew/projects is intended to be a project, it might be that you forgot to list debugs/yarnw in its workspace configuration.\n' +
'- Finally, if /Users/anthonyshew/projects is fine and you intend debugs/yarnw to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.\n' +
'\n' +
'\x1B[1m$ \x1B[22myarn install [--json] [--immutable] [--immutable-cache] [--refresh-lockfile] [--check-cache] [--check-resolutions] [--inline-builds] [--mode #0]',
stderr: '',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
However, this is an error log for Yarn 4 not recognizing the outputs of create-turbo
as a Yarn 4 project - because it isn't. I expect to see this error, since our transforms don't support Yarn 4, but it's not the issue shown in the report.
I'm led to believe that this is a Yarn-specific issue somewhere around installation and caching after finding these GitHub issues:
I tried it with create-turbo@2.0.4-canary.3
and same error. In my case I'm using nvm
instead of installing Node directly, but I think this shouldn't affect to the process.
I've found a related issue in Cypress caused by webpack, I don't know if Turborepo uses webpack but if can help, here is the PR:
I did see that one when I was looking around but create-turbo
doesn't get bundled with webpack so I have a hard time seeing it as a culprit.
Seeing as I can't reproduce and there's some history around this that shows it's likely a problem that comes from elsewhere, I'm going to leave this issue open and see if we have anybody else run into it.
Hello @anthonyshew !
I encountered the same issue. Some examples are created without issues (with-berry / with-tailwind), others are not (with-docker).
I only have yarn 4.3.1 installed on my system, through corepack
~$ which yarn
yarn: not found in (...$PATH)
~$ corepack enable --install-directory ~/.corepack yarn
~$ which yarn
~/.corepack/yarn
~$ yarn -v
! Corepack is about to download https://registry.yarnpkg.com/yarn/-/yarn-1.22.22.tgz
? Do you want to continue? [Y/n] n
~$ corepack install -g yarn@stable
~$ which yarn
~/.corepack/yarn
~$ yarn -v
4.3.1
yarn dlx ...
shows it is using yarn 4.2.2 but it's expected (see below)
~$ yarn dlx create-turbo@latest --example with-docker
! Corepack is about to download https://repo.yarnpkg.com/4.2.2/packages/yarnpkg-cli/bin/yarn.js
? Do you want to continue? [Y/n] n
Explanations
corepack
in shell
/usr/bin/corepack
/usr/lib/node_modules/corepack/dist/corepack.js
/usr/lib/node/corepack/dist/lib/corepack.cjs
yarn
in shell
~/.corepack/yarn
/usr/lib/node_modules/corepack/dist/yarn.js
#!/usr/bin/env node
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT??='1'
require('./lib/corepack.cjs').runMain(['yarn', ...process.argv.slice(2)]);
corepack.cjs
contains this default config
The important part is that corepack references and downloads on demand yarn 4.2.2 when using yarn init
or yarn dlx
.
We don't really care which yarn 2+ version corepack uses under the hood because yarn dlx
is not available for yarn 1 anyway.
The alternative way to use yarn 1 with corepack, without enabling it globally, is to run
corepack yarn@1 create turbo --example with-docker
Or if you want to enforce the latest version of yarn
corepack yarn@4 dlx create-turbo@latest --example with-docker
What is happening
Corepack automatically proxies all invocations of yarn
and uses either
packageManager
field inside the package.json
of the projectpackageManager
Turbo examples have a different version depending on the example
yarn dlx create-turbo@latest
) has "packageManager": "yarn@4.3.1"
"packageManager": "yarn@3.6.3"
"packageManager": "yarn@4.3.1"
"packageManager": "yarn@1.22.19"
All examples using yarn@1.x
don't work with yarn dlx
proxied by corepack. They error with the following yarn-error.log
What seem to happen is
yarn dlx
call to use a specific yarn version (4.2.2 by default or 4.3.1 when using corepack yarn@4 dlx ...
)create-turbo
process spawns a subprocess yarn install --no-immutable
(?)yarn
invocation is proxied by corepackpackageManager
in the example's package.json
and uses the appropriate versionAfter the yarn dlx create-turbo
errors during the install step, manually going to the turbo repo that was created and doing a yarn install --no-immutable
works. This manual step is using the version of yarn defined by the packageManager
field (1.22.19 for the with-docker
example). Corepack is is doing the same thing as when turbo is invoking the install.
The entire display of yarn dlx create-trubo@latest --example with-docker
can be found below
The interesting part may be
at QB (/tmp/xfs-8591230c/dlx-28814/.yarn/cache/create-turbo-npm-2.0.5-ada6fa7eaa-9b51f39f72.zip/node_modules/create-turbo/dist/cli.js:12:57)
at /tmp/xfs-8591230c/dlx-28814/.yarn/cache/create-turbo-npm-2.0.5-ada6fa7eaa-9b51f39f72.zip/node_modules/create-turbo/dist/cli.js:12:8077
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Fl (/tmp/xfs-8591230c/dlx-28814/.yarn/cache/create-turbo-npm-2.0.5-ada6fa7eaa-9b51f39f72.zip/node_modules/create-turbo/dist/cli.js:58:2092)
at async Command.m0 (/tmp/xfs-8591230c/dlx-28814/.yarn/cache/create-turbo-npm-2.0.5-ada6fa7eaa-9b51f39f72.zip/node_modules/create-turbo/dist/cli.js:83:7484)
at async Command.parseAsync (/tmp/xfs-8591230c/dlx-28814/.yarn/cache/commander-npm-11.1.0-56e979613c-13cc6ac875.zip/node_modules/commander/lib/command.js:936:5)
Faced the same issue, resolved by downgrading node to v18.12.0
Verify canary release
What package manager are you using / does the bug impact?
Yarn v1
What operating system are you using?
Mac
Describe the Bug
yarn dlx create-turbo@canary test-turbo-canary ➤ YN0000: · Yarn 4.2.2 ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + create-turbo@npm:2.0.3-canary.0, @tootallnate/quickjs-emscripten@npm:0.23.0, and 104 more. ➤ YN0000: └ Completed in 1s 457ms ➤ YN0000: ┌ Fetch step ➤ YN0013: │ 106 packages were added to the project (+ 13.68 MiB). ➤ YN0000: └ Completed ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed ➤ YN0000: · Done in 1s 583ms
? Which package manager do you want to use? yarn workspaces
Downloading files. This might take a moment.
apps
Installing packages. This might take a couple of minutes.
To Reproduce
yarn dlx create-turbo@latest
oryarn dlx create-turbo@canary
node v20.14.0 yarn v1.22.22