sadanora
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 環境構築の手順 2023年版 - 2022年のパRails輪読会の [環境構築の手順](https://hackmd.io/y7qb2BRMT2Wd4tAtKYObcQ)を参考に進めれば問題ないはずです。 - ただ、2023年のパRails輪読会では扱うRubyなどのバージョンが2022年とは微妙に異なるため、バージョンについてや、[環境構築の手順](https://hackmd.io/y7qb2BRMT2Wd4tAtKYObcQ)に記載がないエラーの対応についてこのメモで補足できたらと思います。 ## 2023年版の環境 ```md # 環境 - Ruby 2.7.8 - Rails 6.0.6.1 - node v18.17.1(2023年8月時点の最新安定版) ``` - 環境構築する際は各バージョンを上記に読み替えて実行してください。 ## `rails new`する際の手順一覧 1. アプリケーション作成 (参考リンク:[【Rails】Git管理せずにRails newしたい \- 時々とおまわり](https://karlley.hatenablog.jp/entry/2023/05/20/095016)) ``` $ rails new アプリケーション名 --skip-git ``` 2. アプリ内へ移動しプラットフォーム追加(誰の環境でも問題なくBundlerを実行できるようにするため) ``` $ cd アプリケーション名 $ bundle lock --add-platform ruby $ bundle lock --add-platform x86_64-linux (Linux以外でnewされた場合はこれも追加) ``` 3. Gemfileを以下のように書き換え、追加する (`net-http`に関してはリンク参照:https://zenn.dev/be_the_light/articles/8d8951f6596528) ```ruby! gem 'webpacker', '~> 4.0' ↓ gem 'webpacker', '~> 5.0' # ↑これに変更する gem 'net-http'  # ↑これを追加する ``` 4. Gemfileに沿ってgemをインストール ``` $ bundle install ``` 5. webpackerインストール実行。途中の質問はすべて`Y`にする。 ``` $ bundle exec rails webpacker:install ``` 6. 足りないパッケージを追加 ``` $ yarn add '@babel/plugin-proposal-private-methods' ``` 7. さらに足りないパッケージを追加 ``` $ yarn add '@babel/plugin-proposal-private-property-in-object' ``` <details> <summary>8. webpackの環境変数の設定(現在必要なし)</summary> 8. /bin/webpackの5行目に以下の記載を追加 ``` ENV["NODE_OPTIONS"] = "--openssl-legacy-provider" ``` </details> <br> 以上で問題なく`$ bin/rails s`できるはずです! 途中のエラー等に関しては以下参照↓ https://bootcamp.fjord.jp/reports/79356 ## `$ yarn install`でエラーが発生する場合 `@rails/webpacker`を5.3.0にアップグレードすると解消できるはずです。 [yarn installできない · Issue \#3 · sadanora/book\_admin](https://github.com/sadanora/book_admin/issues/3) [yarn installできるようにした by sadanora · Pull Request \#2 · sadanora/book\_admin](https://github.com/sadanora/book_admin/pull/2) ## ActionView::Template::Error が発生した場合 このようなエラー ```bash Started GET "/tasks/new" for ::1 at 2023-08-24 16:02:59 +0900 (1.5ms) SELECT sqlite_version(*) (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC Processing by TasksController#new as HTML Rendering tasks/new.html.erb within layouts/application Rendered tasks/_form.html.erb (Duration: 14.7ms | Allocations: 3606) Rendered tasks/new.html.erb within layouts/application (Duration: 17.7ms | Allocations: 4070) [Webpacker] Compiling... [Webpacker] Compilation failed: node:internal/crypto/hash:69 this[kHandle] = new _Hash(algorithm, xofLen); ^ Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:69:19) at Object.createHash (node:crypto:133:10) at module.exports (/Users/user/samples/01/04/todo/node_modules/webpack/lib/util/createHash.js:135:53) at NormalModule._initBuildHash (/Users/user/samples/01/04/todo/node_modules/webpack/lib/NormalModule.js:417:16) at handleParseError (/Users/user/samples/01/04/todo/node_modules/webpack/lib/NormalModule.js:471:10) at /Users/user/samples/01/04/todo/node_modules/webpack/lib/NormalModule.js:503:5 at /Users/user/samples/01/04/todo/node_modules/webpack/lib/NormalModule.js:358:12 at /Users/user/samples/01/04/todo/node_modules/loader-runner/lib/LoaderRunner.js:373:3 at iterateNormalLoaders (/Users/user/samples/01/04/todo/node_modules/loader-runner/lib/LoaderRunner.js:214:10) at iterateNormalLoaders (/Users/user/samples/01/04/todo/node_modules/loader-runner/lib/LoaderRunner.js:221:10) at /Users/user/samples/01/04/todo/node_modules/loader-runner/lib/LoaderRunner.js:236:3 at context.callback (/Users/user/samples/01/04/todo/node_modules/loader-runner/lib/LoaderRunner.js:111:13) at /Users/user/samples/01/04/todo/node_modules/babel-loader/lib/index.js:44:71 { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.17.1 Completed 500 Internal Server Error in 3507ms (ActiveRecord: 1.6ms | Allocations: 16665) ActionView::Template::Error (Webpacker can't find application in /Users/user/samples/01/04/todo/public/packs/manifest.json. Possible causes: 1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. webpack has not yet re-run to reflect updates. 3. You have misconfigured Webpacker's config/webpacker.yml file. 4. Your webpack configuration is not creating a manifest. Your manifest contains: { } ): 6: <%= csp_meta_tag %> 7: 8: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 9: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> 10: </head> 11: 12: <body> app/views/layouts/application.html.erb:9 ``` webpackのコンパイルに失敗しているので`Error: error:0308010C:digital envelope routines::unsupported`について調べてみたところ、以下の記事を発見 [Node\.js 17以上にした際のOpenSSL互換エラー対応](https://zenn.dev/yogarasu/articles/425732ff408d06) OpenSSLの互換性の問題らしい。 一応`$ export NODE_OPTIONS=--openssl-legacy-provider`で環境変数を設定したところwebpackのビルドはできるようになった。 [\-\-openssl\-legacy\-provider | Node.js v18.17.1](https://nodejs.org/docs/latest-v18.x/api/cli.html#--openssl-legacy-provider) `/bin/webpack`で環境変数を設定しておけばいいかも? ```rb #!/usr/bin/env ruby ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" ENV["NODE_ENV"] ||= "development" ENV["NODE_OPTIONS"] = "--openssl-legacy-provider" # 追記 require "pathname" # 省略 ``` ## Webpacker::Manifest::MissingEntryError が発生した場合 webpack の生成物が残っている可能性があるので以下を試してみてください。 - `bin/webpack` でコンパイルしてみる。 - `bin/rails webpacker:clean webpacker:clobber` で webpacker の生成物を消してみる。 - `node_modules`をまるごと消して NPM パッケージを再インストールしてみる。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully