Sign in | Sign up

Nutritionix API 1.1 cannot load such file


Currently contains 4 posts


April 23, 2014 17:08


Hey, I’m using the Ruby on Rails Api 1.1 gem found at

While I know it’s not an official gem, I’m getting an error trying to instantiate the module as described in the sample script.

require_relative ‘../lib/nutritionix/api_1_1’

def nxql_search_params
fields = %w(brand_id brand_name item_id item_name nf_serving_size_qty nf_serving_size_unit)
fields << %w(nf_calories nf_total_carbohydrate nf_sodium nf_dietary_fiber nf_protein)
default_fields = fields.flatten

{ offset: 0, limit: 50, fields: default_fields }


app_id = ‘<YOUR_APP_ID>’
app_key = ‘<YOUR_APP_KEY>’
provider =, app_key)
search_params = nxql_search_params
search_params.merge!(query: ‘potato’)
results_json = provider.nxql_search(search_params)
puts “Results: #{results_json}”

This gives me the error : LoadError cannot load such file — /xxxxxxx/app/lib/nutritionix/api_1_1 directly on the require_relative line.

I already posted an issue on the github, and also saw that mattsilv also reported a similar issue about a month ago. Has there been any fix to it yet?


May 02, 2014 16:06

Matt Silverman

Hi, we do not officially support the RoR library, but we are checking into this. Thanks!


August 19, 2014 13:51


This worked for me:

require_relative ‘../.bundle/ruby/2.0.0/gems/nutritionix-1.1.0/lib/nutritionix/api_1_1’


September 05, 2014 00:12


require ‘nutritionix/api_1_1’

works for me

Reply to thread