testing shiny, runApp error, can not find path - shiny

I have taken the code from http://shiny.rstudio.com/articles/build.html to test building a shiny app myself.
I have created a folder called 'Shiny' and made a project in R with this folder. Inside this project I have a folder called 'shiny_app' containing the ui.R and server.R files.
When I run runApp("/shiny_app"), I get the following error
Error in shinyAppDir(x) :
No Shiny application exists at the path "/shiny_app"
I have not changed the code from the website so I'm not sure why this is happening.
Can anyone advise? Thanks.

1) Check Working directory setwd("C:/Users/DND/Desktop/your folder")
2) Remove the forward slash, I don't think it is necessary runApp("shiny_app", launch.browser = T)

Related

Using custom fonts on shinyapps.io

I would like to use a custom font in my shiny app (on plots) on shinyapps.io. I have my Roboto-Regular.ttf in the ./www/ directory. And this is the upper portion of my app.R file:
dir.create('~/.fonts')
system("chmod +x ./www/Roboto-Regular.ttf")
system("cp ./www/Roboto-Regular.ttf ~/.fonts/")
system('fc-cache -f -v ~/.fonts/')
system('fc-match Roboto')
library(ggplot2)
library(shiny)
library(shinythemes)
library(extrafont)
font_import(pattern="Roboto",prompt=FALSE)
loadfonts()
print(fonts())
Upon deploying the app, I end up with an error that looks like this:
Registering fonts with R
Scanning ttf files in /usr/share/fonts/, ~/.fonts/ ...
Extracting .afm files from .ttf files...
/home/shiny/.fonts/Roboto-Regular.ttfWarning in gzfile(dest, "w") :
cannot open compressed file '/opt/R/3.5.1/lib/R/library/extrafontdb/metrics/Roboto-Regular.afm.gz', probable reason 'Permission denied'
Error in value[[3L]](cond) : cannot open the connection
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
Does anyone see what might be wrong?
After a bit of struggle I found an even simpler solution that works on shinyapps.io:
Here we go:
Place custom font in www directory: e.g. IndieFlower.ttf from here
Follow the steps from here
This leads to the following upper part of the app.R file:
dir.create('~/.fonts')
file.copy("www/IndieFlower.ttf", "~/.fonts")
system('fc-cache -f ~/.fonts')
Since Linux looks into the .fonts directory to search fonts, you don't need the extrafont package, but you can directly use those fonts like:
ggplot(mapping=aes(x=seq(1,10,.1), y=seq(1,10,.1))) +
geom_line(position="jitter", color="red", size=2) + theme_bw() +
theme(text=element_text(size = 16, family = "IndieFlower"))
This is the answer I received from RStudio regarding this. I haven't tested this out myself.
Hi,
Our developer was able to advise this is due to a possibly unfortunate design choice made when they created extrafont and the associated extrafontdb package. The extrafont font database is stored in the extrafontdb package directory -- that's essentially all that the extrafontdb package is used for.
This means that the extrafontdb directory needs to be user-writable. If the user installs the package, this will work fine, but if root installs the package (as is the case on shinyapps.io), then it won't work.
One potential workaround is to install the extrafontdb package to library that is in subdirectory of the app.
To do it: create an r-lib/ subdir, and download the extrafontdb source package there:
dir.create('r-lib')
download.file('https://cran.r-project.org/src/contrib/extrafontdb_1.0.tar.gz','r-lib/extrafontdb_1.0.tar.gz')
When deployed, the app will include this r-lib/ subdirectory and the extrafontdb source package.
Then, at the top of the app, install the extrafontdb package from the source package, into the r-lib directory.
.libPaths(c('r-lib', .libPaths()))
install.packages('r-lib/extrafontdb_1.0.tar.gz',type = 'source',repos = NULL)
They deployed an app on shinyapps.io that does the extrafontdb installation, and it works fine. The libpath is set so so that install.packages() will install from the provided source package to the r-lib/ subdirectory of the app.
Please let us know if you're able to implement the above or have any additional questions.
Thanks,
Adding an alternative answer to symbolrush's answer which I found did not work. Here was the code I used initially:
# Add fonts to shiny linux server
if (Sys.info()[['sysname']] == 'Linux') {
dir.create('~/.fonts')
fonts = c(
"www/IBMPlexSans-Regular.ttf",
"www/IBMPlexSans-Bold.ttf",
"www/IBMPlexSans-Medium.ttf"
)
file.copy(fonts, "~/.fonts")
system('fc-cache -f ~/.fonts')
}
# Load fonts and set theme
font_paths("fonts")
font_add("IBMPlexSans", regular = "IBMPlexSans-Regular.ttf")
font_add("IBMPlexSans-Bold", regular = "IBMPlexSans-Bold.ttf")
font_add("IBMPlexSans-Medium", regular = "IBMPlexSans-Medium.ttf")
showtext_auto()
The bizarre thing is that the first instance of the app on shinyapps.io worked, including the custom fonts. However when the app went to sleep and was opened a second time, I get this error in the log:
Error in value[[3L]](cond) : font file not found for 'regular' type
I was never able to debug why this was the case, but I tried a simpler solution that has worked perfectly so far. I moved my fonts to a /font folder in the app folder (I don't think using the /www folder is necessary) and added the /font folder using path_folder():
library(showtext)
# Load fonts and set theme
font_paths("fonts")
font_add("IBMPlexSans", regular = "IBMPlexSans-Regular.ttf")
font_add("IBMPlexSans-Bold", regular = "IBMPlexSans-Bold.ttf")
font_add("IBMPlexSans-Medium", regular = "IBMPlexSans-Medium.ttf")
showtext_auto()
I hope this helps anyone who is having problems with their app not running after the first instance, as I could not find the same situation anywhere on stackoverflow.

Django CompileError: File to import not found or unreadable: bootstrap-sass/assets/stylesheets/bootstrap/variables

I am currently working on the cadasta - an open source organisation's - Django project.
They require you to run their platform in a virtual machine (virtualbox) using vagrant.
As I enter their repository, and run their server using ./runserver, I am all of a sudden getting a CompileError which says:
File to import not found or unreadable: bootstrap-sass/assets/stylesheets/bootstrap/variables. Parent style sheet: /vagrant/cadasta/core/static/css/_variables.scss.
on line 74 of core/static/css/_variables.scss
#import "bootstrap-sass/assets/stylesheets/bootstrap/variables";
Following this link: https://github.com/jrief/djangocms-cascade/issues/130,
I found that libsass is already installed, and so I tried installing bootstrap-sass inside the VM, but it did no good. Everything was working fine until I renamed the cadasta-platform directory (i.e their github repo that I cloned, and so the main project is included inside this folder only.) and refreshed. I even tried running the server again, but couldn't get through this error. I suppose renaming the directory shouldn't be the cause?
I have no clue on how to proceed. Please help.
EDIT: After renaming the project folder to the same name solved this error. If anyone would ever like to answer this question, please explain why renaming the project directory produces an error like this? As I believe, I think renaming should not be an issue?

Errors I face at the final step of creating an installer for my Qt app

EDITED:
Hi all,
I used the Qt Documentations for creating an installer for my Qt app using Qt Installer Framework.
I think I'm at the final step. Please have a look at the issue:
I have a package_directory folder on my Windows Desktop with these sub-folders. The config.xml file contains this. The data subfolder contains the data.7z file. I then created a licens.txt file on my Desktop. The meta subfolder contains a package.xml file with this content.
Then I created a folder named Result on my Desktop and pasted the Cal.exe file from the Release folder onto it.
And finally Ran the following command:
C:\Qt\QtIFW2.0.3\bin\binarycreator.exe -c C:\Users\CS\Desktop\package_directory\config\config.xml -p C:\Users\CS\Desktop\package_directory\packages C:\Users\CS\Desktop\Result\Cal.exe
The installer was created in the Result folder. But I got the following message from the command line:
Warning: The <Name> tag in the 'C:/Users/CS/Desktop/package_directory/packag
es/com.vendor.product/meta/package.xml' is ignored - the installer uses the path
element right before the 'meta' ('com.vendor.product').
C:\Qt\QtIFW2.0.3\bin>
Should I ignore it? If not how to solve it, too, please?
The installer file exists in the Result folder on Desktop. When I install it and select a folder on Start Menu (say Accessories or Start Up) to have the shortcut of the program, no shortcut will be created or saved there!! :(
What is the reason for that problem and how should I solve it please?

Zurb foundation 6 , what-input.min.js file functionality

Id like to know the relevance of what-input.min.js include in Zurbs foundation-6 framework , in the js/vendor directory , this is because i keep getting an 404 not found error not loading while running the site , ... js/vendor/jquery.min.map file , is there any connection ?
You don't need the .map file which is used to map a minified file back to the original. It is available for download from jquery's site. Source maps are can be ignored in inspector settings which makes sense when you don't plan on debugging minified javascript files
It is unrelated to the source map file 404 but what-input.min.js is a JS library "to watch for mouse, keyboard and touch events"
They have a github page with more documentation: https://github.com/ten1seven/what-input
and a demo:
https://ten1seven.github.io/what-input/
"Tab, click or tap the links and form controls to see how What Input allows them to be styled differently"
I had this exact same problem on every site when using JointsWP with Foundation 6 framework. I finally just figured it out. I turned off css source mapping and still received the error. It turns out that it wasn't lying to me and the js file really does not exist where it is trying to load it from:
/vendor/what-input/what-input.min.js
But it is under the dist folder within that same directory. So if you find your enqueue-scripts.php file where the what-input.min.js is loaded, you can fix the directory path to:
/vendor/what-input/dist/what-input.min.js
And no more 404!

WinJS Sample Code js file missing?

"WinJS ToDo Sample for Multi-Device Hybrid Apps" Sample Code Project (http://code.msdn.microsoft.com/WinJS-TODO-Sample-for-17295485/sourcecode?fileId=114491&pathId=1137423199), I tried download and run it , but the index.html file include
three file for winjs reference : ./css/ui-light.css , ./scripts/frameworks/base.min.js , ./scripts/frameworks/ui.min.js , can't be found in the project .
what's i missing some thing ?
The sample projects have been authored in a way that the requisite dependency frameworks will be automatically downloaded when you run the project for the first time.
However, the libraries may fail to download in case the script does not have the right permissions to execute. To fix this:
Open the folder where you’ve downloaded the sample app
Identify the FetchRequirements.ps1 file and right click it
Choose “Properties”
Click the Unblock button if it shows up
Try to run the project again through Visual Studio