senseIY
@senseIY (I Y)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

rails sでエラーが出てしまう

解決したいこと

rails sでエラーが出てしまうので解決したいです。

まず、rails sをすると

senseiy@senseIY:~/dictum/dictum$ rails s
=> Booting Puma
=> Rails 6.0.4.6 application starting in development
=> Run `rails server --help` for more startup options
error Couldn't find an integrity file
error Found 1 errors.


========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================


To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).


yarn check v1.22.17
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.


Exiting

のようなエラーが出来てきました。どうやらyarnを新しくするといいみたいです。指示通りコマンドを実行すると、

senseiy@senseIY:~/dictum/dictum$ yarn install --check-files
yarn install v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > webpack-dev-server@4.7.4" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0".
warning "webpack-dev-server > webpack-dev-middleware@5.3.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
[4/4] Building fresh packages...
[-/2] ⠐ waiting...
error /home/senseiy/dictum/dictum/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /home/senseiy/dictum/dictum/node_modules/node-sass
Output:
Building: /usr/local/bin/node /home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/usr/local/bin/node',
gyp verb cli   '/home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@16.14.0 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/home/senseiy/dictum/dictum/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/home/senseiy/dictum/dictum/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (/home/senseiy/dictum/dictum/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
gyp verb `which` failed  python Error: not found: python
gyp verb `which` failed     at getNotFoundError (/home/senseiy/dictum/dictum/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/home/senseiy/dictum/dictum/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/home/senseiy/dictum/dictum/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp ERR! stack     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp ERR! stack     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
gyp ERR! System Linux 5.10.16.3-microsoft-standard-WSL2
gyp ERR! command "/usr/local/bin/node" "/home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/senseiy/dictum/dictum/node_modules/node-sass
gyp ERR! node -v v16.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1

このようなエラーになってしまいました。
https://qiita.com/nakki/items/4fa58cb6ff4d6c24c2d2

この方は$ yarn upgradeをしたら解決したようです。実行してみました。ですが、

senseiy@senseIY:~/dictum/dictum$ yarn upgrade
yarn upgrade v1.22.17
[1/4] Resolving packages...
warning @rails/webpacker > node-sass > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @rails/webpacker > node-sass > node-gyp > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning @rails/webpacker > node-sass > node-gyp > tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
warning @rails/webpacker > node-sass > request > har-validator@5.1.5: this library is no longer supported
warning @rails/webpacker > node-sass > request > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
warning @rails/webpacker > postcss-preset-env > postcss-color-gray > postcss-values-parser > flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
warning @rails/webpacker > webpack > node-libs-browser > url > querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning @rails/webpacker > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning @rails/webpacker > optimize-css-assets-webpack-plugin > cssnano > cssnano-preset-default > postcss-svgo > svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning @rails/webpacker > webpack > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > webpack-dev-server@4.7.4" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0".
warning "webpack-dev-server > webpack-dev-middleware@5.3.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
[4/4] Rebuilding all packages...
[-/2] ⢀ waiting...
error /home/senseiy/dictum/dictum/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /home/senseiy/dictum/dictum/node_modules/node-sass
Output:
Building: /usr/local/bin/node /home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/usr/local/bin/node',
gyp verb cli   '/home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@16.14.0 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/home/senseiy/dictum/dictum/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/home/senseiy/dictum/dictum/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (/home/senseiy/dictum/dictum/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
gyp verb `which` failed  python Error: not found: python
gyp verb `which` failed     at getNotFoundError (/home/senseiy/dictum/dictum/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/home/senseiy/dictum/dictum/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/home/senseiy/dictum/dictum/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/home/senseiy/dictum/dictum/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/home/senseiy/dictum/dictum/node_modules/which/which.js:80:29)
gyp ERR! stack     at /home/senseiy/dictum/dictum/node_modules/which/which.js:89:16
gyp ERR! stack     at /home/senseiy/dictum/dictum/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /home/senseiy/dictum/dictum/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
gyp ERR! System Linux 5.10.16.3-microsoft-standard-WSL2
gyp ERR! command "/usr/local/bin/node" "/home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/senseiy/dictum/dictum/node_modules/node-sass
gyp ERR! node -v v16.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1

このようなエラーが出来てしまいました。python2とnodeが怪しいというエラーのようです。nodeのダウングレードを考えましたが、推奨版と同じだったためとりあえずそのままにしてpython2をインストールすることにしました。以下を実行

 sudo apt update
 sudo apt install python2-minimal
 sudo apt-get install build-essential

もう一度yarn install --check-filesを実行

#エラーが長すぎるので気になった一部のみpython2のエラーは解消されたようだ 
#yarn upgrade と yarn install --check_yarn_integrity でも同じようなエラーに

yarn install v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > webpack-dev-server@4.7.4" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0".
warning "webpack-dev-server > webpack-dev-middleware@5.3.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
[4/4] Building fresh packages...
[-/2] ⡀ waiting...
error /home/senseiy/dictum/dictum/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /home/senseiy/dictum/dictum/node_modules/node-sass
Output:
Building: /usr/local/bin/node /home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/usr/local/bin/node',
gyp verb cli   '/home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@16.14.0 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
~
619e3b9799fa599ca81 == 0cb39adcabb513d2651fa25ea39c88cebd76200ea922e619e3b9799fa599ca81)
gyp verb get node dir target node version installed: 16.14.0
gyp verb build dir attempting to create "build" dir: /home/senseiy/dictum/dictum/node_modules/node-sass/build
gyp verb build dir "build" dir needed to be created? /home/senseiy/dictum/dictum/node_modules/node-sass/build
~
In file included from ../../nan/nan.h:58,
                 from ../src/binding.cpp:1:
../src/binding.cpp: At global scope:
/home/senseiy/.node-gyp/16.14.0/include/node/node.h:842:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
  842 |       (node::addon_register_func) (regfunc),                          \
      |                                           ^
/home/senseiy/.node-gyp/16.14.0/include/node/node.h:876:3: note: in expansion of macro ‘NODE_MODULE_X’
  876 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/binding.cpp:358:1: note: in expansion of macro ‘NODE_MODULE’
  358 | NODE_MODULE(binding, RegisterModule);
      | ^~~~~~~~~~~
make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
make: Leaving directory '/home/senseiy/dictum/dictum/node_modules/node-sass/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/senseiy/dictum/dictum/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 5.10.16.3-microsoft-standard-WSL2
gyp ERR! command "/usr/local/bin/node" "/home/senseiy/dictum/dictum/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/senseiy/dictum/dictum/node_modules/node-sass
gyp ERR! node -v v16.14.0
gyp ERR! node-gyp -v v3.8.0

ここで詰まってしまいました。

・wsl2のubuntu20.04を使っています。
・Ruby3.0.0
・Rails 6.0.4.6
・何かしらアドバイスがあればよろしくお願いいたします。

0

1Answer

nodeをダウングレードしたところうまく動きました。どうやら現在の推奨は16のようですが、15系でないと動かない場合があるようです。困っている方の参考になれば幸いです。

0Like

Your answer might help someone💌