LoadError for dotenv/load while Dotenv.load works

Viewed 3662

I want to use dotenv in pure ruby environments. I mean I'm not using Rails.

The github instruction says there are two ways for loading the variables.

require 'dotenv/load'

# or
require 'dotenv'
Dotenv.load

In my environments the latter way works, but `require 'dotenv/load' raises the this error:

LoadError: cannot load such file -- dotenv/load

I gonna use Dotenv.load if former way doesn't work, but I want to know the reason of the error.

I'm using ruby 2.3.3p222 and dotenv (2.1.1). What am I doing wrong?

Additional Info

I'm using bundle exec pry and `load 'myapp.rb'. When I load the script I get the error.

2 Answers
gem install dotenv

Tested on version dotenv-2.7.5

Related