Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`to_json': wrong argument type JSON::Pure::Generator::State (expected JSON/Generator/State) (TypeError #7388

Closed
bantonj opened this issue Jun 3, 2016 · 5 comments

Comments

@bantonj
Copy link

bantonj commented Jun 3, 2016

Vagrant: 1.8.1
OS: OS X 10.11.13

Vagrantfile

VAGRANTFILE_API_VERSION = "2"  
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  unless Vagrant.has_plugin?('vagrant-s3auth')
    # Attempt to install ourself. Bail out on failure so we don't get stuck in an
    # infinite loop.
    system('vagrant plugin install vagrant-s3auth') || exit!

    # Relaunch Vagrant so the plugin is detected. Exit with the same status code.
    exit system('vagrant', *ARGV)
  end

  config.vm.define "redis" do |v|
    v.vm.provider "docker" do |d|
      d.name = "redis-int-api"
      d.remains_running = true
      d.image = "redis"
      d.volumes = ["/var/docker/redis:/data"]
      d.ports = ["6379:6379"] #note if you want to access it outside of docker you need to modify Vagrantfile.proxy
      d.vagrant_machine = "docker-host"
      d.vagrant_vagrantfile = "./Vagrantfile.proxy"
    end
  end

  config.vm.define "mysql" do |v|
    v.vm.provider "docker" do |d|
      d.name = "mysql-int-api"
      d.remains_running = true
      d.image = "mysql:5.6"
      d.volumes = ["/var/docker/mysql:/var/lib/mysql"]
      d.ports = ["3306:3306"]
      d.vagrant_machine = "docker-host"
      d.vagrant_vagrantfile = "./Vagrantfile.proxy"
      d.cmd = ["mysqld", "--explicit_defaults_for_timestamp=0", "--sql-mode=NO_ENGINE_SUBSTITUTION"]
      d.env = {
            "MYSQL_ROOT_PASSWORD"=> "root",
            "MYSQL_USER"=> "krossover",
            "MYSQL_PASSWORD"=> "intelligence",
            "MYSQL_DATABASE"=> "intelligence"
            }
    end
  end

  config.vm.define "intelligence-api" do |api|
     # vagrant host port offset for port forwarding. The base ports are:
     #80 > 8080
     #443 > 4433
     # This setting adds an offset so multiple VMs do not have port conflicts.
     port_offset = 3
     ENV['AWS_ACCESS_KEY_ID']     = "blah
     ENV['AWS_SECRET_ACCESS_KEY'] = "blah"
     api.vm.box     = 'krossoverintelligence/intelligence-api'
     api.vm.box_url = 'vagrantcloud.json'
     api.ssh.username = "vagrant"
     api.ssh.password = "vagrant"
     api.vm.network :forwarded_port, guest: 80, host: 8080 + port_offset, auto_correct: true
     api.vm.network :forwarded_port, guest: 80, host: 4433 + port_offset, auto_correct: true
     api.vm.hostname = `uname -n`.chop.gsub('.', '-') + "-dev"
     api.vm.synced_folder "..", "/var/www/html/intelligence-api", group: "www-data", :mount_options => ['dmode=775','fmode=775']
     api.vm.synced_folder "..", "/home/vagrant/project", group: "www-data", :mount_options => ['dmode=777','fmode=777']
     config.vm.provision "shell", path: "shell/add_keys.sh", privileged: false
     config.vm.provision "shell", path: "shell/run_composer.sh", privileged: false
     config.vm.provision "shell", path: "shell/vagrant_provisioner.sh", privileged: true
   end

end 

Debug output

https://gist.github.com/bantonj/4c197e84c3f6a0846146089bcaadfe4a

Expected behavior

The boxes should be brought up.

Actual behavior

For some users, at various steps in the process the error 'to_json': wrong argument type JSON::Pure::Generator::State (expected JSON/Generator/State) (TypeError) Raw is thrown. For those users who do experience this error, if vagrant up is run 3-4 times, the boxes will eventually be brought up.

Steps to reproduce

  1. vagrant destroy
  2. vagrant up
@sethvargo
Copy link
Contributor

Hi @bantonj

This looks to be coming from a plugin that installed the json-pure gem. Can you please run vagrant plugin list and send the output?

@bantonj
Copy link
Author

bantonj commented Jun 3, 2016

I have these installed.

vagrant-s3auth (1.3.0)
vagrant-share (1.1.5, system)

@sethvargo
Copy link
Contributor

Hi @bantonj

It looks like vagrant-s3auth is pulling in aws-sdk, which pulls in aws-sdk-resources, which pulls in aws-sdk-core, which pulls in jmespath, which pulls in json_pure.

That error is coming from JSON Pure because it overwrites the global to_json method and changes the method airity. I don't know what Vagrant can do here, since pure_json is monkey_patching Ruby core.

@bantonj
Copy link
Author

bantonj commented Jun 6, 2016

Ah, thank you. Looks related to aws/aws-sdk-ruby#1150.

It looks like if you run into this issue you can uninstall and reinstall vagrant-s3auth and it will grab a newer version of jmespath which will fix the issue.

@sethvargo
Copy link
Contributor

Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants