Shell command in ruby: Path problems - ruby

The following shell script should check my ruby project for lint coffeescript and scss.
#!/usr/bin/env ruby
puts "\n== Checking if CoffeeScript is lint =="
checks << system("coffeelint -f .coffeelint.json ./app/assets/javascripts/**/*.coffee")
puts "\n== Checking if SCSS is lint =="
checks << system("scss-lint ./app/assets/stylesheets/**/*.scss")
exit 1 if checks.include?(false)
But the output of running that script in zsh is the following:
== Checking if CoffeeScript is lint ==
fs.js:849
return binding.stat(pathModule._makeLong(path));
^
Error: ENOENT: no such file or directory, stat './app/assets/javascripts/**/*.coffee'
at Error (native)
at Object.fs.statSync (fs.js:849:18)
at findCoffeeScripts (/Users/josua/.nvm/versions/io.js/v2.3.3/lib/node_modules/coffeelint/lib/commandline.js:79:14)
at Object.<anonymous> (/Users/josua/.nvm/versions/io.js/v2.3.3/lib/node_modules/coffeelint/lib/commandline.js:247:17)
at Object.<anonymous> (/Users/josua/.nvm/versions/io.js/v2.3.3/lib/node_modules/coffeelint/lib/commandline.js:254:4)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/josua/.nvm/versions/io.js/v2.3.3/lib/node_modules/coffeelint/bin/coffeelint:34:5)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:471:10)
at startup (node.js:117:18)
at node.js:948:3
== Checking if SCSS is lint ==
No such file or directory # rb_sysopen - ./app/assets/stylesheets/**/*.scss
It seems like the current working path is wrong, but at least puts system("pwd") is showing the correct directory from where the relative paths in the arguments should be reachable.
What's going on here?

Related

Error: Cannot find module '#npmcli/map-workspaces'

Whenever I try to run any npm command I get the following error:
Error: Cannot find module '#npmcli/map-workspaces'
Require stack:
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\config\lib\index.js
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\npm\lib\npm.js
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
at Module._load (node:internal/modules/cjs/loader:885:27)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\Lenovo\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\config\lib\index.js:6:23)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Module.require (node:internal/modules/cjs/loader:1105:19)
I have installed Nodejs and I have all the necessary paths set in my environment variables.
Under my User Variables in Paths I have included the following paths:
C:\Program Files\nodejs
C:\Users\Lenovo\AppData\Roaming\npm
My node version is v18.13.0
I also have nvm installed and the version is 1.1.10
Please advice on the way forward

React Native init fails on cocoapods install

I am facing a rather strange bug. If I react-native init through my terminal, cocoapods installs fine.
If I init a new project through vscode's integrated terminal, I get this error during pod install:
For help, see: https:/nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
[!] Invalid `Podfile` file: 859: unexpected token at ''.
# from /Users/XXXXX/Documents/test/ios/Podfile:7
# -------------------------------------------
# target 'test' do
> config = use_native_modules!
#
# -------------------------------------------
I have verified that my LANG variable is the same on both terminals: en_US.UTF-8
Ruby version: ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [arm64-darwin21]
Cocoapods version: 1.11.3
I have tried installing ruby through brew, rbenv, rvm. The problem remains on all three.
I am on MacOS Monterey 12.1 on M1.

Problem with building the front-end-template

I am trying to install and use the React front end template for Substrate as per this tutorial, but when I run yarn install or yarn start in the project's root directory I get this error:
/home/.../substrate-front-end-template/.yarn/releases/yarn-berry.cjs:2
module.exports=(()=>{var e=
*blah blah blah*
SyntaxError: Unexpected reserved word
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
I am using yarn v.1.22.11 and node v.8.10.0. How can I fix this issue?
Check versions of Yarn and NodeJS. On those versions on my end all works fine:
tomek#rhei-box:~/workspaces/substrate-front-end-template$ node -v
v12.22.4
tomek#rhei-box:~/workspaces/substrate-front-end-template$ yarn -v
2.4.0
In case you are on Linux-like machine check nvm tool in order to be able to change fast versions of NodeJS.

SailsJS remove bluebird

I want to remove the bluebird package installed in my sails app, in favor of the native Node promises.
But after I set npm remove bluebird --save, I get:
Error: Cannot find module 'bluebird'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/candyvoice/node_modules/sails/node_modules/consolidate/lib/consolidate.js:22:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/candyvoice/node_modules/sails/node_modules/consolidate/index.js:1:80)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
I don't use bluebird anywhere in my code so I'm guessing this is somehow a Sails dependency? The stacktrace doesn't refer to any of my files either.
Thanks
Bluebird is a SailsJS dependency.
You can use native promises in your application alongside Sails' bluebird ones and it'll work seamlessly.
Bluebird has thousands of tests to ensure that its promises work seamlessly with native ones - and bluebird contributors are also NodeJS contributors that ensure it doesn't break from the other side either. (Full disclosure, I'm a bluebird contributor and a NodeJS collaborator).
Simply don't use bluebird in your own code - and things will work well :)
As a caveat, in NodeJS 8 there's a chance unhandled promise rejections will throw. You can fix this by setting process.on("unhandledRejection" which will set the same behavior to all promises.

Rails precompile assets on Heroku Sprockets::FileNotFound

I try to deploy my simple Rails app to Heroku. This app is just attempt to use bower with Heroku.
Unfortunately I have problems with precompile assets on Heroku.
This gives me error Sprockets::FileNotFound.
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Sprockets::FileNotFound: couldn't find file './app/App'
remote: (in /tmp/build_fe6dc0e2c0063705b279b26e4aa2432d/app/assets/javascripts/application.js:12)
I don't know what can be the cause. App.js is my own file and it surely exists.
Need to mention that rake assets:precompile work properly on my local machine.
This is my applications.js which includes all other files
//= require jquery
//= require jquery_ujs
//= require vendor/angular/angular
//= require vendor/angular-route/angular-route
//= require vendor/angular-resource/angular-resource
//= require vendor/angular-sanitize/angular-sanitize
//= require vendor/moment/moment
//= require vendor/angular-moment/angular-moment
//= require ./app/App
//= require ./app/router
//= require_tree ./app/controllers
//= require_tree ./app/directives
//= require_tree ./app/filters
In some similar questions I found advice to run heroku repo:purge_cache.
But this failed to me too.
~/tmp/repo_tmp $ cd unpack
~/tmp/repo_tmp/unpack $ tar -zxf ../repo-cache.tgz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
All source code is published at GitHub
https://github.com/ivanovalexey/bowerrr
Could some one help me figure it out?
Thank you.
Solved. The problem was with file name ./app/App.js. I renamed it to ./app/main.js and it worked. Still wonder why it doesn't matter locally.

Resources