4

I am trying to setup rails on aws (Dev env work fine). Can not get production to start up correctly. Can shell in and db looks good. I looked into my log file and I am getting the following error.

rake aborted!
MultiJson::AdapterError: Did not recognize your adapter specification (cannot load such file -- json/ext/parser).

Have MultiJson and Json gems installed and in the gemlock file.

This happens during asset compilation.

user1703416
  • 41
  • 1
  • 3

3 Answers3

5

I'm not 100% sure what the problem was but I read somewhere that downgrading the multi_json gem to version 1.7.8 would fix this and it did for me. Please note that this is just what fixed my app, it might not be the same for you but hopefully it is! I did the following:

Add the following to your Gemfile:

gem 'multi_json', '1.7.8' 

And then update the gem:

bundle update multi_json

Commit the new changes:

git add .
git commit -m "Downgrade multi_json gem"

And push to AWS:

git aws.push

That should resolve the issues.


If you get a complaint from bundler about mis-matched dependencies you can re-install your gems and hopefully fix the dependency issues by removing the Gemfile.lock.

To delete the Gemfile.lock run:

rm Gemfile.lock

And then run bundle install:

bundle install

Commit again and push to aws.

betamax
  • 13,431
  • 9
  • 38
  • 55
  • Just curious, why do you rm the Gemfile.lock? bundle update overwrites it. Is there some case where your approach is safer? –  Jun 04 '14 at 08:29
  • You're right, `bundle update multi_json` would be safer and the better solution. The reason I wrote to remove the Gemfile.lock was because that fixed the issue in my situation whereas `bundle update` didn't. I changed the answer to instruct people to run `bundle update` first. Thanks! – betamax Jun 04 '14 at 09:17
0

After dealing with a situation where I couldn't revert the version, I found another solution to the problem.

We are just missing the appropriate dependent gem. This worked for me to fix it without downgrading:

gem install json

Hopefully that also helps other people with this problem. I got here from Google, so hopefully other people will as well.

0

I'm having a similar problem today. Here's a bit of my log:

Started POST "/users/sign_in" for 173.228.60.113 at 2015-09-29 15:53:47 +0000

MultiJson::AdapterError (Did not recognize your adapter specification (cannot load such file -- json/ext/parser).):
  activesupport (3.2.3) lib/active_support/dependencies.rb:251:in `require'
  activesupport (3.2.3) lib/active_support/dependencies.rb:251:in `block in require'
  activesupport (3.2.3) lib/active_support/dependencies.rb:236:in `load_dependency'
  activesupport (3.2.3) lib/active_support/dependencies.rb:251:in `require'
  json (1.8.3) lib/json/ext.rb:13:in `'
  json (1.8.3) lib/json/ext.rb:12:in `'
  json (1.8.3) lib/json/ext.rb:9:in `'

bundle show (on the ec2 instance) shows where the json gem is installed:

[ec2-user@ip-172-31-43-145 current]$ bundle show json
/usr/local/share/gems1.9/gems/json-1.8.3

Below that directory there is a file ext/json/ext/parser/parser.so

This is a native extension. I've run into issues with these not installing correctly many times before. My workaround is to install a symlink in lib/json/ext

The command looks like this:

ln -s ../../../ext/json/ext/parser/parser.so .

from the above directory.

I also put in a symlink for generator.so. The command, executed while connected to lib/json/ext was:

ln -s ../../../ext/json/ext/generator/generator.so .

There's another directory under ext/json called fbuffer, but it only has a .h file, no .so.

This resolved the issue. I knew where to look because the error message always tells you a path relative to the core gem .rb file, which in this case was ext/json/json.rb

I am not at all happy about having to do this by hand each time a gem with a native extension updates. I would very much like it if someone could tell me how to not have to do that. But in the meantime, this will fix it.

gischer
  • 274
  • 1
  • 3
  • 8