Search code examples
rubyrubygemstoml

Can't load such file - toml-rb, although the gem is installed


My Gemfile:

gem "toml-rb", "~> 0.3.8"

*.rb file:

require "toml-rb"

Locally it works, on a remote server - error:

/home/user_123/.rubies/ruby-2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- toml-rb (LoadError)

Although I've run "bundle" and

$ bundle info  toml-rb
    * toml-rb (0.3.15)
    Summary: TOML parser in ruby, for ruby.
    Homepage: http://github.com/emancu/toml-rb
    Path: /home/user_123/.gem/ruby/2.4.2/gems/toml-rb-0.3.15

What's the matter?


Solution

  • It looks like you're using v0.3.15 of toml-rb. At that point, it was referred to simply as toml.

    Try this:

    require "toml"
    

    Here's an excerpt from the README for v0.3.15:

    require 'toml'
    
    # From a file!
    path = File.join(File.dirname(__FILE__), 'path', 'to', 'file')
    TOML.load_file(path)
    

    Beginning at v1.0.0, the toml-rb would be required like so: require 'toml-rb'. Here's the release where this was changed: https://github.com/emancu/toml-rb/releases/tag/v1.0.0