brentd / xray-rails

☠️ A development tool that reveals your UI's bones
MIT License
1.22k stars 79 forks source link

Getting xray-rails to work with Sublime Text 3 #34

Closed johnkferguson closed 10 years ago

johnkferguson commented 10 years ago

I've been having trouble getting xray-rails to open files using Sublime Text 3.

I have my `~/.xrayconfig file defined as follows:


---
:editor: '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'

I'm not sure why it won't open files as I can open files with Sublime from the command line by running the following command: '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' name_of_file

I'm pretty baffled on why it won't work with xray-rails. The only other piece of relevant information that I can think of is that I have oh-my-zsh installed on my machine.

Any ideas on how to get this to work or what I could be doing wrong?

Thanks a lot.

brentd commented 10 years ago

I can't think of any reason either off the top of my head. Xray uses Open3 to open the file, so you could try this in IRB:

require 'open3'
Open3.capture3("/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "README.md")

Give that a go and let me know if it works.

johnkferguson commented 10 years ago

Yea, the above command works. That's weird. It still doesn't open a view within Sublime when I click on it in the browser.

brentd commented 10 years ago

Still baffled by this. My gut feeling is that the space in the path isn't being stored in the YAML file correctly, but it seems fine from what you pasted.

Could you try using the cog icon in xray's UI to set the path and see if that makes a difference?

juhguu commented 9 years ago

I have the same problem. Any idea?

labocho commented 9 years ago

Do you use tmux with OSX? I had same problem.

$ tmux new-window irb
require "open3"
Open3.capture3('/usr/local/bin/subl /etc/profile')
# Activate SublimeText. But does not open file

And fixed by using reattach-to-user-namespace

$ tmux new-window 'reattach-to-user-namespace irb'
require "open3"
Open3.capture3('/usr/local/bin/subl /etc/profile')
# Open file
brentd commented 9 years ago

Ah, I see. I personally do not use tmux, precisely because of the env issues like this it causes :)

Is there anything we can add to xray to workaround this?

deepakmahakale commented 6 years ago

If you use sublime simply create symlink for subl to usr/local/bin/. As that is where xray search for subl https://github.com/brentd/xray-rails#configuration

 sudo ln -s /usr/bin/subl /usr/local/bin/subl

Or, You can just create a ~/.xrayconfig in root and add the following

:editor: '/usr/local/bin/subl'