52

I am trying to open up a gem in Sublime Text, unsuccessfully. I have Bundler installed. Here is what is happening.

In the command line:

$bundle open Devise
To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR

When I go to the Bundler website it says,

Open the source directory of the given bundled gem:

$ bundle open GEM

This opens the source directory of the provided GEM in your editor. For this to work the EDITOR or BUNDLER_EDITOR environment variable has to be set.

I am new to all of this. What are the specific steps to set my EDITOR or BUNDLER_EDITOR environment variables? I'm on a Mac, using Sublime Text.

Thank you.

3 Answers 3

67

Assuming you're using the bash shell, you'll want to edit either your ~/.bashrc or ~/.bash_profile with:

export EDITOR=<editor name>

Example, specifically for Sublime:

export EDITOR='subl -w'

See: Sublime OS X Command Line docs

5
  • For my version of Sublime Text 2, I had to use export EDITOR='sublime -w' Commented Nov 25, 2014 at 2:26
  • I got an error when using the -w flag. Worked fine for me without it (Sublime 2)
    – sixty4bit
    Commented Jun 5, 2015 at 15:33
  • If you want to open it in TextMate, run which mate and then use that value for the EDITOR variable. Commented Oct 16, 2021 at 4:35
  • The instructions there require setting up a ~/bin folder and subl link, which I was too lazy to do. This works out-of-the-box: export EDITOR='"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" -w' Commented Dec 2, 2022 at 22:37
  • 1
    For VSCode you can do: export EDITOR='code --wait' Commented Apr 27, 2023 at 12:28
13

As @sixty4bit mentioned,

export EDITOR='subl -w' 

will raise error for command bundle open gem_name

But if I use

export EDITOR='subl'

Then sublime will not write commit message to git commit correctly for command git commit.

So I think it is better to use this config:

export EDITOR="subl -w"
export BUNDLER_EDITOR="subl"
2

Example of adding a Visual Studio Code editor:

export EDITOR="code"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.