-
Notifications
You must be signed in to change notification settings - Fork 49
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
Module not found when running on shiny 1.6.0 #237
Comments
Try box::use(../module) |
Thanks for the great reprex! The reason this fails is that, in Shiny server, the result of I’m honestly a bit at a loss at this behaviour of Shiny Server, and I’m wondering whether it might be a bug. As far as I know, ‘box’ might be the only package that’s using |
Ah, I completely misdiagnosed the issue …: |
More complications: the behaviour of |
Could you please try the candidate hotfix by downloading the .tar.gz attached in the linked PR, or by executing install.packages(
'https://github.com/klmr/box/files/7117820/box_1.0.2.9000-shiny-hotfix.tar.gz',
repos = NULL, type = 'source'
) I think this fixes it (it does in my local testing, but confirmation from your specific use-case would be nice, since the fix is kind of a hack). Unfortunately the fix is also somewhat inefficient since it needs to inspect the call stack for each import when Shiny is loaded. Ideally the previous value of |
This works now, also with my actual app 🎉 Yet, maybe a naive question: |
No,
With
This’ll fail because And that, in a nutshell, is why ‘box’ needs to figure out whether it’s being called from inside Shiny (as well as a few other special cases): because it needs to figure out how to find relative imports outside of a module. Resolving them relative to the current working directory is generally not sufficient. Consider a script which is invoked as $ pwd
/some/path
$ Rscript some/other/path/to/script.r now the script itself isn’t inside the working directory (which is In fact, the reason why Shiny (as well as e.g. ‘knitr’) sets the working directory in the first place is probably to make |
Ah, I see now! Thanks for the extensive explanation! Feel free to close the issue from my side. |
Sorry, it's me again with another edge case!
I have this minimal shiny app loading a module located in the same directory:
app.R
When I run the app from the command-line, like this, everything works as expected (I navigated to http://localhost:3838 and see an empty page)
Rscript -e "shiny::runApp('app', port=3838)"
However, when I place the app in the apps directory of a shiny server installation and open the app in the browser, it fails with the following error message:
Evidently, it can't find the
module.R
. Interestingly, sourcing the file with a relative path appears to work without issues.Full repex
(using the rocker/shiny docker container)
Once the container is running, navigate to http://localhost:3838/box_test/
The text was updated successfully, but these errors were encountered: