Saki
    • 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
    # パRails 環境構築の手順 ###### tags: `パRails(2回目)` [toc] ```md # 環境 - Ruby 2.7.6 - Rails 6.0.3 - node 16.17.0 (2022年8月時点 最新安定版) ``` ## Ruby 2.7.6 のインストール 1. 自分のローカル環境に`2.7.6`が入っているか確認する ```shell $ rbenv versions ``` 2. 1で`2.7.6`が入っていなければ、以下のコマンドでインストール ```shell $ rbenv install 2.7.6 ``` 3. バージョン切り替え ```shell $ rbenv local 2.7.6 ``` 4. Gemfileの書き換え ダウンロードしたサンプルコードのGemfileには元々、 ```ruby # Gemfile ruby '2.6.6' ``` と記載されているため、2.7.6に書き換える。 ```ruby # Gemfile ruby '2.7.6' ``` ### なぜ2.7.6なのか - 2.6系は、公式サポートが終了しているためです。 [Ruby 2.6の公式サポートが終了](https://www.famlog.jp/category/ruby) - このため、2.7系の中で一番最新である`2.7.6`を使うことに決めました ## Rails 6.0.3のインストール 1. 自分の環境に入っているバージョンの確認 ```shell $ gem list rails ``` 2. インストール ```shell $ gem i -v 6.0.3 rails ``` ## 輪読会のモブプロで起こったエラー ### `bundle install`すると、`mimemagic`のエラーが出る - `bundle install`すると以下のエラーが出る ``` Installing dependencies using bundler 2.2.1 Running: bundle install --jobs=4 --retry=4 Your bundle is locked to mimemagic (0.3.5), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of mimemagic (0.3.5) has removed it. You'll need to update your bundle to a version other than mimemagic (0.3.5) that hasn't been removed in order to install. ``` - 原因:`minemagic`というgemが、ライセンスを変えたことが原因で、Railsがbuildできなくなっている (参考:[RailsのGPL混入問題についてまとめ(mimemagic) \- Qiita](https://qiita.com/Esfahan/items/45c0cdeb29509b7ec1c5)) - 解決策は2つ 1. `bundle update`する ←パRails輪読会ではこちらを選択しました 2. Railsのバージョンを変える ### `rails s`したら、Yarnのエラーが出る - エラー内容 ```bash ======================================== 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). ``` - 原因 - webpacker周りはバージョンがややこしく、よく予期せぬエラーが起こる。 - 解決策 - `yarn install --check-files`を実行する - `rails s`してみてもダメな場合、以下を実行する - `config/webpacker.yml`を開き、`check_yarn_integrity`2ヶ所を`false`に書き換える ```ruby default: &default source_path: app/javascript source_entry_path: packs public_root_path: public public_output_path: packs cache_path: tmp/cache/webpacker check_yarn_integrity: false #ここをfalseにする webpack_compile_output: true (...省略...) development: <<: *default compile: true # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules check_yarn_integrity: false #ここをfalseにする ``` - 再度`rails s`したら起動できる ## ※各ディレクトリで同じエラーがまた出るので、覚えている内にまとめて環境構築してしまうことを推奨します🙏 - サンプルコードで、1つのRailsアプリで環境構築が完了しても、別のサンプルコードのRailsアプリで起動時、また同じエラーが出てしまいます。 - お手数ですが、 全部まとめて環境構築してしまうと楽だと思います。 <details><summary> ## Paruさんのリポジトリをcloneして動かす手順 </summary> - PC内の都合の良い場所で下記のコマンドをターミナルから入力、ファイルをクローンしてコードをダウンロードする ``` $ git clone https://github.com/Paru871/book_admin.git ``` - ダウンロードできたら、ディレクトリbook_adminを VSCode などで開いて、ターミナルから下記のコマンドを1つずつ入力、これによりDBが初期状態となり、seedに入れたデータが入る(現在Publisherが1件) ``` $ bundle $ yarn $ bin/setup $ rails db:reset ``` - その後、`rails s`してRailsを起動する。 ### 2回目以降 ``` $ git pull origin main ``` ## 「Webpacker::Manifest::MissingEntryError in コントローラー名#アクション名」のエラー解消 ### 👉 エラー解消のためにやったこと 1. nodeのバージョンを「12.22.12」に下げる 2. webpackerのインストール 3. webpackerのコンパイル ### 👉 nodeのバージョンを自動で切り替えられるようにするため、 .nvmrcと.node-versionの2つのファイルを設置しました。 - 「JavaScript環境の設定」プラクティスでは上記ファイルに対応する設定の指示が今年に入ってから更新されていますので、.nvmrcの設定ができている方は特に何もしなくてOKです。 - 昨年までに「JavaScript環境の設定」プラクティスが修了している方は下記のリンクから.nvmrcの対応をお願いします。 - [JavaScript環境の設定 | FBC](https://bootcamp.fjord.jp/practices/177) ### 👉 BootcampアプリのWikiにもnodeの切り替えの方法の説明があります。 [nodeのバージョン切り替え · fjordllc/bootcamp Wiki](https://github.com/fjordllc/bootcamp/wiki/node%E3%81%AE%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E5%88%87%E3%82%8A%E6%9B%BF%E3%81%88) ### 👉 nodeのインストール用コマンド(nvm使用の場合) - インストールされているnodeのバージョンのリストを表示 - `$ nvm ls` - 指定したバージョンのnodeをインストール - `$ nvm install 12.22.12` </details> ## elasticksearchだけdockerで起動する手順 - ディレクトリ直下に以下2つのファイルを作成 1. Dockerfile ``` FROM elasticsearch:7.17.4 RUN elasticsearch-plugin install analysis-kuromoji ``` 2. docker-compose.yml ```yml services: elasticsearch: build: . environment: discovery.type: single-node ports: - "9200:9200" - "9300:9300" ``` - Docker Desktopをインストール [Docker Desktop の Mac へのインストール \| Docker ドキュメント](https://matsuand.github.io/docs.docker.jp.onthefly/desktop/mac/install/) - ターミナル上で、以下を実行(Docker Desktopではやらない) ```ruby! $ docker compose build $ docker compose up ``` - `docker compose up`で`elasticsearch`が起動するので、起動したままの状態で`rails s`する。 →これでealsticsearchだけをdockerで起動することができる。

    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