-
Notifications
You must be signed in to change notification settings - Fork 20
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
locale problem in qgis_query_algorithms()
#218
Comments
Very interesting, thanks for the investigations Jannes. 👍 to the suggested solution. |
Thanks for bringing this up and for pursuing this @jannes-m! From #176 (comment), it seems that this might also be tied to the missing Very interesting that you could get it working by adjusting the locale. However it returns malformed characters in your example. In the referred issue, it seemed that the JSON string malformation was linked to the environment variable. If that is something that can be linked to |
Thanks for your thoughts @florisvdh! Setting the The malformed characters only appear in the reprex but not if you run the example interactively. Overall, |
OK, thanks for clarifying @jannes-m. I believe in most local platforms you won't have that the locale is C, but maybe it's standard in docker images. And then indeed:
I think it would be fine to implement that in a conditional manner: check if the locale is C (or some other case that we know causes the problem) and if so, only then change the locale for the duration of the function call. What do you think? |
I absolutely agree, I'll draft a PR and of course I'll let you know -:) |
BTW in jeroen/jsonlite#338 (comment) I read that JSON is always UTF-8 by definition. {qgisprocess} relies on JSON. So it might also make sense to adjust the locale of the container instead. Addressing the problem in non UTF-8 locales would potentially apply to any package relying on JSON strings. But I would definitely welcome your PR! |
mmh, you are right, I'll think about it |
Looks like this could do it in the Dockerfile?
|
It seems there has been some discussion in Rocker about this in the past as well (which you rely on). rocker-org/rocker#19 |
Wow, what a thread! Many thanks for finding and sharing that. A solution for RStudio aligns with my suggestion: https://github.com/rstudio/r-docker/pull/18/files So let's build on that, do you want to give that a go and see if that fixes it Jannes? |
Closed by PR #219. |
Great work! New release in order I imagine. Many thanks 🙏 |
@jannes-m @Robinlovelace Do you need to have the fix on CRAN to get this fixed on your side or do you use qgisprocess from github/r-universe ? In the latter case, I'd want to wait with CRAN release in order to investigate |
@florisvdh yes please as it's not in remotes: https://github.com/geocompx/geocompkg/blob/e6c5d110632fbdaf150f27ba667ea2e460308409/DESCRIPTION#L81 |
OK, expect a CRAN release with this fix quite soon, then 🙂 |
@Robinlovelace of course you are right that we do not use remotes. However, I would say, we could wait a few weeks for the fix since the problem only ocurrs when running the container in a bash session. And I assume there are not so many people using this option. I might be wrong but at least nobody aside from Robin reported this bug. But of course, I am also happy if you publish a new CRAN release right now. |
Let's go with CRAN now, unless any downside. Will make testing a bit easier and the image has a surprisingly large n. downloads for something that is temporarily broken. |
FYI CRAN submission is pending since a couple of days, after replying about a supposedly false positive; PR #222. |
Many thanks 🙏 |
Finally the third attempt made it to CRAN (while releasing this feature should have been a no-brainer). See #222 for more on this. |
Epic! Hopefully will be easier next time 🙏 |
Thanks a lot for your efforts 🙏 |
Things to check beforehand
Are QGIS plugins the cause?
The problem remains with all plugins disabled.
Description of the observed problem
Hey @florisvdh,
I finally had some time to address geocompx/docker#52.
When running our image in a bash session (
docker run -it --rm ghcr.io/geocompx/docker:qgis R
),library(qgisprocess)
fails.I tracked down the error to
jsonlite::fromJSON()
called inqgisprocess::qgis_query_algorithms()
.This is a locale problem and can be solved by setting the locale (see below).
Not setting the encoding argument in
result = qgisprocess:::qgis_run(args = c("list", "--json"), encoding = "UTF-8")
run inqgis_query_algorithms()
would also work but that might cause unwanted side effects, I guess.Hence, I wonder if we should set the locale in
qgisprocess::qgis_query_algorithms()
and restore the original values on exit?@Robinlovelace the qgis container works just fine when run in the browser in an rstudio session because the rstudio session already uses
en_US.UTF-8
.Created on 2024-09-04 with reprex v2.1.0
~
QGIS version
3.36.2
R session info
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
locale:
[1] C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] qgisprocess_0.3.0.9000
loaded via a namespace (and not attached):
[1] vctrs_0.6.5 cli_3.6.2 knitr_1.46 rlang_1.1.3
[5] xfun_0.43 stringi_1.8.3 processx_3.8.4 assertthat_0.2.1
[9] jsonlite_1.8.8 glue_1.7.0 clipr_0.8.0 htmltools_0.5.8.1
[13] ps_1.7.6 rappdirs_0.3.3 fansi_1.0.6 rmarkdown_2.26
[17] evaluate_0.23 tibble_3.2.1 fastmap_1.1.1 yaml_2.3.8
[21] lifecycle_1.0.4 stringr_1.5.1 compiler_4.4.0 fs_1.6.4
[25] pkgconfig_2.0.3 rstudioapi_0.16.0 digest_0.6.35 R6_2.5.1
[29] reprex_2.1.0 utf8_1.2.4 pillar_1.9.0 callr_3.7.6
[33] magrittr_2.0.3 tools_4.4.0 withr_3.0.0
Additional context
No response
The text was updated successfully, but these errors were encountered: