Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot commit - The directory '~/.emacs.d/server' is unsafe #41

Closed
ghost opened this issue Oct 19, 2017 · 17 comments
Closed

Cannot commit - The directory '~/.emacs.d/server' is unsafe #41

ghost opened this issue Oct 19, 2017 · 17 comments
Labels
bug emacs A bug in Emacs that affects us

Comments

@ghost
Copy link

ghost commented Oct 19, 2017

Hello,

As stated in the title I cannot commit my staged changes. I get the message:
The directory '~/.emacs.d/server' is unsafe

Output of magit-version:
Magit 2.11.0, Git 2.14.2.windows.3, Emacs 25.3.1, windows-nt

Output of with-editor-debug:

with-editor: c:/Users/atabbern/AppData/Roaming/.emacs.d/elpa/with-editor-2.7.0/with-editor.el
emacs: c:/emacs-25.3-i686/bin/emacs (25.3.1)
system:
  system-type: windows-nt
  system-configuration: i686-w64-mingw32
  system-configuration-options: --host=i686-w64-mingw32 --without-dbus --without-compress-install 'CFLAGS=-static -O2 -g3'
server:
  server-running-p: nil
  server-process: nil
  server-use-tcp: t
  server-name: server
  server-socket-dir: nil
    WARNING: not an accessible directory
  server-auth-dir: ~\.emacs.d\server\
with-editor-emacsclient-executable:
 value:   c:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
 default: c:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
 funcall: c:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
path:
  $PATH: "C:\\Program Files\\ImageMagick-7.0.7-Q16;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Windows\\CCM;C:\\windows\\CCM;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\windows\\CCM;C:\\windows\\CCM;C:\\Program Files\\Microsoft\\Web Platform Installer\\;C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET Web Pages\\v1.0\\;C:\\Program Files (x86)\\Windows Kits\\8.0\\Windows Performance Toolkit\\;C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\110\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\120\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\120\\Tools\\Binn\\ManagementStudio\\;C:\\Program Files (x86)\\Microsoft SQL Server\\120\\DTS\\Binn\\;C:\\apps\\FME\\;C:\\Python27\\ArcGIS10.2\\;C:\\emacs-25.3-i686\\bin;C:\\Program Files\\PostgreSQL\\10\\bin;C:\\Program Files\\PostgreSQL\\Apache\\apache\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Windows\\CCM;C:\\windows\\CCM;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\windows\\CCM;C:\\windows\\CCM;C:\\Program Files\\Microsoft\\Web Platform Installer\\;C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET Web Pages\\v1.0\\;C:\\Program Files (x86)\\Windows Kits\\8.0\\Windows Performance Toolkit\\;C:\\Program Files\\Microsoft SQL Server\\110\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\110\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Pro"
  exec-path: (c:/Program Files/ImageMagick-7.0.7-Q16 C:/Program Files (x86)/Intel/iCLS Client/ C:/Program Files/Intel/iCLS Client/ C:/windows/system32 C:/windows C:/windows/System32/Wbem C:/windows/System32/WindowsPowerShell/v1.0/ C:/Program Files/Intel/Intel(R) Management Engine Components/DAL C:/Program Files/Intel/Intel(R) Management Engine Components/IPT C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT C:/Windows/CCM C:/windows/CCM C:/Program Files/Intel/WiFi/bin/ C:/Program Files/Common Files/Intel/WirelessCommon/ C:/windows/CCM C:/windows/CCM C:/Program Files/Microsoft/Web Platform Installer/ C:/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/ C:/Program Files (x86)/Windows Kits/8.0/Windows Performance Toolkit/ C:/Program Files/Microsoft SQL Server/110/Tools/Binn/ C:/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn/ C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ C:/Program Files/Microsoft SQL Server/120/Tools/Binn/ C:/Program Files/Microsoft SQL Server/120/DTS/Binn/ C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio/ C:/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn/ C:/apps/FME/ C:/Python27/ArcGIS10.2/ C:/emacs-25.3-i686/bin C:/Program Files/PostgreSQL/10/bin C:/Program Files/PostgreSQL/Apache/apache/bin C:/Program Files/Git/cmd C:/Program Files (x86)/Intel/iCLS Client/ C:/Program Files/Intel/iCLS Client/ C:/windows/system32 C:/windows C:/windows/System32/Wbem C:/windows/System32/WindowsPowerShell/v1.0/ C:/Program Files/Intel/Intel(R) Management Engine Components/DAL C:/Program Files/Intel/Intel(R) Management Engine Components/IPT C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT C:/Windows/CCM C:/windows/CCM C:/Program Files/Intel/WiFi/bin/ C:/Program Files/Common Files/Intel/WirelessCommon/ C:/windows/CCM C:/windows/CCM C:/Program Files/Microsoft/Web Platform Installer/ C:/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/ C:/Program Files (x86)/Windows Kits/8.0/Windows Performance Toolkit/ C:/Program Files/Microsoft SQL Server/110/Tools/Binn/ C:/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn/ C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ C:/Program Files/Microsoft SQL Server/120/Tools/Binn/ C:/Pro c:/emacs-25.3-i686/libexec/emacs/25.3/i686-w64-mingw32)
  with-editor-emacsclient-path:
    c:/emacs-25.3-i686/bin (t)
      c:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
    c:/Program Files/ImageMagick-7.0.7-Q16 (t)
    C:/Program Files/Microsoft SQL Server/120/DTS/Binn/ (nil)
    C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio/ (nil)
    C:/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn/ (nil)
    C:/apps/FME/ (t)
    C:/Python27/ArcGIS10.2/ (t)
    C:/emacs-25.3-i686/bin (t)
      C:/emacs-25.3-i686/bin/emacsclient.exe (25.3)
    C:/Program Files/PostgreSQL/10/bin (t)
    C:/Program Files/PostgreSQL/Apache/apache/bin (t)
    C:/Program Files/Git/cmd (t)
    C:/Program Files (x86)/Intel/iCLS Client/ (t)
    C:/Program Files/Intel/iCLS Client/ (t)
    C:/windows/system32 (t)
    C:/windows (t)
    C:/windows/System32/Wbem (t)
    C:/windows/System32/WindowsPowerShell/v1.0/ (t)
    C:/Program Files/Intel/Intel(R) Management Engine Components/DAL (t)
    C:/Program Files/Intel/Intel(R) Management Engine Components/IPT (t)
    C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL (t)
    C:/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT (t)
    C:/Windows/CCM (t)
    C:/Program Files/Intel/WiFi/bin/ (nil)
    C:/Program Files/Common Files/Intel/WirelessCommon/ (nil)
    C:/windows/CCM (t)
    C:/Program Files/Microsoft/Web Platform Installer/ (nil)
    C:/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/ (nil)
    C:/Program Files (x86)/Windows Kits/8.0/Windows Performance Toolkit/ (nil)
    C:/Program Files/Microsoft SQL Server/110/Tools/Binn/ (t)
    C:/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn/ (nil)
    C:/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ (nil)
    C:/Program Files/Microsoft SQL Server/120/Tools/Binn/ (nil)
    C:/Pro (nil)
    c:/emacs-25.3-i686/libexec/emacs/25.3/i686-w64-mingw32 (t)

Any help is greatly appreciated. Thanks!

@tarsius tarsius closed this as completed Oct 19, 2017
@npostavs
Copy link
Member

Could you post the result of evaluating the following please:

(list :attrs (file-attributes "~/.emacs.d/server" 'integer)
      :uid (user-uid)
      :modes (file-modes "~/.emacs.d/server"))

@tarsius tarsius reopened this Oct 19, 2017
@tarsius
Copy link
Member

tarsius commented Oct 19, 2017

Also see magit/magit#3148.

@npostavs
Copy link
Member

@tarsius that one is about macOS, this one is Windows. Probably not actually related.

@tarsius
Copy link
Member

tarsius commented Oct 19, 2017

Okay! Already reopened.

@ghost
Copy link
Author

ghost commented Oct 19, 2017

I do not see anything when I evaluate:

(list :attrs (file-attributes "~/.emacs.d/server" 'integer)
      :uid (user-uid)
      :modes (file-modes "~/.emacs.d/server"))

Should i be looking in a specific place?

@npostavs
Copy link
Member

I meant you should paste that in *scratch*, and then hit C-M-x (that is Ctrl+Alt+X) when point is in that expression.

But actually, maybe this is just another case of magit/magit#1587? So try the solution in https://stackoverflow.com/questions/885793/emacs-error-when-calling-server-start

@ghost
Copy link
Author

ghost commented Oct 19, 2017

Yes i posted that in scratch and did M-x eval-buffer. Nothing happened. OK I will check out your suggestion.

@tarsius
Copy link
Member

tarsius commented Oct 19, 2017

Yes i posted that in scratch and did M-x eval-buffer. Nothing happened.

All expressions in the buffer (in this case likely just that one expression) were evaluated. However that command does not print the output of all evaluated expressions because there could be thousands of them. Instead use C-M-x as suggested.

@ghost
Copy link
Author

ghost commented Oct 19, 2017

Here's that output:

image

@ghost
Copy link
Author

ghost commented Oct 19, 2017

OK so I tried following the instructions at the stack overflow link. That seems to be on the right track. I created the folder at C:\Users[username].emacs.d\server. By default it had administrator as owner. The problem is that I am unable to change the owner to [computer name][username] as I am on my workplace network. If I look under my computer name when I try to change the owner my username simply doesn't exist in the list and is rejected. The only thing I can change it to is [username]@[worknetwork]. I tried doing this, restarting emacs and then comitting again and I get the same error.

@npostavs npostavs added the bug emacs A bug in Emacs that affects us label Oct 19, 2017
@npostavs
Copy link
Member

Hmm, could you post the output of that command again, now that you've changed the ownership? You can copy the text from the *Messages* buffer rather screenshotting.

Does the takeown solution work any better?

@ghost
Copy link
Author

ghost commented Oct 19, 2017

Here is the output:
(:attrs (t 1 544 513 (23015 58033 0 0) (23015 58033 0 0) (23015 58033 0 0) 0 "drwxrwxrwx" t (5376 6 . 61509) (58962 . 30162)) :uid 65156 :modes 511)

Unfortunately, the takeown solution results in the same error. It successfully changes the ownership of that folder to [myworkdomain] / [username] as opposed to [mycomputername] / [username].

@npostavs
Copy link
Member

Looks like the ownership didn't change at all from Emacs point of view (it's in position 2 (counting from 0) in the return from file-attributes), 544 both times. According to a comment in server-ensure-safe-dir, 544 is the "Administrators" id.

I guess you're stuck with suppressing the error, as suggested in https://stackoverflow.com/a/17069276

@ghost
Copy link
Author

ghost commented Oct 19, 2017

Adding this to my .emacs worked like a charm!

(defadvice server-ensure-safe-dir (around
my-around-server-ensure-safe-dir
activate)
"Ignores any errors raised from server-ensure-safe-dir"
(ignore-errors ad-do-it))

Thanks!
P.S. Is there any downsides that you're aware of to ignoring any errors raised from server-ensure-safe-dir?

@ghost ghost closed this as completed Oct 19, 2017
@npostavs
Copy link
Member

P.S. Is there any downsides that you're aware of to ignoring any errors raised from server-ensure-safe-dir?

I think it means anyone with write access to c:/Users/[username]/AppData/Roaming/.emacs.d/server can control your emacs. Or maybe read access? Not actually sure about the details. There is a long and confusing thread about this at Emacs Bug#865. Eli did say

Btw, I think erroring out if what server-ensure-safe-dir wants to see
is not true is too draconian. It may be better to ask, at least an an
optional behavior.

So ignoring the errors is probably not completely crazy.

@ghost
Copy link
Author

ghost commented Oct 19, 2017

Ahhhh. I actually just discovered that there is a .emacs.d folder at C:\Users \ [username] as well as another .emacs.d folder at C:\Users\ [username] \ AppData\Roaming\

I had previously been changing the owner of the first one (at C:\Users \ [username] \ .emacs.d\server)
I just changed the owner for the one in AppData to [username] @ [worknetwork] and it now works without changing my .emacs file!
So I no longer have to ignore the errors which is much better.
Thanks again!

@npostavs
Copy link
Member

Aha, that would explain why Emacs showed the ownership not being changed.

Note to self: when troubleshooting this next time, include the full w32 filename as one of the things to check.

craigmac pushed a commit to craigmac/emacs.d that referenced this issue Jan 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug emacs A bug in Emacs that affects us
Development

No branches or pull requests

2 participants