3

I am using Windows Subsystem for Linux with Rails 5.2 and Sublime Text 3. When i do

EDITOR="subl --wait" rails credentials:edit

It says "New credentials encrypted and saved." but does not open the file to be edited with Sublime Text 3. Also when trying Visual Studio Code with

EDITOR="code --wait" rails credentials:edit

Visual Studio Code opens but it is empty.

I can only edit the file with VIM and the command EDITOR="vim" rails credentials:edit

The thing is i do not want to edit the file with vim. What is the problem so it does not open the file to be edited with Sublime or VS Code?

I am using Rails 5.2

Thanks a lot in advance

enter image description here

alext
  • 678
  • 1
  • 11
  • 25

4 Answers4

6

On macOS, you would run this command to edit the credentials in Sublime. When you are done, save and close the file in Sublime:

EDITOR="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -w" bin/rails credentials:edit
Sébastien Saunier
  • 1,787
  • 2
  • 19
  • 28
5

I am on windows 7x64 and stumbled upon this issue this morning.Solved it by adding atom to my system variable Path(so cmd & powershell & bash all know about it) and by adding powershell to my environment.I use separate environment for ruby & rails.

So now when I type set EDITOR=atom --wait && rails credentials:edit in cmd or

1st $env:EDITOR="atom --wait", 2nd rails credentials:editin powershell or

EDITOR="atom --wait" rails credentials:edit in bash,

I get the desired result wich is to open credentials and edit them :).. Hope this helps

PS. I didn't need to use --wait flag when setting the editor to subl or notepad! EDITOR is just a temporary variable for the current session, meaning for the cmd,powershell or bash window that is opened at the moment!

Goku San
  • 71
  • 5
1

By default Sublime Text Editor is not configured to be run directly from the command line. You're trying to set the EDITOR variable to "subl --wait", but the command line doesn't know what "subl" is! Try this post which goes into detail on setting up a "subl" alias for starting up sublime on the command line, then try again!

Open Sublime Text from Terminal in macOS

EDIT: Noticed you are on Ubuntu and not MacOS, but that post should still work as long as you're using bash, which is the default shell on Ubuntu.

jsanderlin
  • 154
  • 4
  • I did configure subl command in Terminal, so when i type subl it opens Sublime Text 3. Same thing as sublime happens with Atom, Notepad, Wordpad – alext Jun 25 '18 at 21:47
  • Noticed a typo in your VS Code example, you need a space between `code` and `--wait`, not a regular sublime user, but I did get it to work with Atom like this: `EDITOR="atom --wait" rails credentials:edit` – jsanderlin Jun 25 '18 at 21:51
  • i copied code --wait wrong. I am running it with code --wait. When i am trying to run it with Atom, i get same behavior with VS Code (empty file) – alext Jun 25 '18 at 22:27
  • Are you able to open Atom/Code from the terminal, i.e. `atom .` or `code .` to open the current directory? – jsanderlin Jun 25 '18 at 22:33
  • yes i am able to open Atom/Code from the terminal to current directory. – alext Jun 26 '18 at 07:39
0

I have succeeded my following this

 SET EDITOR="full_path to sublime"
 rails credentials:edit

after closing sublime only i am getting new credentials saved response.

Hope it helps

Ali Akbar
  • 370
  • 3
  • 9