Skip to content

Commit 9b62d76

Browse files
authored
Fix 177 (Requal crashing on Windows 11) (#178)
* fix #177 - Use powershell instead of wmic --------- Co-authored-by: hlageek <[email protected]>
1 parent b36e6e3 commit 9b62d76

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: requal
22
Title: Shiny Application for Computer-Assisted Qualitative Data Analysis
3-
Version: 1.2.4.9006
3+
Version: 1.2.4.9007
44
Authors@R:
55
c(
66
person(given = "Radim",

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- default document encoding is now processed explicitly
2626
- other minor fixes
2727
- selecting segments on smartphones/tablets and by combination of mouse and keyboard now works
28+
- Requal crashing on Windows 11 due to missing wmic utility
2829

2930
# requal 1.1.3 Rieppeleon
3031

R/utils.R

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,46 @@ get_volume_paths <- function() {
193193
names(volumes_checked) <- volumes_checked
194194
volumes_checked
195195
} else if (tolower(sysinfo["sysname"]) == "windows") {
196-
volumes_string <- system("wmic logicaldisk get caption", intern = TRUE)
197-
volumes <- unlist(stringr::str_extract_all(volumes_string, "[A-Z]\\:"))
198-
volumes_checked <- volumes[fs::file_access(volumes)]
199-
names(volumes_checked) <- volumes_checked
200-
volumes_checked
196+
# For Windows 11, first try PowerShell
197+
tryCatch(
198+
{
199+
volumes_string <- system(
200+
"powershell -Command \"Get-PSDrive -PSProvider FileSystem | Select-Object -ExpandProperty Name\"",
201+
intern = TRUE
202+
)
203+
volumes <- paste0(volumes_string[nzchar(volumes_string)], ":")
204+
volumes_checked <- volumes[fs::file_access(volumes)]
205+
names(volumes_checked) <- volumes_checked
206+
volumes_checked
207+
},
208+
error = function(e) {
209+
# Fallback: try wmic
210+
tryCatch(
211+
{
212+
volumes_string <- system(
213+
"wmic logicaldisk get caption",
214+
intern = TRUE
215+
)
216+
volumes <- unlist(stringr::str_extract_all(
217+
volumes_string,
218+
"[A-Z]\\:"
219+
))
220+
volumes_checked <- volumes[fs::file_access(volumes)]
221+
names(volumes_checked) <- volumes_checked
222+
volumes_checked
223+
},
224+
error = function(e2) {
225+
# Last resort: check common drive letters
226+
potential_volumes <- paste0(LETTERS[3:26], ":") # C: through Z:
227+
volumes_checked <- potential_volumes[fs::file_access(
228+
potential_volumes
229+
)]
230+
names(volumes_checked) <- volumes_checked
231+
volumes_checked
232+
}
233+
)
234+
}
235+
)
201236
} else {
202237
c(Volumes = fs::path_home())
203238
}

0 commit comments

Comments
 (0)