ropensci / unifir

A unifying interface for calling Unity from R
https://docs.ropensci.org/unifir/
Other
29 stars 0 forks source link

Issue finding Unity on MacOS and Windows #4

Closed wjones127 closed 2 years ago

wjones127 commented 2 years ago

Had issues finding Unity on MacOS. This is what I saw in my interactive session:

library(unifir)

options(unifir_unity_path="/Applications/Unity/Hub/Editor/2021.3.0f1/Unity.app/Contents/MacOS/Unity")
find_unity() # success on first call
# [1] "\"/Applications/Unity/Hub/Editor/2021.3.0f1/Unity.app/Contents/MacOS/Unity\""
find_unity() # failure on second call
# Error in find_unity() : Couldn't find Unity executable at provided path. 
# Please make sure the path provided to 'unity' is correct.
Sys.getenv("unifir_unity_path")
# [1] "\"/Applications/Unity/Hub/Editor/2021.3.0f1/Unity.app/Contents/MacOS/Unity\""

It works if I remove the logic that adds quotation marks to the path and add a beginning slash on this line:

https://github.com/mikemahoney218/unifir/blob/2e5f90cfc09b4456b3751f932f19da49e0dbebc7/R/find_unity.R#L86

On Windows, the windows_location() works fine, but file.exists(unity) always returns false with the extra " added to the path. I think this means even if the user profiles a different unity path, it will always select the default system one.

Relatedly, if I run the test locally on MacOS, I get this failure:

Failure (test-make_script.R:64:3): make_script always produces the same script
example_script$unity (`actual`) not identical to saved_script$unity (`expected`).

`actual`:   "junk_string"    
`expected`: "\"junk_string\""
mikemahoney218 commented 2 years ago

Gah! Thank you, will look into this today. Any chance you could post your sessionInfo()?

wjones127 commented 2 years ago

Sure!

R version 4.1.3 (2022-03-10)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.3.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] unifir_0.1.0

loaded via a namespace (and not attached):
[1] compiler_4.1.3        R6_2.5.1              tools_4.1.3           glue_1.6.2           
[5] proceduralnames_0.2.1
mikemahoney218 commented 2 years ago

Thanks! I made some changes in 128714fc524fd9244d2a9000d2429af3f81967f7 to hopefully address this (on the branch response_to_reviewers), though I haven't gotten to test them yet.

wjones127 commented 2 years ago

Great. I can confirm that branch fixes the issue for me. The unit tests pass and the Unity path is consistently found on MacOS.

mikemahoney218 commented 2 years ago

Fantastic, thanks!

github-actions[bot] commented 10 months ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.