内容へ移動
Cat Paw Software
ユーザ用ツール
ログイン
サイト用ツール
検索
ツール
文書の表示
以前のリビジョン
バックリンク
最近の変更
メディアマネージャー
サイトマップ
ログイン
>
最近の変更
メディアマネージャー
サイトマップ
トレース:
bundler
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== bundler ====== rubygems の管理ツール。バージョン依存を解決したり、アプリごとにgem管理を行える ===== Gemfileのバージョン指定 ===== <code ruby> gem "hoge" # 未指定、無ければ最新版を入れ、既にあればそれを使う gem "hoge", "=1.3.2" # バージョン 1.3.2 のみ gem "hoge", ">=1.3.2" # バージョン 1.3.2 以降のどれか gem "hoge", "~>1.3.2" # バージョン 1.3.2 以降 1.4 未満のどれか gem "hoge", "~>1.3" # バージョン 1.3 以降 2 未満のどれか </code> ===== bundlerのインストール ===== bundler自体はgemで普通にインストールする。最近のRubyには最初からインストールされているので以下は不要 $ gem install bundler ===== bundlerを使う ===== ==== Gemfileを作成する ==== $ bundle init ==== gemライブラリインストール先の指定 ==== ''--path''による指定は非推奨。以下で設定する <code> bundle config set --local path ./vendor </code> ==== Gemの依存性を解決 ==== $ bundle install 最新版ではないが条件を満たすものが既にインストールされている場合、アップデートされない。 ==== Gemを更新 ==== $ bundle update 条件を満たす最新版にアップデートされる。 ==== bundler自身を更新 ==== 普通にgemでインストールする $ gem install bundler バージョンを指定する場合 $ gem install bundler -v '2.5.3' ロックされているバージョンを上げる。これは実行しているbundlerは最新版、Gemfile.lockに記述されているbundlerのバージョンが古い場合で、普通にbundle installするとロックされている古いbundlerがインストールされてしまう。Rubyのメジャーバージョンを上げたりすると発生する。 $ gem update --bundler ==== アプリ毎にGemを管理 ==== $ bundle install ==== 実行 ==== bundleでpathを指定してインストールした場合、普通にrubyやirbコマンドを叩いてもライブラリパスに入っていないのでインストールしたgemを使えない。 $ bundle exec ruby とする。 ==== Gemでインストールされるコマンドを使う ==== 例えばrspec等のコマンドを持っているgemをbundleでpathを指定してインストールした場合、パスもイブラリパスも通っていないので、そのままでは使えない。 $ bundle install --binstubs と打つと ./bin/rspec が作成される。 $ ./bin/rspec でrspecを実行できる。 コマンドを作成する場所も指定可能 $ bundle install --binstubs=vendor/bin ===== Gemを開発する ===== bundlerを利用するGemを開発するには… $ bundle gem PROJECT_NAME これで、プロジェクトのひな形が作られる。 ===== gemインストールエラー対策 ===== ==== nokogiriでlibxml2が見つからない ==== * ruby 2.5.1 * bundler 2.0.1 * gem 2.7.6 * macOS 10.14.3 <code> Fetching nokogiri 1.8.2 Installing nokogiri 1.8.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/nullpon/Documents/private/bluenotes-rails/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.8.2/ext/nokogiri /Users/nullpon/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20190225-38046-kqdrce.rb extconf.rb --use-system-libraries checking if the C compiler accepts ... yes checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no Building nokogiri using system libraries. ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed. *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. </code> <code> $ brew install libxml2 $ bundle config build.nokogiri --with-libxml2-include=/usr/local/opt/libxml2/include/libxml2 </code> ググると ''--use-system-libraries'' が必要と出てくるが最近はデフォルトで付いてるらしい。 ==== mysql2でsslライブラリが見つからない ==== * ruby 2.5.1 * bundler 2.0.1 * gem 2.7.6 * macOS 10.14.3 <code> 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 </code> <code> $ brew install openssl $ bundle config build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include" </code> ==== rmagickで wand/MagickWand.h が見つからない ==== <code> checking for wand/MagickWand.h... no Can't install RMagick 2.13.4. Can't find MagickWand.h. </code> wand/MagickWand.h は imagemagick 6に入っている(7にはない) <code> brew install imagemagick@6 brew link --force imagemagick@6 </code> ==== DidYouMean ==== <code> Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead. </code> bundler 2.2 or 2.3あたりを使っていると表示された。bundler自身を更新することで解決する ===== Gitリポジトリからgemをインストール ===== Gemfileに以下のように記述 <code> gem "http-server", git: 'https://github.com/paulownia/http-server.git' </code> または <code> git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } gem "http-server", github: 'paulownia/http-server' </code>
bundler.txt
· 最終更新: 2025/02/02 04:26 by
nullpon
ページ用ツール
文書の表示
以前のリビジョン
バックリンク
文書の先頭へ