Skip to content

Instantly share code, notes, and snippets.

@digitalm
Last active January 7, 2019 08:59
Show Gist options
  • Save digitalm/c2fef1aa4c22b63532dcca2c1b201049 to your computer and use it in GitHub Desktop.
Save digitalm/c2fef1aa4c22b63532dcca2c1b201049 to your computer and use it in GitHub Desktop.

TL;DR

開発環境は以下のような準備をしていただけるとスムーズかも。
docker未導入なので、モダンでなく、たいへん申し訳ございません 🙇
環境の作成でなにか詰まったり困ったら、当gistにコメントいただるといいかもしれません (が、勤務時間外だと返信が遅くなるかもしれません)

version install example
ruby ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-darwin17] rbenv install -v 2.3.7 && rbenv rehash
postgres 9.5.13 brew install [email protected] && brew switch [email protected] 9.5.13 && postgres -D /usr/local/var/[email protected]
redis 4.0.9 brew install redis
ghostscript 9.22 brew install ghostscript
@kyamaguchi81
Copy link

kyamaguchi81 commented Dec 3, 2018

rbenv install -v 2.3.7後に行ったこと

  • gem install bundle
  • bundle install --path=vendor/bundle
  • gem install libv8 -v '3.16.14.17' --source 'https://rubygems.org/'

postgresがうまくはいらない

Error: [email protected] does not have a version "9.5.13" in the Cellar.
[email protected] installed versions: 9.5.14

@digitalm
Copy link
Author

digitalm commented Dec 3, 2018

macOS Mojaveで古いlibv8とtherubyracerが入らない時の対処法 - Qiita | https://qiita.com/shimx/items/32e85093f21e673c7127

-> bundle config する
bundle config --local build.therubyracer --with-v8-dir=$(brew --prefix v8-315)

export PATH="/usr/local/opt/[email protected]/bin:$PATH"

@kyamaguchi81
Copy link

kyamaguchi81 commented Dec 3, 2018

上のリンクで打ったコマンド

  • export PATH="/usr/local/opt/[email protected]/bin:$PATH"
  • source ~/.zshrc
  • brew install v8-315
  • bundle config --local build.therubyracer --with-v8-dir=$(brew --prefix v8-315)
  • bundle config --local build.libv8 --with-system-v8

@kyamaguchi81
Copy link

kyamaguchi81 commented Dec 3, 2018

DB設定とローカルサーバ立ち上げ

事前準備

  • config/database.ymlのrootユーザー名をローカル環境のユーザー名に変更する(例えばkensukeyamaguchi)

rake(DBセット)

$ bundle exec rake db:create
$ bundle exec rake db:migrate
$ bundle exec rake db:seed_fu

DB立ち上げる

$ pg_ctl -D /usr/local/var/postgres/ start
$ redis-server

$ bundle exec sidekiq -C config/sidekiq.yml

アプリケーション立ち上げる

$ rails s

localhost:3000 にアクセスする

FYI

postgresユーザー作成方法
https://github.com/knowledgelabo/Manageee/pull/107

@kyamaguchi81
Copy link

seed_fu で下記のような ERROR: column "increment_by" does not exist が表示される場合は

$ �bundle exec rake db:drop

してから seed_fu するとうまくいくかも

% bundle exec rake db:seed_fu                 
                                                                               
== Seed from /Users/you_mac/workspace/group-manager/db/fixtures/config_user_permission.rb
(...中略...)
2017-11-04 02:56:52.833 JST [60030] ERROR:  column "increment_by" does not exist at character 103
2017-11-04 02:56:52.833 JST [60030] STATEMENT:              SELECT setval('public.config_user_permissions_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_by FROM public.config_user_permissions_id_seq), (SELECT min_value FROM public.config_user_permissions_id_seq)) FROM "config_user_permissions"), false)
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column "increment_by" does not exist
LINE 1: ...sions_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_...
                                                             ^
:             SELECT setval('public.config_user_permissions_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_by FROM public.config_user_permissions_id_seq), (SELECT min_value FROM public.config_user_permissions_id_seq)) FROM "config_user_permissions"), false)
/Library/Ruby/Gems/2.0.0/gems/seed-fu-2.3.5/lib/seed-fu/runner.rb:46:in `eval'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute'
(略)
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => db:seed_fu
(See full trace by running task with --trace)

引用元: https://github.com/NUTFes/group-manager/wiki/postgres%E3%81%AE%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E3%81%8C10.x%E3%81%A7%E3%82%A8%E3%83%A9%E3%83%BC

もしそれでもだめなら下記を試してみる

$ brew install postgresql
$ brew unlink postgresql && brew link postgresql
$ bundle exec rake db:drop

$ bundle exec rake db:create
$ bundle exec rake db:migrate
$ bundle exec rake db:seed_fu

@digitalm
Copy link
Author

digitalm commented Dec 17, 2018

rubyracer問題 -> gcc11+ 使えば mini_racer に置き換えられるのではないか
https://github.com/rails/rails/blob/f8a3935ba17c5f99dafe8d9c92fd1de5936abca6/guides/source/getting_started.md#starting-up-the-web-server

less-rails が rubyracer 依存なので、引っこ抜いた後なら可能そう
rubyjs/therubyracer#437 (comment)

@kyamaguchi81
Copy link

最終的に下記で ERROR: column "increment_by" does not exist at character 103 が表示されないかたちでpostgresを入れれた

$ brew install [email protected]
$ brew services stop postgresql
$ brew services start [email protected]

$ bundle exec rake db:drop
$ bundle exec rake db:create
$ bundle exec rake db:migrate
$ bundle exec rake db:seed_fu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment