ラベル mysql の投稿を表示しています。 すべての投稿を表示
ラベル mysql の投稿を表示しています。 すべての投稿を表示

mysql2のインストール失敗 An error occurred while installing mysql2 (0.4.5), and Bundler cannot continue.

rails5をインストールするときにmysql2のgemがうまく入らずにハマった時のメモ

mac 10.12.3
ruby 2.3.1p112
Bundler version 1.12.5

```
Installing mysql2 0.4.5 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /workdir/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5/ext/mysql2
/Users/yoshifuji.hiroki/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170415-12041-6ex24h.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... no
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql/5.6.26/lib
-----
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /workdir/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.4.5/mkmf.log

current directory: /workdir/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean

current directory: /workdir/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /workdir/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.5 for inspection.
Results logged to /workdir/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/mysql2-0.4.5/gem_make.out
Using puma 3.8.2
Using bundler 1.12.5
Using sass 3.4.23
Using tilt 2.0.7
Using turbolinks-source 5.0.0
Using tzinfo 1.2.3
Using nokogiri 1.7.1
Using rack-test 0.6.3
Using sprockets 3.7.1
Using websocket-driver 0.6.5
Using mime-types 3.1
Using coffee-script 2.4.1
Using uglifier 3.2.0
Using rb-inotify 0.9.8
An error occurred while installing mysql2 (0.4.5), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.5'` succeeds before bundling.
```

解決方法

xcode-select --install

xcodeのコマンドラインツールがインストールしてないだけだった。

xcodeのversionあげた場合とか気をつけたほうがよい。

Railsの開発環境をDockerで作った時にハマったところ Rails, Nginx, Redis, MySQL

docker-composeを使って構築する時にハマったところ


ホストマシン(Macのローカル環境)とDockerコンテナとのやりとり


 - ports ( -pオプション)でやりとりできるのはホストマシンのPortをマッピングする

なので

Dockerコンテナ同士のPortをマッピングしているわけではない

例えば、MySQLのコンテナ(Port:3306)にホストマシンからアクセスできるからといって、Railsを動かしているコンテナからアクセスはできない。


ホストマシン : mysql -h127.0.0.1 -uroot => OK
Railsコンテナ : mysql -h 127.0.0.1 -uroot => NG

linksを使って指定すれば、名前解決できるのでそれを使ってアクセスする

links:
    - mysql

Railsコンテナ : mysql -h mysql -uroot => OK


RailsアプリのMySQLへの接続、Redisへの接続などはホスト名の指定方法を変更する必要がある!!

修正前
database.yml
  host: localhost

development.rb
  config.session_store :redis_store,
                       servers: 'redis://localhost:6379/0',

修正後
database.yml
  url: mysql2://root:@mysql:3306

development.rb
  config.session_store :redis_store,
                       servers: 'redis://redis:6379/0',

Railsアプリの共有方法

ディレクトリ構成を以下のようにしていた

任意のディレクトリ/RailsApp/
  Gemfile
  app
  bin
  config
  db
  docker-compose/
    nginx/
      Dockerfile
      app.conf
    app/
      Dockerfile
    docker-compose.yml
    
そうすると、appのDockerfileに書くRailsAppのパスが親のパスになるため、Permissionエラーとなる

COPY .. /app
 
なのでdocker-compose.ymlとRailsアプリのDockerファイルはルートディレクトリに置くようにした



mysqldumpでバックアップ

mysqldumpを使ってmysqlのバックアップをとる

ただピンポイントでやりたい場合、既にあるSQLにちょっと追加したい場合など、
lvやlessでコピペしたい

mysqldump -uroot data-base-name

ReactNativeでAndroid対応する話

前提 ReactNativeでiOS版のアプリをリリースしていて、Android版をリリースする話 トラブルシューティング Build.VERSION_CODES.Q が存在しないエラー compileSdkVersionを29以上にすると解決 メモリー足りないエラー Execu...