Process hangs while running ruby formatter(stree) as external tool

There is a new ruby formatter in town called syntax_tree. I'm attempting to use its write cli :

It works fine in my shell:
❯ bundle exec stree write ./spec/features/foo.rb
./spec/features/foo.rb 2ms

❯ stree write ./spec/features/foo.rb
./spec/features/foo.rb 2ms

❯ which stree

There isn't a plugin, so I'm attempting to hook it up as an external tool:


When I run the tool though, it just opens a run tab, shows `/Users/me/.rbenv/shims/stree write /Users/me/foos/spec/foo.rb`, then just hangs and I have to ctrl+C to kill it. Nothing gets formatted. Is there something I'm missing? If I replace stree with echo under program, things work fine and it doesn't hang.



Just to be sure, does the command work if you run it the way it's run by IDE?


I'm not sure if this is what you mean, but if I copy the same command from the run tab and paste it inside of a Terminal in RubyMine to run it, it works fine.


This may be caused by running rbenv ruby without specifying the version. Could you please try changing the command so that 


is passed before the command? In addition, please try running the same command from the Run tab but in

/bin/bash -c 'command'



Good thought, but still no luck. External tool hangs, but works fine in a run tab:

Shell script run configuration: 

run tab:
❯ /bin/zsh -c " export RBENV_VERSION=3.1.2 && /Users/me/.rbenv/shims/stree write /Users/me/foo.rb "
/Users/me/foo.rb 18ms


External tool:

/bin/zsh -c " export RBENV_VERSION=3.1.2 && /Users/me/.rbenv/shims/stree write /Users/me/foo.rb "

# hangs

Thank you for trying it. Could you please specify your IDE's version, is it on the latest one?


RubyMine 2022.1.2

Build #RM-221.5787.34, built on June 1, 2022


I've tried to reproduce it in RubyMine 2022.3 EAP with the following configuration but didn't manage to (meaning, it works fine). Could you please try configuring it the same way?


Updated RubyMine and used the same settings. Still hangs. I'm on MacOS v12.4.

Replacing /usr/bin/env with `cat` works as expected. Not sure whats going on. Are there any logs I can look at?


Just to be sure, did you update to 2022.3 EAP? Could you please attach a screenshot of your External tool as it looks now?

In addition, please try running that command and piping the output to the file like

command ... > result.txt

and attach the content of that file. 


Looks like I'm on 2022.2.3, not .3... Is .3 a development build? Check for updates says I'm on latest.


Redirecting to a file doesn't appear to be creating the file at all. I also tried the following, and I got an empty file for stree2.out, but no stree3.out(same with &>): 


Can you please try redirecting it not via External tool, but via Terminal?


Yep that worked

❯ /bin/zsh -c " export RBENV_VERSION=3.1.2 && /Users/gm/.rbenv/shims/stree write /Users/gm/foo.rb  > /tmp/stree2.out" > /tmp/stree3.out

❯ cat /tmp/stree2.out
/Users/gm/foo.rb 1ms


Thank you for trying. Could you please check also the following command in the Terminal (that should be closer to conditions of External tool):

/bin/zsh -c " export RBENV_VERSION=3.1.2 && /Users/gm/.rbenv/shims/stree write /Users/gm/foo.rb" >output.txt 2>error.txt </dev/null

Good suggestion. It appears that passing an input seems to be breaking things. It doesn't hang, but it no longer works either. Looks like when you pass it in an input, it tries to format the input rather than the files listed after write. I'll keep playing and see if I can come up with a command which doesn't let the input pass through to stree...


I struggled a bit trying to get redirection or piping to work, but I eventually got something to going by using a custom script and writing to a tmp file. Not ideal, but its fast enough and gets the job done.

❯ cat /usr/local/bin/fstree
export RBENV_VERSION=3.1.2

/bin/zsh -c "/Users/gm/.rbenv/shims/stree format <$1  &> /tmp/formatted.txt"
mv /tmp/formatted.txt $1


Sounds like the root cause here was a broken version of syntax tree: 


Please sign in to leave a comment.