-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug?]: yarn config get / unset
throws Usage Error when a setting isn't in the config
#5479
Comments
On the other hand, it's generally seen a good practice in Bash to enable |
I guess, to me, unsetting and getting configuration props that don't exist on the cli doesn't come with it the same downsides / repercussions that attempting to reference a variable that doesn't exist in a script might have (especially in the CI/CD pipeline use case). And in our case, which is probably not the norm, our build servers are Windows agents running Powershell tasks. It just doesn't feel like getting a config prop that hasn't been set is an erroneous action. Otherwise, how would you check if the config has any property that you might want to change template behavior for in a cli context? |
I guess something like this? A little verbose, and perhaps the if yarn config get someSetting > /dev/null; then
yarn config set someSetting hello-world
fi Alternatively, I'd probably be fine to have a |
Right on. Yeah, there are definitely more verbose workarounds; so it's not a blocker. It just seems like there should be a built-in way to relax that call so it's not throwing errors if the presence of the prop is uncertain (like in the case of large-scale pipelines servicing several projects with varying configs). |
Hi! 👋 It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it. |
@arcanis should this stay open based on your recommendation (some kind of tolerate option)? |
Hi! 👋 It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it. |
|
It's not my priority and it seems "easy", so if someone wants to implement it that's fine by me - but if noone does for three+ months, it seems reasonable to let it close. |
Fair enough. I'd like to help with this, but just haven't had the time. If it closes, and i do get a chance to learn the codebase enough to help with this at some point, is there a way to re-open it? |
Hi! 👋 It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it. |
Self-service
Describe the bug
Whenever you use the
yarn config unset <settingName>
oryarn config get <settingName>
command, with a setting name that isn't present in the config, it throws aUsage Error: Couldn't find a configuration settings named <settingName>
. This can be problematic when used in a CI/CD context. For example, we have reusable pipeline templates that service multiple projects. Some of those projects use theafterInstall
plugin and so those config files haveafterInstall
settings applied. When bumping versions in our pipeline, we don't want theafterInstall
scripts to run. So we have code that unsets the afterInstall setting and re-sets it at the end of the stage. Blindly unsetting that property would be ideal, but since that throws an Error, I tried using theconfig get
command to see if that setting is present before unsetting, but even that throws an error.It seems like the behavior for both calls should be a no-op. CLI's like
git
will just return an empty string if you try and get a config prop that isn't there. It doesn't error out (e.g.git config --get user.phone
). Similarly, if you're trying to unset a prop that isn't there, I would expect it to just do nothing, not throw an error.I wasn't sure if this should be considered a Bug or an Enhancement, so if it needs to be re-labled/re-titled, that's totally cool.
To reproduce
Run
yarn config unset afterInstall
oryarn config get afterInstall
on a project that doesn't haveafterInstall
set.Environment
Additional context
The text was updated successfully, but these errors were encountered: