Process hangs while running ruby formatter(stree) as external tool Follow
There is a new ruby formatter in town called syntax_tree. I'm attempting to use its write cli : https://github.com/ruby-syntax-tree/syntax_tree#write
It works fine in my shell:
❯ bundle exec stree write ./spec/features/foo.rb
❯ stree write ./spec/features/foo.rb
❯ 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.
Please sign in to leave a comment.
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
Good thought, but still no luck. External tool hangs, but works fine in a run tab:
Shell script run configuration:
Thank you for trying it. Could you please specify your IDE's version, is it on the latest one?
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
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
Thank you for trying. Could you please check also the following command in the Terminal (that should be closer to conditions of External tool):
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.
Sounds like the root cause here was a broken version of syntax tree: https://github.com/ruby-syntax-tree/syntax_tree/issues/159.