質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

1635閲覧

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

senseIY

総合スコア281

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2022/03/07 10:06

解決したいこと

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... ~ 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 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 ~ 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) :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 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
・何かしらアドバイスがあればよろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

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

投稿2022/03/07 11:30

senseIY

総合スコア281

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問