vercel pull --yes --environment=app2 --token=$VERCEL_TOKEN
Vercel CLI 41.7.2
> Downloading `app2` Environment Variables for MYORG/MYPROJECT
Error: Invalid request: 'target' value of 'app2' references an environment that does not exist.
I also tried vercel pull --yes --environment=preview --git-branch=app2 --token=$VERCEL_TOKEN but that doesn’t give me the right variables.
I suppose the correct behaviour here is a file with all variables from my image. What I am missing here? Thanks
Hi @leonardofaria, can you share the purpose for pulling down the variables?
Because if it is for running your app locally than I think a better command for doing this is: vercel env pull --environment=app2.
But if you plan to use them for vercel build or vercel dev then yes vercel pull --yes --environment=app2 --token=$VERCEL_TOKEN is the correct one.
I tried these for my project and it worked as expected:
the first one generated a .env.local at the project root
the second one generate a .env.staging.local in the .vercel/ folder (staging is the name of my custom environment)
I would like to build app2 (branch app2) and production (branch main) in GHA.
As I mentioned before the pull command is not building several variables. For example I would expect 4 env variables starting with TYPESENSE and some starting with GOOGLE. Can you see them in your file pulled file?
I see. I think both commands worked for me. I tested by creating a custom environment called staging then added a few environment variables to my project: 1 to all environments, 1 to only staging, and 1 to all except staging. In this case, when I ran the commands I got the 2 environment variables added to the local file as expected.
Can you try recreating this scenario as I said? And maybe run it on your system so we can confirm quickly.
When I run vercel link it linked to pistachiosoftware/pistachioapp however the correct is pistachiosoftware/pistachio-app. Pull would always fail since the name of the project was wrong.
The solution was replying no in the Found project “pistachiosoftware/pistachio”. Link to it?. I was not expecting that because my vercel.json already had the teamId and projectId properly assigned.
vercel link
Vercel CLI 41.7.2
? Set up “~/Sites/pistachio”? yes
? Which scope should contain your project? Pistachio
? Found project “pistachiosoftware/pistachio”. Link to it? no
? Link to different existing project? yes
? What’s the name of your existing project? pistachio-app
Can you share the vercel.json file. Because, I think after linking the project Vercel CLI stores this info in .vercel/ directory, which might not be available because it’s excluded in source control.
Thanks @leonardofaria. It makes sense. As I said before, after linking the project Vercel CLI stores this info in .vercel/ directory, which might not be available because it’s excluded in source control.