Last active
December 10, 2023 20:00
-
-
Save pmarreck/2367908 to your computer and use it in GitHub Desktop.
Get Sublime Text 2 (or 3) to use your RVM ruby and bundle Gemfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get Sublime to use your rvm ruby... Change your ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.sublime-build | |
# (for ST3: ~/Library/Application Support/Sublime Text 3/Packages/User/Ruby.sublime-build) to this, replacing YOURUSERNAME. | |
# I am still looking to optimize this further... For example, avoiding hardcoding by using something like $HOME, although | |
# I have yet to get any form of that to work. | |
{ | |
"working_dir": "${project_path}", | |
"cmd": [ | |
"/Users/YOURUSERNAME/.rvm/bin/rvm-auto-ruby", "-Ilib:test", "$file" | |
], | |
// "path": "/Users/YOURUSERNAME/.rvm/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin", | |
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", | |
"selector": "source.ruby" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using
rvm-auto-ruby
is inefficient as it initializes the RVM environment on each invocation and has a noticeable performance impact.Here is my solution for Sublime Text 3 on MacOS (commands require superuser privileges):
Create file
/Applications/Sublime Text.app/Contents/MacOS/setenv.sh
with the contents of this gistchmod +x "/Applications/Sublime Text.app/Contents/MacOS/setenv.sh"
Edit
/Applications/Sublime Text.app/Contents/Info.plist
, changing theCFBundleExecutable
value tosetenv.sh
Force update the LaunchService database in the Terminal by using the lsregister command:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f '/Applications/Sublime Text.app'
(Re-)launch Sublime Text. Observe how the correct ruby (as set by rvm) invocations are almost instant within sublime :)
Bonus hint:
Invocations of various ruby executables (
bundle
,rspec
, etc.) are much faster when done viaruby -S <executable>
(at least for me on MacOS 10.12 with updated rubygems and rvm). Haven't really investigated why, but it sometimes saves up to one second...Try it yourself:
Hope this helps.