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
Yarn save-prefix option changed/ignored #4343
Comments
I cannot replicate this on latest master. What I tried:
Checked |
@BYK if I run the following commands:
this is what Yarn adds to package.json:
This is certainly a bug. Please mention your node.js, yarn and operating system version. |
Hi @BYK, Below is a (bash) script to demonstrate. Please note that the script assumes the existence of a git repo with no changes. I've included the output for the relevant commands. $ yarn config set save-prefix false
$ yarn add --dev rollup-plugin-uglify
$ cat package.json | grep rollup-plugin-uglify
"rollup-plugin-uglify": "false2.0.1",
$ git checkout .
$ yarn config set save-prefix ''
$ yarn add --dev rollup-plugin-uglify
$ cat package.json | grep rollup-plugin-uglify
"rollup-plugin-uglify": "^2.0.1",
$ git checkout . |
For good measure, here is the output of my config, with the registry token scrubbed. $ yarn config list
yarn config v1.0.1
info yarn config
{ 'version-tag-prefix': 'v',
'version-git-tag': true,
'version-git-sign': false,
'version-git-message': 'v%s',
'init-version': '0.0.1',
'init-license': 'BSD-2-Clause',
'save-prefix': '',
'ignore-scripts': false,
'ignore-optional': false,
registry: 'https://registry.yarnpkg.com',
'strict-ssl': true,
'user-agent': 'yarn/1.0.1 npm/? node/v6.11.2 darwin x64',
lastUpdateCheck: 1504807978160 }
info npm config
{ 'init-author-name': 'Andrew Pinkham',
'init-author-url': 'https://www.jambonsw.com/',
'init-license': 'BSD-2-Clause',
'init-version': '0.0.1',
'save-exact': true,
'save-prefix': '' }
✨ Done in 0.13s. |
I think this is due to a quirk in bash or how we use config. If you go ahead and set this manually in the I think passing an empty string with bash as the last argument is pretty quirky so I'll see what I can do. |
What are you setting in
|
This one. That said it looks correct. That's very weird. I can't reproduce this with the config you provide using Yarn 1.0.1 :( |
What other information can I provide to try and track this down? I am going to install from master to see if perhaps that's the difference. |
@jambonrose so here's what happens to me, with that
|
Can there be another |
Adding the |
Sorry if I've misunderstood, but is that first case you're seeing not a bug? Should the |
To clarify, the behavior I'm expecting is, when
Instead your |
I confirm that I am seeing this behavior with a build from I've tried adding the |
The problem stems from line 89 of // src/cli/commands/add.js
let prefix;
if (tilde) {
prefix = '~';
} else if (exact) {
prefix = '';
} else {
prefix = String(this.config.getOption('save-prefix')) || '^';
} Rather than trying to add logic around By having this option, the logic above could become something like: // src/cli/commands/add.js
let prefix;
if (tilde) {
prefix = '~';
} else if (exact || Boolean(this.config.getOption('save-exact'))) {
prefix = '';
} else {
prefix = String(this.config.getOption('save-prefix')) || '^';
} Feedback welcome. |
@jambonrose Yarn actually respects Are you up for a PR? |
**Summary** Fixes #4343. Currently there is no way to remove the package prefix inside `.yarnrc` file, this PR add support for `save-exact` in `.yarnrc` as discussed in #4343. Full credit goes to @jambonrose ``` save-exact true ``` One small thing, should `yarn` be backwards compatible with the old behavior which is `save-prefix ''`? We can just add an extra check here for do this. What do you think @BYK? ```js } else if (exact || Boolean(this.config.getOption('save-exact')) || Boolean(this.config.getOption('save-prefix'))) { ``` **Test plan** New unit test.
I was coming back around for this, but it looks like @ahmedelgabri got to it before me. Nice work! |
**Summary** Fixes yarnpkg#4343. Currently there is no way to remove the package prefix inside `.yarnrc` file, this PR add support for `save-exact` in `.yarnrc` as discussed in yarnpkg#4343. Full credit goes to @jambonrose ``` save-exact true ``` One small thing, should `yarn` be backwards compatible with the old behavior which is `save-prefix ''`? We can just add an extra check here for do this. What do you think @BYK? ```js } else if (exact || Boolean(this.config.getOption('save-exact')) || Boolean(this.config.getOption('save-prefix'))) { ``` **Test plan** New unit test.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I've just upgraded from v0.20.3 to v1.0.1. The behavior described by @meznaric in #3045 was what I was previously seeing.
When I run
yarn config set save-prefix false
(the previous recommendation, as noted in #3045), installed packages now have the stringfalse
placed in front of the version. For instance, when I runyarn add --dev rollup-plugin-uglify
, this is what Yarn adds to mypackage.json
.If I run
yarn config set save-prefix ''
to try and remove the prefix, the option is ignored. Below is the string Yarn adds topackage.json
when I run the same command as above with the new config.Note that Yarn lists my NPM config as having the same options (as shown by
yarn config list
).Yarn config excerpt:
NPM config excerpt:
I have no idea if I am the problem here, as I cannot find any documentation about this setting.
This is related to #1088 and #3320.
What is the expected behavior?
I should be able to configure Yarn such that the versions of packages being added are exact (unless there is a good reason I should not be doing this? - if so, a warning is in order).
Please mention your node.js, yarn and operating system version.
Node v6.11.2
Yarn v1.0.1
macOS 10.11
The text was updated successfully, but these errors were encountered: