Problem with yarn dependency using the rhino R package - r

I am trying the new R package rhino from the Appsilon team to build shiny apps.
Running on a Windows10 laptop I installed the dependencies node.js and yarn as described in this tutorial.
Here is the output of rhino::diagnostics() :
Windows 10 x64 build 19042
R version 4.1.0 (2021-05-18)
rhino: 1.0.0
node: v16.15.0
yarn: 1.22.15
Running rhino::build_sass() gives me this error:
yarn run v1.22.15
$ sass --no-source-map --style=compressed root/app/styles/main.scss:root/app/static/css/app.min.css
Error reading root\app\styles\main.scss: no such file or directory.
error Command failed with exit code 66.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error:
! System command 'yarn' exited with status 66.
i If you can't use Node.js and yarn, try using sass: 'r' configuration.
Run `rlang::last_error()` to see where the error occurred.
I am puzzled by the paths in the call to "sass" that start with "root/app". My app is located in my home directory:
"C:/Users/XXX/Documents/workspace/rhino_dummy"
Is it possible that these paths are wrong in the call?
Luckily, the suggested alternative with the deprecated libsass interpreter works for the sass example in the tutorial. It would be nice to have node.js with sass working on Windows10 for future more complex apps.
Edit 1, after Kat's comment
Thanks Kat for the quick feedback. I added sass via yarn add sass and tried again same error:
> rhino::build_sass()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ sass --no-source-map --style=compressed root/app/styles/main.scss:root/app/static/css/app.min.css
Error reading root\app\styles\main.scss: no such file or directory.
error Command failed with exit code 66.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error:
! System command 'yarn' exited with status 66.
i If you can't use Node.js and yarn, try using sass: 'r' configuration.
Run `rlang::last_error()` to see where the error occurred.
The warning is coming from the pckage.json file that was created by calling yarn inside my R project folder. It has only minimal content:
# package.json
{
"dependencies": {
"sass": "^1.51.0"
}
}
Out of curiosity, I tried to compile the javascript example, also failed with very similar error regarding folder paths:
> rhino::build_js()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ webpack
assets by status 0 bytes [cached] 1 asset
ERROR in main
Module not found: Error: Can't resolve 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js' in 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node'
resolve 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js' in 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node'
using description file: C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration using description file: C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\package.json (relative path: ./root/app/js/index.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.wasm doesn't exist
as directory
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js doesn't exist
webpack 5.69.0 compiled with 1 error in 162 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error in `system_yarn()`:
! System command 'yarn' exited with status 1.
Run `rlang::last_error()` to see where the error occurred.

For Node.js functions to work on Windows 10, you'll need to enable Developer Mode on your system as mentioned in our How-to: Use Rhino on Windows article. This is necessary for symbolic links to work on Windows (and the .rhino/node/root file is a symbolic link to the root of the project).
After you do that, delete the .rhino/node directory from your project, or run rhino:::add_node(clean = TRUE) in the root of your project.

Workaround
This answer is only a workaround, if you cannot enable developer mode on windows (see Kamil Zyla's post for more information).
It looks like the folder name "root" in the error messages is a broken variable.
The folder ...\workspace\rhino_dummy\.rhino\node\root does not exist, but the substructures do exit:
app\styles\main.scss
app\js\index.js
...\workspace\rhino_dummy\.rhino\node
Fix step1
I tried my luck and created the folder "root": C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root
copied rhino_dummy\app\styles\main.scss to rhino_dummy\.rhino\node\root\app\styles\main.scss
copied rhino_dummy\app\js\index.js to rhino_dummy\.rhino\node\root\app\js\index.js
running rhino::build_sass() and rhino::build_js() now worked!
rhino::build_sass()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ sass --no-source-map --style=compressed root/app/styles/main.scss:root/app/static/css/app.min.css
Done in 0.45s.
rhino::build_js()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ webpack
asset app.min.js 470 bytes [compared for emit] [minimized] (name: main)
runtime modules 670 bytes 3 modules
./root/app/js/index.js 113 bytes [built] [code generated]
webpack 5.69.0 compiled successfully in 846 ms
Done in 2.58s.
Fix step2
copy results back to "static" folder, where they are expected by shiny/rhino
copy rhino_dummy\.rhino\node\root\app\static\css\app.min.css to rhino_dummy\app\static\css\app.min.css
copy \rhino_dummy\.rhino\node\root\app\static\js\app.min.js to \rhino_dummy\app\static\js\app.min.js
launch the app via shiny::shinyAppDir(".")
click the button from the tutorial ;-)
Edit1
Checking the github repo of rhino
SASS
definition of build_sass()
calling yarn("build-sass")
definition of build-sass
showing hard-coded root/app/styles/main.scss
JS
definition of build_js()
calling yarn("build-js")
definition of "webpack" build-js also showing hard-coded "root" in file paths

Related

how to solve Firebase CLI error on start up

when I open firebase CLI I get this error :
Let's make sure your Firebase CLI is ready...
undefined:1
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at ChildProcess.<anonymous> (C:\snapshot\firepit\welcome.js:115:27)
at ChildProcess.emit (events.js:311:20)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Socket.emit (events.js:311:20)
at Pipe.<anonymous> (net.js:668:12)
I am using windows 10 pro
The comment on the original question was the solution for me. My "Downloads" folder is hosted on D: and the installer assumes C:
(how to solve Firebase CLI error on start up)
A solution that helped me after transferring the exe to C has failed, is deleting the folder:
C:\Users\{YOUR_PROFILE_NAME}\.cache\firebase
Hope this helps anyone
That is nothing to worry about, it only appears because the CLI by default assumes it is in the C directory.
So, copying the CLI exe to any other directory would show this message but, you can still use all the CLI functionalities as you wish.
Like what I did here using firebase init
The solution :
leave the exe name as: "firebase-win.exe" and you can move it to whatever folder you want
The detailed explanation:
i moved the executable i downloaded ("firebase-tools-instant-win.exe") to folder: c:\firebase\bin
and it works without any error,
but for some reason if i rename the exe file to something like: "firebase.exe" or "fbcli.exe" it will throw the json error and will not download the .cache folder correctly
but if i rename the exe name to: "firebase-win.exe" it works no matter what folder i put it in,
when checking C:\Users{YOUR_PROFILE_NAME}.cache\firebase\runtime\shell.bat
if the exe name is: "firebase.exe" (Not working) then the content is:
#echo off
"C:\firebase\bin\firebase.exe" C:\Users\{YOUR_PROFILE_NAME}\CACHE~1\firebase\runtime\shell.js %*
if the exe name is: "firebase-win.exe" (working) then the content is:
#echo off
"C:\firebase\bin\FIREBA~1.EXE" C:\Users\shaybc\.cache\firebase\runtime\shell.js %*
so i simply left the exe name: "firebase-win.exe"
valid names worked for me:
fireb-win.exe
firebase-win.exe
firebase-w.exe
fire-base.exe
fbcli-win.exe
...
Install Firebase using npm:
npm install firebase
source:
https://firebase.google.com/docs/web/setup
I got this warning as well, but when I tried to init, serve, and deploy, it worked just fine. Good luck!

Linking PHPUnit with PhpStorm

PHPUnit: 4.8.31
PhpStorm: 2016.1
I'm having issues running PHPUnit from within PhpStorm. From a CMD window, running the test works fine, but the PhpStorm output is this:
"C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\php\php704vc14x86x161109103716\php.exe" C:/Users/username/AppData/Local/Temp/ide-phpunit.php --no-configuration "C:\tests"
Testing started at 5:30 PM ...
Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\php\php704vc14x86x161109103716\ext\php_curl.dll' - The specified procedure could not be found.
in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\php\php704vc14x86x161109103716\ext\php_curl.dll' - The specified procedure could not be found.
Fatal error: Class 'PHPUnit_TextUI_ResultPrinter' not found in C:\Users\username\AppData\Local\Temp\ide-phpunit.php on line 253 in Unknown on line 0
PHP Fatal error: Class 'PHPUnit_TextUI_ResultPrinter' not found in C:\Users\username\AppData\Local\Temp\ide-phpunit.php on line 253
Process finished with exit code 255
I've included the folder with my phpunit.phar library in PhpStorm:
PhpStorm knows about the include paths, autocomplete works.
The run config looks like this:
The PHP version/install I'm using is the same one.
Windows:
PhpStorm:
Any ideas?
I tried running a script that uses curl from a CMD window and saw that the curl library wasn't loaded.
I did phpinfo(); and saw that the CMD window was using a different PHP installation (I had installed a new EasyPHP version).
I made the windows sys variable PATH point at my old one, then it started throwing some errors about not loading some libraries (php_curl.dll, libssh2.dll), so I moved them from the new install folder to the old one and to Windows\SysWOW64.
Miraculously, the PhpStorm run config was also fixed, which leads me to believe it doesn't use the interpreter I set in its options, but rather the one from PATH..
The PhpStorm output is now:
"C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\php\php704vc14x86x161109103716\php.exe" C:/Users/username/AppData/Local/Temp/ide-phpunit.php --no-configuration "C:\tests"
Testing started at 9:22 AM ...
Warning: The use statement with non-compound name 'PHPUnit_Framework_TestCase' has no effect in C:\DummyTest.php on line 3
PHPUnit 4.8.31 by Sebastian Bergmann and contributors.
PHP Warning: The use statement with non-compound name 'PHPUnit_Framework_TestCase' has no effect in C:\DummyTest.php on line 3
No tests found in class "TestDummy".
Time: 372 ms, Memory: 10.00MB
FAILURES!
Tests: 1, Assertions: 0, Failures: 1.
Process finished with exit code 1

error when I try to open app_dev.php file

I install symfony 2 under htdocs(xampp) folder, I start apache then I try to open app_dev.php file using this url :
http://localhost/symfony2/web/app_dev.php
I get this error :
Warning: require(C:\xampp\htdocs\symfony2\app/../vendor/autoload.php):
failed to open stream: No such file or directory in
C:\xampp\htdocs\symfony2\app\autoload.php on line 9
Fatal error: require(): Failed opening required
'C:\xampp\htdocs\symfony2\app/../vendor/autoload.php'
(include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\symfony2\app\autoload.php on line 9
the tutorial that I follow (here) say that it will open a page
I reistall symfony using this command :
$ composer create-project symfony/framework-standard-edition my_project_name "2.7.*"
it works perfectly
Best way is to start symfony via the console to get the development enviroment:
bin/console server:run
http://symfony.com/doc/current/book/installation.html#running-the-symfony-application
Also check the read and write privileges, and check the composer installation.

Grunt error SailsJS when lifting with --no-frontend

I have a Sails Api which the first time boots like a charm.
Press CTRL + C to stop it and then try to start it again. It works, BUT,
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
Aborted due to warnings.
Running "clean:dev" (clean) task
Warning: Cannot delete files outside the current working directory.
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `folderthingy` ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R 501 folderthingy
Well, I check it all, and the folder just is my own and has enough rights. I also put up a 777 for testing purposes but this didn't change a thing.
Then, I decided to clear out all the contents of the .tmp folder and try to boot again. This worked like a charm, .tmp got filled again, and when I stopped the server, tried to reboot it, I got the exact same error message again!
I'm booting with the --no-frontend option, so in fact I don't understand why it even wants to load grunt.
Why is this happening? What's going wrong here?
Why it happens is still not known to mankind, but I fixed it with removing the Gruntfile.
Fixed this by following below steps :
File path in your sails app -> tasks/config/sync.js
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-sync --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-sync');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Note: Work for Warning "sync:dev" not found
If you are using Linux, try doing sudo sails lift, you can have problems with permissions (happened to me). If Windows - check that no file manager or some other program is blocking the .tmp folder (also happened to me when I opened the folder in Total Commander).
In any case, since you don't use frontend, you can simply remove some of the grunt tasks (in the folder tasks/ you have README.md which explains which tasks are run in which case) or all of them (see documentation) and you won't have the problem.
i also got this error-
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
Aborted due to warnings.
Running "sass:dev" (sass) task
> error: Looks like a Grunt error occurred--
>
> error: Please fix it, then **restart Sails** to continue running tasks
> (e.g. watching for changes in assets)
>
> error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `/Users/siyaram.malav/Desktop/repo/project1/.tmp` ?
this error came because it could not find the sass module.And ran following command
sudo gem install sass
it worked for me.
In your case, try running sudo gem install clean command.
it should work.
thanks.
I had the same problem while following this tutorial:
https://www.youtube.com/watch?v=ZE7ye2G_H9Q&index=4&list=PLf8i4fc0zJBzLhOe6FwHpGhBDgqwInJWZ
I created a "linker" folder since that's what the guy did, which then prompted me with the error. It looks like he's using an older version of SailsJS since he runs into no errors.
Did you by any chance create a new folder in the assets folder? If you did, the problem is that grunt isn't able to run tasks on the specific folder since it's not linked with the rest of the assets folders and files. Try placing all newly created files within already existing folders and trying again. This worked for me.

stange error with Behat and Mink on Sf2

I'm using Behat,mink in my Symfony2 project,so I follow those tutorials to make installation :
http://extensions.behat.org/symfony2/ , http://extensions.behat.org/symfony2/migrating_from_2.3_to_2.4.html
but when I run this command php behat.phar --init "#YouBundleName",I get this very strange error :
PHP Warning: require(Behat\MinkExtension\Extension): failed to open stream: No such file or directory in phar:///var/www/project/behat.phar/src/Behat/Behat /Extension/ExtensionManager.php on line 112
PHP Fatal error: require(): Failed opening required 'Behat\MinkExtension\Extension' (include_path='.:/usr/share/php:/usr/share/pear') in phar:///var/www/project/behat.phar/src/Behat/Behat/Extension/ExtensionManager.php on line 112
I'm sure I installed the last version of behat and mink mentionned in the second link above and then I made php composer.phar unpdate and cache clear too,but still the same error?
I had the same problem. Forgot you need to install behat/mink-extension as well as behat/mink. For example you might need to run:
php composer.phar require behat/mink-extension:*
Worked for me.
By the way, looks like you got confused by the two installation methods, phar vs composer. I'd go with the composer route because it's easier to update and manage versions. This would mean running php bin/behat ... instead of php behat.phar ....

Resources