Hey,
I’ve been facing an issue recently during deployment where the vercel cli doubles the root directory which leads to the deployment failing because there’s no path as apps/web/apps/web.
Problem
To describe my flow, my Vercel Project settings are set as follows:
- Root Directory:
apps/web - Build command:
cd ../.. && turbo build
Configuration
Then, here’s my root workspace package.json with the following scripts:
{
"scripts": {
"vercel:link": "vercel link --yes --repo",
"vercel:envs": "turbo run vercel:envs",
"vercel:build": "turbo run vercel:build",
"vercel:deploy": "turbo run vercel:deploy"
}
}
This runs the scripts in the apps/web/package.json which are describe as follows:
{
"scripts": {
"vercel:link": "vercel link --yes --repo",
"vercel:envs": "vercel pull --yes --environment=preview",
"vercel:build": "vercel build",
"vercel:deploy": "vercel deploy --prebuilt"
}
}
The build is created in apps/web/.vercel/output, which is great, but when the vercel:deploy script runs, it appends the root directory again and so the Vercel CLI looks for the output in apps/web/apps/web which obviously doesn’t exist.
I’ve tried using the exact flow locally and it works without any issues, so why is the behavior different on CI/CD? I’ve made sure the versions are the same, and everything else I could possibly think of.
I also tried moving the vercel commands to run from the workspace root, but in that case, the build wouldn’t start unless I provided the --cwd apps/web flag which means I’m back to square one.
Error Output
Here’s an error message of the path doubling:
web:vercel:deploy
cache bypass, force executing 21e867016fb51699
> web@0.1.0 vercel:deploy /home/runner/work/X/X/apps/web
> vercel deploy --prebuilt --token=$VERCEL_TOKEN
Vercel CLI 50.14.0
Retrieving project…
Error: The provided path “~/work/X/X/apps/web/apps/web” does not exist. To change your Project Settings, go to https://vercel.com/X/X/settings
ELIFECYCLE Command failed with exit code 1.
Any help in this regard would be really appreciated. If there’s any additional info needed, please do let me know.