-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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] package.json and package-lock.json order is different when used Czech locale #2829
Labels
Bug
thing that needs fixing
Priority 2
secondary priority issue
Release 7.x
work is associated with a specific npm 7 release
Comments
jakubjosef
added
Bug
thing that needs fixing
Needs Triage
needs review for next steps
Release 7.x
work is associated with a specific npm 7 release
labels
Mar 5, 2021
darcyclarke
added
Priority 2
secondary priority issue
and removed
Needs Triage
needs review for next steps
labels
Apr 9, 2021
same in Windows 10 with Slovak language, node v14.16.1, npm v7.11.2 |
This was referenced May 5, 2021
I make pull requests to fix this npm/arborist#276 will fix sorting in so this 2 packeses will need to be updated to fix this |
Thank you @padinko! |
isaacs
added a commit
to npm/arborist
that referenced
this issue
May 6, 2021
Node will use the current environment's locale sorting for String.localeCompare. Thankfully, String.localeCompare can take a second argument to specify the locale. Up until Node 13, any valid argument provided to the function _may_ be respected if Node was compiled with Intl support, or would always be treated as `'en'` otherwise. The solution is to always set the locale to `'en'`. An alternative solution would be to compare strings based on byte order, but this does not provide ideal ergonomis. To verify this, the locale is set in the test environment to `'sk'`, which has a significantly different alphabet, including sorting words starting with `'ch'` _after_ words starting with `'d'`. Re: npm/cli#2829 Fix: #276
isaacs
added a commit
to isaacs/node-glob
that referenced
this issue
May 6, 2021
isaacs
added a commit
to npm/ignore-walk
that referenced
this issue
May 6, 2021
isaacs
added a commit
to npm/libnpmexec
that referenced
this issue
May 6, 2021
No test added, since there's nothing in this module that particularly depends on string sorting, but it's a best practice all the same. Re: npm/cli#2829
isaacs
added a commit
to npm/npm-packlist
that referenced
this issue
May 6, 2021
Force all uses of String.localeCompare to use the 'en' locale. Re: npm/cli#2829
isaacs
added a commit
that referenced
this issue
May 6, 2021
This adds the 'en' locale to all instances of String.localeCompare within the CLI codebase. Tests added for the cases where we're sorting arbitrary user-generated data. The tests rely on the fact that 'ch' sorts after 'd' in the `'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that this is the default behavior if no locale is specified, `LC_ALL=sk` is set in the test environment. Other instances of `localeCompare` sort data that the cli controls, so no tests were added. Re: #2829
isaacs
added a commit
to npm/arborist
that referenced
this issue
May 6, 2021
Node will use the current environment's locale sorting for String.localeCompare. Thankfully, String.localeCompare can take a second argument to specify the locale. Up until Node 13, any valid argument provided to the function _may_ be respected if Node was compiled with Intl support, or would always be treated as `'en'` otherwise. The solution is to always set the locale to `'en'`. An alternative solution would be to compare strings based on byte order, but this does not provide ideal ergonomis. To verify this, the locale is set in the test environment to `'sk'`, which has a significantly different alphabet, including sorting words starting with `'ch'` _after_ words starting with `'d'`. Re: npm/cli#2829 Fix: #276
isaacs
added a commit
to npm/arborist
that referenced
this issue
May 7, 2021
Node will use the current environment's locale sorting for String.localeCompare. Thankfully, String.localeCompare can take a second argument to specify the locale. Up until Node 13, any valid argument provided to the function _may_ be respected if Node was compiled with Intl support, or would always be treated as `'en'` otherwise. The solution is to always set the locale to `'en'`. An alternative solution would be to compare strings based on byte order, but this does not provide ideal ergonomis. To verify this, the locale is set in the test environment to `'sk'`, which has a significantly different alphabet, including sorting words starting with `'ch'` _after_ words starting with `'d'`. Re: npm/cli#2829 Fix: #276
isaacs
added a commit
that referenced
this issue
May 7, 2021
This adds the 'en' locale to all instances of String.localeCompare within the CLI codebase. Tests added for the cases where we're sorting arbitrary user-generated data. The tests rely on the fact that 'ch' sorts after 'd' in the `'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that this is the default behavior if no locale is specified, `LC_ALL=sk` is set in the test environment. Other instances of `localeCompare` sort data that the cli controls, so no tests were added. Re: #2829
isaacs
added a commit
that referenced
this issue
May 7, 2021
This adds the 'en' locale to all instances of String.localeCompare within the CLI codebase. Tests added for the cases where we're sorting arbitrary user-generated data. The tests rely on the fact that 'ch' sorts after 'd' in the `'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that this is the default behavior if no locale is specified, `LC_ALL=sk` is set in the test environment. Other instances of `localeCompare` sort data that the cli controls, so no tests were added. Re: #2829
isaacs
added a commit
that referenced
this issue
May 10, 2021
This adds the 'en' locale to all instances of String.localeCompare within the CLI codebase. Tests added for the cases where we're sorting arbitrary user-generated data. The tests rely on the fact that 'ch' sorts after 'd' in the `'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that this is the default behavior if no locale is specified, `LC_ALL=sk` is set in the test environment. Other instances of `localeCompare` sort data that the cli controls, so no tests were added. Re: #2829
isaacs
added a commit
that referenced
this issue
May 10, 2021
This adds the 'en' locale to all instances of String.localeCompare within the CLI codebase. Tests added for the cases where we're sorting arbitrary user-generated data. The tests rely on the fact that 'ch' sorts after 'd' in the `'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that this is the default behavior if no locale is specified, `LC_ALL=sk` is set in the test environment. Other instances of `localeCompare` sort data that the cli controls, so no tests were added. Re: #2829
wraithgar
pushed a commit
to npm/libnpmexec
that referenced
this issue
May 10, 2021
No test added, since there's nothing in this module that particularly depends on string sorting, but it's a best practice all the same. Re: npm/cli#2829
isaacs
added a commit
to npm/arborist
that referenced
this issue
May 10, 2021
Node will use the current environment's locale sorting for String.localeCompare. Thankfully, String.localeCompare can take a second argument to specify the locale. Up until Node 13, any valid argument provided to the function _may_ be respected if Node was compiled with Intl support, or would always be treated as `'en'` otherwise. The solution is to always set the locale to `'en'`. An alternative solution would be to compare strings based on byte order, but this does not provide ideal ergonomis. To verify this, the locale is set in the test environment to `'sk'`, which has a significantly different alphabet, including sorting words starting with `'ch'` _after_ words starting with `'d'`. Re: npm/cli#2829 Fix: #276
isaacs
added a commit
to npm/arborist
that referenced
this issue
May 10, 2021
Node will use the current environment's locale sorting for String.localeCompare. Thankfully, String.localeCompare can take a second argument to specify the locale. Up until Node 13, any valid argument provided to the function _may_ be respected if Node was compiled with Intl support, or would always be treated as `'en'` otherwise. The solution is to always set the locale to `'en'`. An alternative solution would be to compare strings based on byte order, but this does not provide ideal ergonomis. To verify this, the locale is set in the test environment to `'sk'`, which has a significantly different alphabet, including sorting words starting with `'ch'` _after_ words starting with `'d'`. Re: npm/cli#2829 Fix: #276
isaacs
added a commit
that referenced
this issue
May 10, 2021
This adds the 'en' locale to all instances of String.localeCompare within the CLI codebase. Tests added for the cases where we're sorting arbitrary user-generated data. The tests rely on the fact that 'ch' sorts after 'd' in the `'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that this is the default behavior if no locale is specified, `LC_ALL=sk` is set in the test environment. Other instances of `localeCompare` sort data that the cli controls, so no tests were added. Re: #2829
wraithgar
pushed a commit
to npm/arborist
that referenced
this issue
May 10, 2021
Node will use the current environment's locale sorting for String.localeCompare. Thankfully, String.localeCompare can take a second argument to specify the locale. Up until Node 13, any valid argument provided to the function _may_ be respected if Node was compiled with Intl support, or would always be treated as `'en'` otherwise. The solution is to always set the locale to `'en'`. An alternative solution would be to compare strings based on byte order, but this does not provide ideal ergonomis. To verify this, the locale is set in the test environment to `'sk'`, which has a significantly different alphabet, including sorting words starting with `'ch'` _after_ words starting with `'d'`. Re: npm/cli#2829 Fix: #276
wraithgar
pushed a commit
that referenced
this issue
May 10, 2021
This adds the 'en' locale to all instances of String.localeCompare within the CLI codebase. Tests added for the cases where we're sorting arbitrary user-generated data. The tests rely on the fact that 'ch' sorts after 'd' in the `'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that this is the default behavior if no locale is specified, `LC_ALL=sk` is set in the test environment. Other instances of `localeCompare` sort data that the cli controls, so no tests were added. Re: #2829 PR-URL: #3203 Credit: @isaacs Close: #3203 Reviewed-by: @ruyadorno
I can confirm this is now fixed in NPM. Thank you, closing this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug
thing that needs fixing
Priority 2
secondary priority issue
Release 7.x
work is associated with a specific npm 7 release
Current Behavior:
package-lock and package.json order is different when used non English (Czech) locale
Expected Behavior:
Sorting should be locale-agnostic to not change package-lock JSON back and forth.
Steps To Reproduce:
ch
in name (eg. chai)Environment:
It looks like similar problem as it's reported here
npm/npm#17048
I think the root cause is different order of letters. In Czech alphabet
CH
letter stands afterH
, but in English alphabet it's justC
.Example in package.json (left is Czech locale, right is English)
Workaround
If someone is facing the same issue in can be fixed by defining alias
alias npm='LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8" npm'
in bash_profile/.zshrc or similar file depends to shell you are using.The text was updated successfully, but these errors were encountered: