Ruby on Rails Tutorial - 5.26 - Sublime Text "Unable to save" new file "spec / support / utilities.rb"

I am using Sublime Text 2 following the guidance of Michael Hartley Ruby on Rails.

The specific part of the tutorial that I am referring to can be found at http://ruby.railstutorial.org/book/ruby-on-rails-tutorial (ctrl + F "Listing 5.26").

I can create a spec / support file. However, when I try to create the file spec / support / utilities.rb, I get the message "Unable to save files ~ / rails_projects / sample_app / spec / support / utilities.rb".

Does anyone know why this could be?

Someone on the Sublime Text forum seemed to have the same problem: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=8570&p=36922#p36922

+6
source share
6 answers

This problem sounds like the result of incorrect permissions or ownership of the folder. Change the directories ( cd ) so that you are outside the folder in which you create the .rb file and enter:

 ls -l 

This terminal command lists the permissions attached to all files / folders in this directory. If the root is specified as the owner of the folder, change its owner by typing:

 sudo chown YOUR_COMP_USER_NAME FOLDER_NAME/ 

Now you can save files from inside this folder.

+3
source

To diagnose this, first find out if there is a problem in Sublime or your file system:

  • Does this file already exist? Try to find it in your file system (without using Sublime).

  • Make sure you have permission to write to this file. Use "ls -la" on the command line to show file permissions.

  • Can you create and / or save this file using any other editor, for example TextMate or Notepad?

+1
source

The following exalted plugin fixed the Unable to save... error Unable to save... https://gist.github.com/3779601

+1
source

The folder specification / support does not exist and the sublime will not create the missing folder, so these are errors.

You just need to create the spec / support folder and then sublime will save the file.

I also highly recommend installing the AdvancedNewFile plugin (Video of his actions thanks to Jeffrey Way and NetTuts +) , which you can get directly from the Control package. If necessary, it creates files, parent folders, and if you try to create a file that already exists, it opens it instead.

0
source

This can happen if you try to create a file in a directory that does not currently exist. E.g. I was unable to save

~ / rails_projects / sample_app / app / views / shared / _error_messages.html.erb

via the "subl" command from the terminal because I was missing / shared / folder. Hope this helps.

0
source

so @knice almost had it, I ran into the same permission issue when starting my first rails project on mavericks.

as already mentioned, if you run ls -l, you will see your folder / files listed with their rights.

I solved this by changing the property recursively with the following command from outside my project directory

 sudo chown -Rv <your_username> <your_path_and_foldername> 

for example, if you are in your folder in the terminal, you should cd .. and then

 sudo chown -Rv username ruby_proj/ 

-R is for a recursive value that will be applied to all files and folders contained in the folder you specify, and v after it simply produces verbose output, showing you which permissions on the folder and file have been changed.

Hope this helps someone else.

0
source

Source: https://habr.com/ru/post/925276/


All Articles