ruby-syntax-tree/vscode-syntax-tree

Launches atlassian Sourcetree.app (naming collision)

counterbeing opened this issue · 5 comments

On my system, there is a binary present called stree which is for opening the sourcetree app. I know this app has been around for quite some time, and this isn't an invention of mine. I'm just imagining that there might be a lot of people with an stree binary already on their system.

Upon installing the app, it opened up the sourcetree app in five different directories on my system. I'm wondering if there's some way to detect the appropriate binary by default?

I've gotten it working by manually configuring the path to the gem, and it seems to be great! I just don't want this naming collision to possibly hamper adoption.

Thanks so much!
Cory

P.S. Just left the very first review in the VSCode marketplace ;)

Interesting @counterbeing! I had no idea that stree would end up conflicting.

We do supply the ability to specify the path, but I agree that that's not a great default experience. I'm thinking we could probably inspect the PATH environment variable ourselves and do something smart. For example, we could find all of the path entries that contain "ruby" in the name.

Try something for me. If you run the following program, does path get set to the right executable?

path =
  ENV["PATH"].split(":").detect do |directory|
    executable = File.join(directory, "stree")
    break executable if directory.include?("ruby") && File.exists?(executable)
  end

@counterbeing I opened up a PR I think will fix this, but want to verify this first, so let me know if you get a chance to run that.

That does appear to return a path!

❯ irb
irb(main):001:0* path =
irb(main):002:1*   ENV["PATH"].split(":").detect do |directory|
irb(main):003:1*     executable = File.join(directory, "stree")
irb(main):004:1*     break executable if directory.include?("ruby") && File.exists?(executable)
irb(main):005:0>   end
=> "/Users/cory/.asdf/installs/ruby/3.0.3/bin/stree"

I suppose the other thing worth noting is that I'm running my ruby under asdf as my version manager. But, yes, this appears to work. This shell was running a version of ruby that actually didn't have syntax_tree installed, and I got nil, which seems like expected behavior. Then I installed a copy of the gem in this ruby version, and it popped out as expected.

This should be out in v0.5.0!