Skip to content

Conversation

@DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Nov 12, 2025

Closes #7760

This is what caused both arrange() and group_by() |> summarise() to fall back to the old system-locale ordering, rather than using the new C locale approach and requiring arrange(.locale =) instead.

It was always meant to be a temporary global option that people could slap at the top of their scripts if they just didn't want to deal with it right now.

Comment on lines 79 to 94
# This deprecation is a bit special. Since it is a global option that only the
# end user would ever set, we set `user_env = globalenv()` so that it always
# looks like a "direct" usage to lifecycle. This also makes our lives easier,
# because `user_env` would have to be threaded all the way up through the
# exported `grouped_df()` function, which is then used in many places
# throughout dplyr. Additionally, we've bypassed `deprecate_soft()` and gone
# straight to `deprecate_warn()` since this is only an end user facing option.
lifecycle::deprecate_warn(
when = "1.2.0",
what = I("`options(dplyr.legacy_locale =)`"),
details = c(
i = "If needed for `arrange()`, use `arrange(.locale =)` instead.",
i = "If needed for `group_by() |> summarise()`, follow up with an additional `arrange(.locale =)` call."
),
user_env = globalenv()
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most important paragraph to read, because this deprecation process is very special since it is a global option that is only used by end users:

  • We force user_env = globalenv() to make usage always look "direct" to lifecycle (because an end user "directly" set the global option)
  • We start with once per session deprecate_warn() rather than deprecate_soft() (that wouldn't really mean much anyways since user_env = globalenv())

I started off with deprecate_soft() and tried to thread user_env up the stack, but it's quite a nightmare. It gets pushed up through grouped_df() which is used all over the place, way more than just group_by().

Instead, this seems like a much saner option, especially since it is a global option that should only ever be set by end users anyway (a quick glance at the cran github org confirms that no R package is setting this for users).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://github.com/search?q=org%3Acran%20dplyr.legacy_locale&type=code, this is only going to affect user code, not CRAN packages, so this behaviour sounds reasonable to me.

@DavisVaughan DavisVaughan requested a review from hadley November 12, 2025 23:04
Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only request is to be a bit more concrete about exactly what you need to do to restore legacy behaviour.

Comment on lines 79 to 94
# This deprecation is a bit special. Since it is a global option that only the
# end user would ever set, we set `user_env = globalenv()` so that it always
# looks like a "direct" usage to lifecycle. This also makes our lives easier,
# because `user_env` would have to be threaded all the way up through the
# exported `grouped_df()` function, which is then used in many places
# throughout dplyr. Additionally, we've bypassed `deprecate_soft()` and gone
# straight to `deprecate_warn()` since this is only an end user facing option.
lifecycle::deprecate_warn(
when = "1.2.0",
what = I("`options(dplyr.legacy_locale =)`"),
details = c(
i = "If needed for `arrange()`, use `arrange(.locale =)` instead.",
i = "If needed for `group_by() |> summarise()`, follow up with an additional `arrange(.locale =)` call."
),
user_env = globalenv()
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://github.com/search?q=org%3Acran%20dplyr.legacy_locale&type=code, this is only going to affect user code, not CRAN packages, so this behaviour sounds reasonable to me.

@DavisVaughan DavisVaughan merged commit 90f10c3 into main Nov 14, 2025
14 checks passed
@DavisVaughan DavisVaughan deleted the feature/soft-dep-locale branch November 14, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Soft deprecate dplyr.legacy_locale global option usage

3 participants