# Knife node show json format squished

**URL:** <https://discourse.chef.io/t/knife-node-show-json-format-squished/4084>\
**Category:** Chef Infra (archive)\
**Created:** [June 13, 2013, 1:35am UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084 "2013-06-13T01:35:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kallen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallen/32/1049_2.png) [@Kallen](https://discourse.chef.io/u/Kallen)\
**Post date:** [June 13, 2013, 1:35am UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084/1 "2013-06-13T01:35:41Z")

</div>

Recently the node output I see went from a nice “fully-expanded” view of the  
json to the json being not expanded, being “squished”… for lack of better  
phrasing.

Does anyone happen to know what happened, or how to get the output back to  
fully-expanded?

$ knife node show [db01.stg.cherryporkleftovers.com](http://db01.stg.cherryporkleftovers.com) -Fj -l  
{  
“name”: “[db01.stg.cherryporkleftovers.com](http://db01.stg.cherryporkleftovers.com)”,  
“chef\_environment”: “staging1”,  
“run\_list”: [“role[base]”,“role[database]”],  
“normal”: {“repo”:{“epel”:{“key”:“RPM-GPG-KEY-EPEL-6”},“percona”:{“key”:“RPM-GPG-KEY-percona”},“centos”:{“key”:“RPM-GPG-KEY-CentOS-5”,…snip-the-squish  
"default": {“s3cmd”:{“users”:[“root”],“userlist”:[“foo”,“baz”]},“boundary”:{“bprobe”:…snip-the-squish  
snip

I’m not exactly sure what changed in my dev environment, and when it did.  
FWIW I did try downgrading my chef 10.26.0 to 10.24.0 within my rvm, but that  
changed nothing.

06/12 17:34[zahadum chefdev] which ruby /home/kallen/.rvm/rubies/ruby-1.9.3-p429/bin/ruby 06/12 18:33[zahadum chefdev] gem list chef

\*\*\* LOCAL GEMS \*\*\*

chef (10.26.0, 10.24.0)

---

<div class="post-metadata">

**Author:** ![John\_Alberts](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/john_alberts/32/293_2.png) [@John\_Alberts](https://discourse.chef.io/u/John_Alberts)\
**Post date:** [June 13, 2013, 3:28am UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084/2 "2013-06-13T03:28:56Z")

</div>

me too! I've noticed this recently too. I'm not really sure when it  
started happening, so I can't really offer any details that would be  
helpful. I'd love to hear if you find a solution.

-bash-3.2# which ruby  
/usr/local/bin/ruby  
-bash-3.2# ruby -v  
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86\_64-linux]  
-bash-3.2# gem list chef

\*\*\* LOCAL GEMS \*\*\*

chef (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
chef-expander (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
chef-server (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
chef-server-api (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
chef-server-webui (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4,  
0.10.0)  
chef-solr (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)

Yes, yes, I know. I should clean these old gems up. 🙂

John

On Wed, Jun 12, 2013 at 8:35 PM, [kallen@groknaut.net](mailto:kallen@groknaut.net) wrote:

> Recently the node output I see went from a nice "fully-expanded" view of  
> the  
> json to the json being not expanded, being "squished"... for lack of better  
> phrasing.
> 
> Does anyone happen to know what happened, or how to get the output back to  
> fully-expanded?
> 
> $ knife node show [db01.stg.cherryporkleftovers.com](http://db01.stg.cherryporkleftovers.com) -Fj -l  
> {  
> "name": "[db01.stg.cherryporkleftovers.com](http://db01.stg.cherryporkleftovers.com)",  
> "chef\_environment": "staging1",  
> "run\_list": ["role[base]","role[database]"],  
> "normal":  
> {"repo":{"epel":{"key":"RPM-GPG-KEY-EPEL-6"},"percona":{"key":"RPM-GPG-KEY-percona"},"centos":{"key":"RPM-GPG-KEY-CentOS-5",..snip-the-squish  
> "default":  
> {"s3cmd":{"users":["root"],"userlist":["foo","baz"]},"boundary":{"bprobe":..snip-the-squish  
> snip
> 
> I'm not exactly sure what changed in my dev environment, and when it did.  
> FWIW I did try downgrading my chef 10.26.0 to 10.24.0 within my rvm, but  
> that  
> changed nothing.
> 
> 06/12 17:34[zahadum chefdev]$ which ruby  
> /home/kallen/.rvm/rubies/ruby-1.9.3-p429/bin/ruby  
> 06/12 18:33[zahadum chefdev]$ gem list chef
> 
> \*\*\* LOCAL GEMS \*\*\*
> 
> chef (10.26.0, 10.24.0)

--  
John Alberts

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [June 13, 2013, 3:46pm UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084/3 "2013-06-13T15:46:07Z")

</div>

On Wednesday, June 12, 2013 at 8:28 PM, John Alberts wrote:

> me too! I've noticed this recently too. I'm not really sure when it started happening, so I can't really offer any details that would be helpful. I'd love to hear if you find a solution.
> 
> -bash-3.2# which ruby  
> /usr/local/bin/ruby  
> -bash-3.2# ruby -v  
> ruby 1.9.2p180 (2011-02-18 revision 30909) [x86\_64-linux]  
> -bash-3.2# gem list chef
> 
> \*\*\* LOCAL GEMS \*\*\*
> 
> chef (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
> chef-expander (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
> chef-server (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
> chef-server-api (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
> chef-server-webui (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)  
> chef-solr (10.26.0, 10.24.4, 10.18.0, 10.16.2, 0.10.8, 0.10.4, 0.10.0)
> 
> Yes, yes, I know. I should clean these old gems up. 🙂
> 
> John
> 
> On Wed, Jun 12, 2013 at 8:35 PM, \<[kallen@groknaut.net](mailto:kallen@groknaut.net) ([mailto:kallen@groknaut.net](mailto:kallen@groknaut.net))\> wrote:
> 
> > Recently the node output I see went from a nice "fully-expanded" view of the  
> > json to the json being not expanded, being "squished"... for lack of better  
> > phrasing.
> > 
> > Does anyone happen to know what happened, or how to get the output back to  
> > fully-expanded?

I can't think of any changes to the relevant code in Chef recently that would cause this. The code path is:

Knife uses a presenter object to convert your data to a string: [https://github.com/opscode/chef/blob/master/lib/chef/knife/core/generic\_presenter.rb#L81](https://github.com/opscode/chef/blob/master/lib/chef/knife/core/generic_presenter.rb#L81)

Chef adds some options for nesting levels, then calls JSON.pretty\_generate [chef/lib/chef/json\_compat.rb at main · chef/chef · GitHub](https://github.com/opscode/chef/blob/master/lib/chef/json_compat.rb#L105)

I have 11.4.2 installed locally and it's correctly "pretty printing" the json, so there must be something different in your setup.

--  
Daniel DeLeo

---

<div class="post-metadata">

**Author:** ![Steven\_Danna](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/steven_danna/32/195_2.png) [@Steven\_Danna](https://discourse.chef.io/u/Steven_Danna)\
**Post date:** [June 13, 2013, 3:57pm UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084/4 "2013-06-13T15:57:48Z")

</div>

On 6/12/13 8:28 PM, John Alberts wrote:

> me too! I've noticed this recently too. I'm not really sure when it  
> started happening, so I can't really offer any details that would be  
> helpful. I'd love to hear if you find a solution.

One possibility is that you are using a plugin that loads a gem which is  
monkey-patching some core class, thus affecting the pretty-printing.

Are you using any custom/non-opscode plugin?

Sincerely,

Steven

--  
Steven Danna  
Systems Engineer, Opscode, Inc  
GPG Key: [http://stevendanna.github.com/downloads/code/public.key](http://stevendanna.github.com/downloads/code/public.key)

---

<div class="post-metadata">

**Author:** ![Kallen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallen/32/1049_2.png) [@Kallen](https://discourse.chef.io/u/Kallen)\
**Post date:** [June 13, 2013, 6:19pm UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084/5 "2013-06-13T18:19:25Z")

</div>

On Thu, 13 Jun 2013, Steven Danna wrote:

> On 6/12/13 8:28 PM, John Alberts wrote:
> 
> > me too! I've noticed this recently too. I'm not really sure when it  
> > started happening, so I can't really offer any details that would be  
> > helpful. I'd love to hear if you find a solution.
> 
> One possibility is that you are using a plugin that loads a gem which is  
> monkey-patching some core class, thus affecting the pretty-printing.
> 
> Are you using any custom/non-opscode plugin?
> 
> Sincerely,
> 
> Steven

For the most part, I had been using rvm ruby 1.9.2. Recently I installed  
ruby 1.9.3 via rvm. I just tested this in my 1.9.2, and the json pretty  
print is as I like it, unsquished:

$ which ruby  
~/.rvm/rubies/ruby-1.9.2-p290/bin/ruby

$ gem list chef

\*\*\* LOCAL GEMS \*\*\*

chef (10.24.0, 10.16.2)

Wrt custom/non-opscode knife plugins, for good measure, I moved aside my  
~/.chef/plugins dir, reran ruby 1.9.3 test, and still got squished json.

kallen

---

<div class="post-metadata">

**Author:** ![Joshua\_Miller](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshua_miller/32/212_2.png) [@Joshua\_Miller](https://discourse.chef.io/u/Joshua_Miller)\
**Post date:** [June 14, 2013, 5:50am UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084/6 "2013-06-14T05:50:29Z")

</div>

We are seeing this at my work also with the omnibus install.  
—

On Thu, Jun 13, 2013 at 11:19 AM, null [kallen@groknaut.net](mailto:kallen@groknaut.net) wrote:

> On Thu, 13 Jun 2013, Steven Danna wrote:
> 
> > On 6/12/13 8:28 PM, John Alberts wrote:
> > 
> > > me too! I've noticed this recently too. I'm not really sure when it  
> > > started happening, so I can't really offer any details that would be  
> > > helpful. I'd love to hear if you find a solution.
> > 
> > One possibility is that you are using a plugin that loads a gem which is  
> > monkey-patching some core class, thus affecting the pretty-printing.
> > 
> > Are you using any custom/non-opscode plugin?
> > 
> > Sincerely,
> > 
> > Steven  
> > For the most part, I had been using rvm ruby 1.9.2. Recently I installed  
> > ruby 1.9.3 via rvm. I just tested this in my 1.9.2, and the json pretty  
> > print is as I like it, unsquished:  
> > $ which ruby  
> > ~/.rvm/rubies/ruby-1.9.2-p290/bin/ruby  
> > $ gem list chef  
> > \*\*\* LOCAL GEMS \*\*\*  
> > chef (10.24.0, 10.16.2)  
> > Wrt custom/non-opscode knife plugins, for good measure, I moved aside my  
> > ~/.chef/plugins dir, reran ruby 1.9.3 test, and still got squished json.  
> > kallen

---

<div class="post-metadata">

**Author:** ![Kallen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallen/32/1049_2.png) [@Kallen](https://discourse.chef.io/u/Kallen)\
**Post date:** [July 9, 2013, 12:38am UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084/7 "2013-07-09T00:38:51Z")

</div>

Squish is due to this problem with knife-spork:

> <https://github.com/jonlives/knife-spork/issues/66>
>
> First and foremost, thanks for this life-changing tool. Sincerely: I'm a better… Dad because of Knife-Spork! :-) The issue:
> 
> Basically, I have all json laid out in pretty-print format as it's much easier to manage, but anytime I run knife spork and it touches my json files, the pretty print formatting gets blown away. Possibly just a user issue on my part so sorry if I'm wasting your time. It has become quite a source of frustration in an otherwise peaceful knife-spork world.
> 
> Here's a link to a Gist that demonstrates the problem: https://gist.github.com/toddmichael/407b574e3b6662e0bbd2. 
> 
> Appreciate the help. Cheers!

If I remove the knife-spork gem/plugin, my json output is pretty again.

kallen

On Thu, 13 Jun 2013, Joshua Miller wrote:

> We are seeing this at my work also with the omnibus install.  
> ???
> 
> On Thu, Jun 13, 2013 at 11:19 AM, null [kallen@groknaut.net](mailto:kallen@groknaut.net) wrote:
> 
> > On Thu, 13 Jun 2013, Steven Danna wrote:
> > 
> > > On 6/12/13 8:28 PM, John Alberts wrote:
> > > 
> > > > me too! I've noticed this recently too. I'm not really sure when it  
> > > > started happening, so I can't really offer any details that would be  
> > > > helpful. I'd love to hear if you find a solution.
> > > 
> > > One possibility is that you are using a plugin that loads a gem which is  
> > > monkey-patching some core class, thus affecting the pretty-printing.
> > > 
> > > Are you using any custom/non-opscode plugin?
> > > 
> > > Sincerely,
> > > 
> > > Steven  
> > > For the most part, I had been using rvm ruby 1.9.2. Recently I installed  
> > > ruby 1.9.3 via rvm. I just tested this in my 1.9.2, and the json pretty  
> > > print is as I like it, unsquished:  
> > > $ which ruby  
> > > ~/.rvm/rubies/ruby-1.9.2-p290/bin/ruby  
> > > $ gem list chef  
> > > \*\*\* LOCAL GEMS \*\*\*  
> > > chef (10.24.0, 10.16.2)  
> > > Wrt custom/non-opscode knife plugins, for good measure, I moved aside my  
> > > ~/.chef/plugins dir, reran ruby 1.9.3 test, and still got squished json.  
> > > kallen

---

<div class="post-metadata">

**Author:** ![jdunn](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jdunn/32/1800_2.png) [@jdunn](https://discourse.chef.io/u/jdunn)\
**Post date:** [July 9, 2013, 12:42am UTC](https://discourse.chef.io/t/knife-node-show-json-format-squished/4084/8 "2013-07-09T00:42:07Z")

</div>

I don't have knife-spork installed but I also see this issue. Strange.

- Julian

On Mon, Jul 8, 2013 at 8:38 PM, [kallen@groknaut.net](mailto:kallen@groknaut.net) wrote:

> Squish is due to this problem with knife-spork:  
> [knife-spork json file updates undo pretty print format · Issue #66 · jonlives/knife-spork · GitHub](https://github.com/jonlives/knife-spork/issues/66)
> 
> If I remove the knife-spork gem/plugin, my json output is pretty again.
> 
> kallen
