33
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

bundle installしたgemを通常のrubyコードでrequireする方法

Last updated at Posted at 2017-05-27

確認環境

$ bundler -v
Bundler version 1.14.6
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

準備

$ bundle init
$ vi Gemfile

(使いたいgemを記述して保存)

$ bundle install --path vendor/bundle 

カレントパスのvendor/bundle以下にgemをinstallしています。

Gemfile例

Gemfile
source "https://rubygems.org"

gem 'pry', '0.9.12.2'

require

下記のような感じでrequireすると良い

foo.rb
require "bundler/setup"
# 個別にrequire
require "pry"

...
foo.rb
require "bundler/setup"
# 一括require
Bundler.require

...

参考

Ruby書くならBundler使え

33
36
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?