Daniel Grimes
Daniel Grimes

Reputation: 333

On "bundle open <gemname>": EDITOR environment variable failing? (Windows)

I'm working in Windows 10 on a rails project and want to open up the devise gem to have a look. I'm running bundle open devise, which gives me the following

C:\Users\MyName\Documents\MyRailsProj>bundle open devise
Could not run 'C:Program FilesMicrosoft VS CodeCode.exe C:/Ruby22/lib/ruby/gems/2.2.0/gems/devise-4.4.1'

I've set the environment variable EDITOR to C:\Program Files\Microsoft VS Code\Code.exe in my system, which is the correct location of VS Code on my system. I've also tried setting it to point to sublime3, which has the same result.

I'm guessing I've just set this variable incorrectly, but I don't know how bundle open expects the EDITOR or BUNDLER_EDITOR to be set other than to the path of the program I want to use to open the gem. Any ideas why I can't open the gem?

edit:

I can totally just use bundle show devise so see the gem's location and go find and open it in vs code all I want, but I do also want to know how to use the EDITOR environment variable properly, so I think the question still has merit if anyone has any ideas.

Upvotes: 1

Views: 1692

Answers (1)

Ira Casper
Ira Casper

Reputation: 46

It looks like bundle is treating the environment variable as an escaped string, and so all the path separators are being lost. In addition, it also might not be handling spaces correctly.

However, you might not need the path at all. If you can open the editor just by typing "Code" at a command prompt, just set EDITOR to

code

Otherwise, instead of setting it to C:\Program Files\Microsoft VS Code\Code.exe

try

C:\\Program\ Files\\Microsoft\ VS\ Code\\Code.exe

or

"C:/Program Files/Microsoft VS Code/Code.exe"

Upvotes: 3

Related Questions