### 解決したいこと

`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
    
```

以下リンク先の方は `yarn upgrade` をしたら解決したようです。

[rails コマンドの際のyarnエラー yarn.lockで不整合が起きてる場合に起こる -
Qiita](https://qiita.com/nakki/items/4fa58cb6ff4d6c24c2d2)

実行してみましたが、以下のようなエラーが出てしまいました。

```

    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を使っています。
  * Ruby 3.0.0
  * Rails 6.0.4.6
CC BY-SA 4.0
2022-03-07T10:10:49.923
86738
2022-03-07T12:11:14.790
2022-03-07T12:11:14.790
3060
51193
question
ruby-on-rails wsl yarn
rails sでエラーが出てしまう
nodeをダウングレードしたところうまく動きました。どうやら現在の推奨は16のようですが、15系でないと動かない場合があるようです。困っている方の参考になれば幸いです。
CC BY-SA 4.0
2022-03-07T11:31:05.603
86739
2022-03-07T11:31:05.603
51193
86738
answer