Comments (6)
We've programmed some commands for that, but its not ideal and introduces more room for errors and intermediate states if something fails. A simple update flag would be the best way to handle it for our case.
from vercel.
While not ideal, you could remove the env variable vercel env rm
and then add the new value.
from vercel.
I also have the same problem... it would be great is there was a --yes
argument (that is also used on env pull
and env rm
to skip the confirmation/warning that the variable already exists.
from vercel.
I started looking into raising a PR to add this functionality and found that the Vercel API endpoint for create
does allow for overriding if the KEY already exists with an upsert
param.
There is also (for interest) another endpoint for "editing" an existing env var when it exists, but you need to know it's ID, not the envvar name/key (so you need to do a map first.
So it shouldn't be too much extra to change this in Vercel CLI.
from vercel.
What's interesting/strange/confusing is that when you attempt to vercel env add
with an existing key, the CLI error is:
Error: Another Environment Variable with the same Name and Environment exists in your project. Remove it or choose a different Name or Environment.
Yet, I can't find this error message in the CLI codebase (this project), I thought maybe the API is returning this error, yet trying to create a new envar Key that already exists returns the following error from the API (https://api.vercel.com/v10/projects/${projectID}/env):
{
"error": {
"code": "ENV_CONFLICT",
"message": "A variable with the name `API_URL` and target `preview` already exists",
"key": "key",
"envVarKey": "API_URL"
},
"failed": [
{
"error": {
"code": "ENV_CONFLICT",
"message": "A variable with the name `API_URL` and target `preview` already exists",
"key": "key",
"envVarKey": "API_URL"
}
}
]
}
I'll keep digging to see where the CLI's error is coming from (could be using an older endpoint)...
Update
Endpoint v9 is returning the error below when trying to set an existing env Key. v9 also doesn't allow the "upsert" para... so CLI will need updating to use v10 of this endpoint.
{
"error": {
"code": "ENV_ALREADY_EXISTS",
"message": "Another Environment Variable with the same Name and Environment exists in your project. Remove it or choose a different Name or Environment.",
"key": "API_URL",
"configurationId": null,
"target": [
"preview"
]
}
}
Update 2
CLI is using v8:
const url = /v8/projects/${projectId}/env
;
from vercel.
Awesome work!
from vercel.
Related Issues (20)
- X-Vercel-IP-Country returning wrong country
- create a support case is disabled HOT 1
- [Deploy Button] integration installed callback is stuck HOT 1
- Issue Deploying Nuxt 2 App: Cannot find module 'vercel__launcher.launcher' HOT 7
- Latest NextJs build error HOT 1
- getInstalledPackageVersion is not a function HOT 3
- [email protected]
- Attempting to build locally with pnpm install does not work
- Error when adding new domain to the project
- [vc dev] `tsconfig.json` setting `verbatimModuleSyntax` and `module: preserve` not allowed
- Function runtime error: Cannot find module HOT 2
- vercel dev not working HOT 2
- Latest version of cli is pulling in insecure packages that have available patches
- Python runtime does not work on Python 3.12 with ASGI HOT 10
- [34.1.8] `vercel build` Error: Cannot read properties of null (reading 'trim') HOT 5
- Automatic updates for Go releases
- Bug: Parallel intercepted route in Next.js
- Regression: `vercel build` fails with pnpm v9.1.x on latest Vercel CLI HOT 9
- Console Logs Merging into a Single Message in Dashboard when Using ESModules
- [cli] Removing VERCEL_ENV in [email protected] is a breaking change HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vercel.