cs150bf / ever-notedown

Atom Editor Plugin
MIT License
140 stars 13 forks source link

Unable to sync with Evernote after moving Git Path (Failed to create temporary file/Permission denied) #18

Closed 7k50 closed 8 years ago

7k50 commented 8 years ago

I am unable to sync with Evernote after changing the path of the EVND file storage from ~/.atom/evnd/ to a Dropbox folder.

I copied all my EVND notes, including index.json to: /Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/

I initiated a git repo in the new folder with git init which was created in: /Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/.git

I get this error message when trying to sync existing and new notes:

Failed to create temporary file
/Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/.git/objects/tmp_object_git2_Cdhp2n':
Permission denied when trying to send note to Evernote

Traceback:

Note options:
title: "CMD Terminal (Shell/Bash)"
tags: ["EVND"]
notebook: {"name":"Computer/Devices"}
metaDate: null
format: "Markdown"
update: true
filePath: "/Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/20151007/cmd_terminal_(shell_bash).markdown"
renderOptions: {"mathjax":true}
moved: false
path: "/Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/20151007"
fnStem: "cmd_terminal_(shell_bash)"
Hide Stack Trace
Error: Failed to create temporary file '/Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/.git/objects/tmp_object_git2_Cdhp2n':
Permission denied
at Error (native)
at Function.exports.StorageManager.StorageManager.addAppleScripts (/Users/xxx/.atom/packages/ever-notedown/lib/storage-manager.coffee:182:16)
at StorageManager.exports.StorageManager.StorageManager.addNote (/Users/xxx/.atom/packages/ever-notedown/lib/storage-manager.coffee:314:34)
at MarkdownNote.update (/Users/xxx/.atom/packages/ever-notedown/lib/note-prototypes/note-markdown.coffee:98:44)
at Object.module.exports.toEvernote (/Users/xxx/.atom/packages/ever-notedown/lib/ever-notedown.coffee:1174:17)
at Object.module.exports.file2Evernote (/Users/xxx/.atom/packages/ever-notedown/lib/ever-notedown.coffee:1140:8)
at /Users/xxx/.atom/packages/ever-notedown/lib/ever-notedown.coffee:475:12
at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
at HTMLButtonElement.<anonymous> (/Users/xxx/.atom/packages/ever-notedown/lib/ever-notedown-preview-view.coffee:453:22)
at HTMLButtonElement.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4435:9)
at HTMLButtonElement.elemData.handle (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4121:28)
cs150bf commented 8 years ago

There might be a few issues that we'll need to figure out here... maybe we should start from the "Error: Failed to create temporary file"? It looks like a directory permission issue to me.

Could you please try these:

  1. In a terminal, cd to /Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/tmp/ (Does this directory even exists?--I would think so, but just making sure)
  2. Do you see a bunch of *.applescript in there?
  3. Now if you type git add *.applescript in your terminal, what happens?
  4. Who's the owner of /Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/? Is it root? (Check with ls -ld /Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/)
  5. On a separate note, in the Atom log, do you see a line that starts with @gitRepo.getPath(): before the traceback you posted? What does it say?

There are probably more issues beyond the permission problem, though. My apologies for the lack of documentation on how to migrate EVND directory. There might be quite a few problems if you just copy over all the notes and index.json:

  1. Your commit history is still in your old EVND directory (~/.atom/evnd/ by default), assuming you haven't deleted that folder--this is a git thing, and I kind of assumed people who do really migrate their EVND folder (instead of moving temporarily for testing purpose) will do it in git-style: clone, etc. My bad for not even mentioning this in the documentation.
  2. index.json, which tracks all EVND notes, still contains the information pertaining to the old EVND directory--if you open it up with any text editor, you see entries like path, enExportedFiles, attachments:path that still point to the old directory. You might have to do some manual find-and-replace for the paths, otherwise the syncing will probably break for all notes.

Or rather, _I_ should write a routine within EVND so users can move their notes relatively easily. But until that happens...

TL;DR Here is what I did when I moved my own evnd folder from the default location to dropbox, which might be of less fuss:

  1. Close Atom;
  2. Move ~/.atom/evnd/ to /Users/xxx/Dropbox/blahblah/evnd/ (Alternatively, copy everything with cp -r and move ~/.atom/evnd/ away or rename it) -- There is no need to do more git init because your old folder is already established as a git repo.
  3. Make a symlink with ln -s /Users/xxx/Dropbox/blahblah/evnd/ /Users/xxx/.atom/evnd/
  4. Open Atom, go to EVND settings, in Git Path, type in /Users/xxx/.atom/evnd/ and check the Git Path Symlink check box
  5. Restart Atom. If all goes well, everything should work the same as before as if you still have your folder in ~/.atom/evnd/, except it's actually located elsewhere. (Assuming you don't see the "permission denied" error!)
7k50 commented 8 years ago

Hi, thanks for your answer and support for this issue!

Syncing now works again, but first my replies to your questions:

1/2) Yes, /tmp/ exists and these AppleScripts are present:

evernote-create-note.AppleScript
evernote-find-note.AppleScript
evernote-get-attachments-info.AppleScript
evernote-get-enml.AppleScript
evernote-get-html.AppleScript
evernote-get-note-info.AppleScript
evernote-retrieve-note.AppleScript
evernote-update-note.AppleScript

3) sudo git add *.AppleScript passes through in Terminal, no feedback message given.

4) drwxr-xr-x@ 12 winterflags staff 408 Oct 24 12:05 /Users/winterflags/Dropbox/Creative/Programming/Tools/Atom/EVND

5) Sorry, I don't see @gitRepo.getPath(): anywhere in the error dialog box.

As for your TL;DR guide – thanks – syncing now works again.

The difference after following your guide is that I had the Git path pointed to my custom location /Users/xxx/Dropbox/blahblah/EVND/. I have now restored it to the default ~/.atom/evnd/ and thus it seems to work again. Thanks!

Update 1: There seems to be a slight issue with content discrepancy. I use Atom/EVND on two computers and even though I now keep everything in a synced Dropbox folder, I don't see the same contents when opening Atom on the two computers. This may be due to a Dropbox syncing error (my Dropbox wheel is stuck spinning for this particular folder) so I will have to reindex my Dropbox to verify if it is related to EVND.

cs150bf commented 8 years ago

Well, thanks for your feedback and I'm glad now the syncing works for you... sort of?

I do have a comment for 3), though--I would think you do not need sudo for git add. But if you do, then the "permission denied" error you first posted makes sense: EVND does not have sudo privilege (as it shouldn't!) to run commands like git add so it errors out. Since the permission to your folder looks fine to me, my guess is your /Users/xxx/Dropbox/Creative/Programming/Tools/Atom/EVND/.git/ is owned by root and you'll need to do a chown for it.

Ref:
Git commands require sudo on OSX: http://stackoverflow.com/questions/28832815/git-commands-require-sudo-on-osx (see comment on the answer)

In fact I wonder if the permission of the .git/ folder may be related to the Dropbox syncing issue you are having.

Or maybe not, I probably should have thought about possible problems of putting a git repo on dropbox before--it's probably fine (as it has been for me) if no git operation is done while dropbox is still syncing, but otherwise... I could see how there could be trouble if you try to edit the same file simultaneously on two machines (by "simultaneously" I mean at the same time, or within seconds). But in a more general sense, I think git repo on dropbox should be fine.

Some refs:

7k50 commented 8 years ago

Hey, I am now back after reindexing my entire Dropbox (which took a few days since it's almost 1TB). This didn't resolve the Dropbox spinning wheel being stuck, but simply copy/delete/pasting the files resolves the issue.

But back to the main issue: the EVND content not syncing seems to be because Dropbox excludes content in symlinked (aliased) folders. I just want to make sure that I understood it correctly that:

The reason I'm getting different EVND content on my two computers is simply because the contents in the /Users/winterflags/.atom/evnd/ folders are different. No syncing is taking place.

But maybe I misunderstood something along the way?

I'm not very good with *nix and how owners work, but these are the contents in the Dropbox folder, via ls -al:

drwxr-xr-x@ 11 winterflags  staff      374 Oct 27 10:33 .
drwxr-xr-x@  4 winterflags  staff      136 Oct 27 10:31 ..
drwxr-xr-x@ 11 winterflags  staff      374 Oct 27 10:31 .git
drwxr-xr-x@ 27 winterflags  staff      918 Oct 27 10:31 20151007
drwxr-xr-x@ 13 winterflags  staff      442 Oct 27 10:31 20151021
drwxr-xr-x@ 10 winterflags  staff      340 Oct 27 10:31 20151023
drwxr-xr-x@ 23 winterflags  staff      782 Oct 27 10:31 20151024
drwxr-xr-x@  3 winterflags  staff      102 Oct 27 10:31 backups #I have created this folder
-rw-r--r--@  1 winterflags  staff  1268804 Oct 27 10:34 evnd .atom #This is the symlink
-rw-r--r--@  1 winterflags  staff    18502 Oct 25 15:55 index.json
drwxr-xr-x@ 18 winterflags  staff      612 Oct 27 10:31 tmp

And contents of .git:

drwxr-xr-x@ 11 winterflags  staff  374 Oct 27 10:31 .
drwxr-xr-x@ 11 winterflags  staff  374 Oct 27 10:33 ..
-rw-r--r--@  1 winterflags  staff   23 Oct 24 09:07 HEAD
drwxr-xr-x@  2 winterflags  staff   68 Oct 24 09:07 branches
-rw-r--r--@  1 winterflags  staff  137 Oct 24 09:07 config
-rw-r--r--@  1 winterflags  staff   73 Oct 24 09:07 description
drwxr-xr-x@ 11 winterflags  staff  374 Oct 27 10:31 hooks
-rw-r--r--@  1 winterflags  staff  856 Oct 25 15:42 index
drwxr-xr-x@  3 winterflags  staff  102 Oct 27 10:31 info
drwxr-xr-x@ 12 winterflags  staff  408 Oct 27 10:31 objects
drwxr-xr-x@  4 winterflags  staff  136 Oct 27 10:31 refs
cs150bf commented 8 years ago

Something real quick (I might come back and update this comment later today):

I just want to make sure that I understood it correctly that:

  • The Git link in EVND Package Settings should be the Default: /Users/winterflags/.atom/evnd/?
  • A symlink should be created in my Dropbox folder pointing to the above location?

First on the second point: I would think that it's the other way around... For myself I have the EVND folder on dropbox (something like /Users/xxx/Dropbox/blahblah/evnd/) and then make a symlink at ~/.atom/evnd/ which points to the aforementioned directory, as done by running the command ln -s /Users/xxx/Dropbox/blahblah/evnd/ /Users/xxx/.atom/evnd/. That's what I was thinking when I wrote my previous comment. For example, when I run ls -al ~/.atom/ev*, the result is:

$ ls -al ~/.atom/ev*
lrwxr-xr-x  1 myUserName  staff  59 May  3 17:11 /Users/myUserName/.atom/evnd -> /Users/myUserName/Dropbox/blahblah/evnd

And then on the first point, yes and you'll need to check the "Git Path Symlink" checkbox.

screen shot 2015-10-27 at 8 13 05 am

I guess what I'm most confused about is why do you have evnd .atom inside your EVND folder? (And it doesn't look like a symlink to me as I don't see any arrow... or do you mean that you have made a symlink at ~/.atom/evnd/ that points to this evnd .atom folder?) I have a feeling that's probably not what you want. I thought you only need these:

7k50 commented 8 years ago

Hi, first off – sorry for the late reply, the last few days were a bit busy.

And sorry about the confusion regarding the symlinks. I have set up the symlink according to your instructions – ln -s /Users/xxx/Dropbox/blahblah/evnd/ /Users/xxx/.atom/evnd/. I had also put an alias pointing back to /Users/xxx/.atom/evnd/ for ease of navigation, that was the file you saw in the directory listing.

This is what the directories look like now:

screen shot 2015-10-29 at 13 29 22 copy

The issue seems to be that Atom/EVND doesn't index notes from ~/.atom/evnd/EVND/index.json. Instead it indexes ~/.atom/evnd/index.json. Even if I delete this file, it recreated on Atom startup. Since I deleted all notes in this folder, its contents are simply {}.

The package settings use the default (empty) Git link:

screen shot 2015-10-29 at 13 35 18
cs150bf commented 8 years ago

Ah, the new information is very helpful, now I see what the problem is: your EVND path setting is one level off.

That's probably caused by an error on my part--when I said ln -s /Users/xxx/Dropbox/blahblah/evnd/ /Users/xxx/.atom/evnd/, it should have been ln -s /Users/xxx/Dropbox/blahblah/evnd/ /Users/xxx/.atom/evnd (note the slash in the very end--we don't need it). You can redo the symlinking by removing the existing ~/.atom/evnd/ (the symlink, not the actual folder!) and run the correct ln -s command again. Sorry about that.

If you want to verify if the symlink is done properly:

$ ls -al ~/.atom/
total 1056
drwxr-xr-x   30 xxx  staff    1020 May  3 17:11 .
drwxr-xr-x+  91 xxx  staff    3094 Oct 28 12:51 ..
-rw-r--r--@   1 xxx  staff   10244 Apr 17  2015 .DS_Store
drwxr-xr-x  794 xxx  staff   26996 Oct 16 15:21 .apm
-rw-r--r--    1 xxx  staff      41 Feb  8  2015 .gitignore
-rw-r--r--    1 xxx  staff    2483 Oct 27 08:12 config.cson
drwxr-xr-x    4 xxx  staff     136 Feb 26  2015 dev
lrwxr-xr-x    1 xxx  staff      59 May  3 17:11 evnd -> /Users/xxx/Dropbox/blahblah/evnd
.
.
.
20150509   20150610   20150702   20150727   20150909   20150923   20151011   index.json
20150510   20150612   20150706   20150801   20150914   20150924   20151012   tmp
.
.
.
7k50 commented 8 years ago

Ah, it makes sense now. Thanks a lot! :) Now I can finally start using this nice piece of software.