Yarn: save-prefix config can't be deleted, an empty string changes to a weird `true` value

Created on 7 Feb 2017  Â·  13Comments  Â·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?

A bug.

What is the current behavior?

yarn config can't delete the save-prefix setting and setting it to an empty string changes the value to true. Subsequent yarn add package invocations save the 'true' prefix which is definitely not what I'd expect.

If the current behavior is a bug, please provide the steps to reproduce.

$ yarn config get save-prefix
^
$ yarn config delete save-prefix
$ yarn config get save-prefix   
^
$ yarn config set save-prefix ''
$ yarn config get save-prefix
true
$ yarn add jquery
$ cat package.json 
{
  "dependencies": {
    "jquery": "true3.1.1"
  }
}

What is the expected behavior?

  1. yarn config delete save-prefix should delete the prefix or reset it to an empty string
  2. yarn config set save-prefix '' should set save-prefix to an empty string, not true. A boolean value for this setting should either be forbidden or should not be stringified when saving a package version range to package.json.

Please mention your node.js, yarn and operating system version.
Node 6.9.5 or 7.5.0, macOS 10.12.3 (16D32), yarn 0.20.0.

needs-repro-script

Most helpful comment

I just removed save prefix by editing .yarnrc manually

Append this line to the end of .yarnrc. It should be located at home directory.

save-prefix ""

Result:

âž” yarn add typescript                  
yarn add v0.21.3
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
└─ [email protected]
Done in 2.31s.

âž” cat package.json 
{
  "devDependencies": {
    "webpack": "^2.3.2",
    "webpack-dev-server": "^2.4.2"
  },
  "dependencies": {
    "localforage": "^1.5.0",
    "localforage-memoryStorageDriver": "^0.9.2",
    "tslib": "^1.6.0",
    "typescript": "2.2.2"
  }
}

Before a fix is deployed, we can use this as a temporary solution.


I believe this bug is caused by this line.

All 13 comments

Can confirm the same behavior on Windows 10 using Yarn 0.19.1

I have the same issue.
Windows 10, Node v6.9.1, Yarn v0.21.3.
I've tried the following:

yarn config set save-prefix           -> true
yarn config set save-prefix ""        -> true
yarn config set save-prefix ''        -> "''"
yarn config set save-prefix false     -> 'false'
yarn config set save-prefix 0         -> '0'
yarn config set save-prefix null      -> 'null'
yarn config set save-prefix undefined -> 'undefined'

Same here. This seems to make it basically impossible to save without a prefix...

I just removed save prefix by editing .yarnrc manually

Append this line to the end of .yarnrc. It should be located at home directory.

save-prefix ""

Result:

âž” yarn add typescript                  
yarn add v0.21.3
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
└─ [email protected]
Done in 2.31s.

âž” cat package.json 
{
  "devDependencies": {
    "webpack": "^2.3.2",
    "webpack-dev-server": "^2.4.2"
  },
  "dependencies": {
    "localforage": "^1.5.0",
    "localforage-memoryStorageDriver": "^0.9.2",
    "tslib": "^1.6.0",
    "typescript": "2.2.2"
  }
}

Before a fix is deployed, we can use this as a temporary solution.


I believe this bug is caused by this line.

there seems to be a way, as mentioned in #1088:

yarn config set save-prefix false

We should at least be able to replace this setting with an empty string so prioritizing for 1.0.

I can't replicate this behavior, can you confirm? When I run yarn config set save-prefix '' it sets it to an empty string.

Empty string seems to work OK for me on OSX v0.27.5

$ yarn config set save-prefix '~'
yarn config v0.27.5
success Set "save-prefix" to "~".
Done in 0.02s.

$ more ~/.yarnrc
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


lastUpdateCheck 1502213071825
save-prefix "~"

$ yarn config set save-prefix ''
yarn config v0.27.5
success Set "save-prefix" to "".
Done in 0.02s.

$ more ~/.yarnrc
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


lastUpdateCheck 1502213071825
save-prefix ""

$ yarn config delete save-prefix
yarn config v0.27.5
success Deleted "save-prefix".
Done in 0.02s.

$ more ~/.yarnrc
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


lastUpdateCheck 1502213071825

Yay, thanks @rally25rs!

Closing this then?

This does seem to work fine for me with Yarn 0.27.5.

It seems it's been fixed in the meantime, that's great! I'm closing the issue then.

I didn't know two people can close the issue simultaneously. :)

Looks like you beat me to it.

It's actually showing both of us having closed the ticket. Sounds like a bug in GitHub!

Well, nevermind. :) I'm glad the issue is gone.

Was this page helpful?
0 / 5 - 0 ratings