github icon indicating copy to clipboard operation
github copied to clipboard

Uncaught TypeError: Cannot read property 'getPath' of undefined

Open danahartweg opened this issue 7 years ago • 23 comments

Steps to Reproduce

  1. Open a project containing a git repository
  2. Make changes to a file
  3. Click the changed file in the Git tab, the diff view does not appear
  4. Explicitly trigger the View Unstaged Changes For Current File command, which provides the error below

I've tried safe mode, a clean install, different project in a different repository... everything results in the same error and no change diffs.

Atom: 1.18.0 x64 Electron: 1.3.15 OS: Mac OS X 10.12.5 Thrown From: github package 0.3.3

Stack Trace

Uncaught TypeError: Cannot read property 'getPath' of undefined

At /Applications/Atom.app/Contents/Resources/app/node_modules/github/lib/controllers/root-controller.js:790

TypeError: Cannot read property 'getPath' of undefined
    at RootController.viewChangesForCurrentFile (/Applications/Atom.app/Contents/Resources/app/node_modules/github/lib/controllers/root-controller.js:790:37)
    at RootController.viewUnstagedChangesForCurrentFile (/Applications/Atom.app/Contents/Resources/app/node_modules/github/lib/controllers/root-controller.js:812:16)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:265:35)
    at /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:65
    at Object.didConfirmSelection (/Applications/Atom.app/Contents/Resources/app/node_modules/command-palette/lib/command-palette-view.js:106:35)
    at SelectListView.confirmSelection (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-select-list/src/select-list-view.js:313:26)
    at HTMLDivElement.core:confirm (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-select-list/src/select-list-view.js:81:20)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:265:35)
    at /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:65
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:610:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:401:28)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:100:42)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:3:65)

Commands

     -1:17.3.0 core:close (ul.list-inline.tab-bar.inset-panel)
     -1:15 application:open (ul.list-inline.tab-bar.inset-panel)
     -1:06.5.0 window:toggle-dev-tools (atom-pane.pane.active)
     -0:45.9.0 application:open (atom-workspace.workspace.scrollbars-visible-when-scrolling.theme-one-dark-syntax.theme-one-dark-ui)
     -0:36.9.0 github:toggle-github-tab (atom-workspace.workspace.scrollbars-visible-when-scrolling.theme-one-dark-syntax.theme-one-dark-ui)
     -0:25.8.0 core:save (input.hidden-input)
     -0:21.9.0 core:close (div.github-StagingView.unstaged-changes-focused)
     -0:21 command-palette:toggle (div.github-StagingView.unstaged-changes-focused)
     -0:18.6.0 core:confirm (input.hidden-input)
     -0:18.5.0 github:view-unstaged-changes-for-current-file (div.github-StagingView.unstaged-changes-focused)

Non-Core Packages


danahartweg avatar Jun 21 '17 16:06 danahartweg

Thanks for the report! Do you get the error for changes to any file? Also, can you share the path for a file that triggers the error?

rsese avatar Jun 29 '17 20:06 rsese

Oh sorry one more question - can you also reproduce in safe mode (atom --safe)?

rsese avatar Jun 29 '17 20:06 rsese

I tried multiple projects and files in those projects (all backed by git repositories). The only thing they had in common was a base directory of /Users/dana/.

And yes, I tried safe mode as well as a clean install of atom, all with the same results.

danahartweg avatar Jun 29 '17 20:06 danahartweg

And yes, I tried safe mode as well as a clean install of atom, all with the same results.

Oy sorry, I spaced that you totally mentioned that in your original report sorry about that!

I poked at this a bit more and see that I can reproduce if I execute GitHub: View Unstaged Changes For Current File while the focus is on the Git tab, then I can generate this error. I think at your step 3, we're focusing the Git tab so there's no active editor which causes the error? If I click back into the file with changes and execute GitHub: View Unstaged Changes For Current File, it works ok.

Though I guess another issue in your case is this?

  1. Make changes to a file
  2. Click the changed file in the Git tab, the diff view does not appear

Assuming you're saving the file after (2), I'm not sure why the diff view doesn't appear in this case. Are there console errors at this point?

rsese avatar Jun 29 '17 22:06 rsese

No worries! It was sort of sandwiched in-between everything else. I can verify that same behavior of when a file is focused in the editor, versus when it's not.

There actually are console errors at that point, which I should have checked for. I must have missed them when I assumed that invoking GitHub: View Unstaged Changes For Current File without a file selected in the editor was the source of the problem.

Those errors actually led me to finding out the root of my problem is a duplicate of https://github.com/atom/github/issues/977

At least there's still an uncaught exception that can be taken care of? Anyway, thanks for the help, and sorry for taking away some of your valuable time!

danahartweg avatar Jun 29 '17 23:06 danahartweg

Those errors actually led me to finding out the root of my problem is a duplicate of #977

Ahhh great, glad you found that one, that explains things.

At least there's still an uncaught exception that can be taken care of?

:+1: I think that's still a bug so we can leave this open.

Thanks again for reporting :v:

rsese avatar Jun 30 '17 17:06 rsese

Sure thing!

It's nothing compared to the great work you guys do at GitHub.

danahartweg avatar Jul 01 '17 03:07 danahartweg

Hey there fellow tentacools,

Just an update: I got the same error without Git's color piping config involved (at least not from my local tinkering).

I have a different version of Atom, and this all occurred in a temp directory with Git init ran from Atom (I'm really loving how streamlined this is, but I digress).

The error report popup said the issue was already known and linked me here.

Since I had checked and found, after reading through #977, that my issue's cause was apparently not the same, I decided to include the error report here.

Thanks, ion

Steps to Reproduce

When one octocat likes another octocat--wrong list. Here we go: Beginning in BASH and transitioning to Atom:

  1. MYDIR=$(mktemp -d)
  2. cd $MYDIR
  3. touch somethingNew
  4. atom .
  5. ctrl+shift+9
  6. Click Create repository button
  7. ctrl+shift+p
  8. Type 'unstaged'
  9. enter

atom-github-error-reproduction_screenshot from 2017-08-17 16-26-52

Atom: 1.19.2 x64 Electron: 1.6.9 OS: Ubuntu 16.04.3 Thrown From: github package 0.3.4-1

Stack Trace

Uncaught TypeError: Cannot read property 'getPath' of undefined

At /usr/share/atom/resources/app/node_modules/github/lib/controllers/root-controller.js:790

TypeError: Cannot read property 'getPath' of undefined
    at RootController.viewChangesForCurrentFile (/usr/share/atom/resources/app/node_modules/github/lib/controllers/root-controller.js:790:37)
    at RootController.viewUnstagedChangesForCurrentFile (/usr/share/atom/resources/app/node_modules/github/lib/controllers/root-controller.js:812:16)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:265:35)
    at /usr/share/atom/resources/app/src/command-registry.js:3:65
    at Object.didConfirmSelection (/usr/share/atom/resources/app/node_modules/command-palette/lib/command-palette-view.js:106:35)
    at SelectListView.confirmSelection (/usr/share/atom/resources/app/node_modules/atom-select-list/src/select-list-view.js:313:26)
    at HTMLDivElement.core:confirm (/usr/share/atom/resources/app/node_modules/atom-select-list/src/select-list-view.js:81:20)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:265:35)
    at /usr/share/atom/resources/app/src/command-registry.js:3:65
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:610:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:401:28)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/usr/share/atom/resources/app/src/window-event-handler.js:100:42)
    at HTMLDocument.<anonymous> (/usr/share/atom/resources/app/src/window-event-handler.js:3:65)

Commands

     -0:26.6.0 github:toggle-git-tab (atom-pane.pane.active)
     -0:11.2.0 command-palette:toggle (atom-workspace.workspace.scrollbars-visible-always.theme-one-light-syntax.theme-one-light-ui)
     -0:08.2.0 core:confirm (input.hidden-input)
     -0:08.2.0 github:view-unstaged-changes-for-current-file (atom-workspace.workspace.scrollbars-visible-always.theme-one-light-syntax.theme-one-light-ui)

Non-Core Packages


ionchill avatar Aug 18 '17 02:08 ionchill

I can reproduce this when nothing is open or when the unstaged changes tab is open but not when the git tab is focused.

Ben3eeE avatar May 04 '18 18:05 Ben3eeE

I have been seeing warnings on 1.57.0 on file moves/renames in a freshly created repo (freshly imaged computer) as well but not seeing any of the major errors but can reproduce most of the warnings with 100% consistency.

Atom

Atom    : 1.57.0
Electron: 9.4.4
Chrome  : 83.0.4103.122
Node    : 12.14.1

Installed packages

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

https://github.com/atom/atom/issues/22542 and https://github.com/atom/atom/issues/22686 are possibly related.

Steps To Reproduce:

  • New, Unpublished GitHub repo
  • On files open or previewed (within the scope of a GitHub repo) within Atom, you will receive a Cannot read property 'getPath' of undefined on/after moving or renaming that file.
  • If the file is not open or previewed in Atom, and you right click to rename from the Project file list or drag and drop files around without allowing Atom to preview or open the file, then zero errors/warnings are produced.

An additional set of behaviors to note:

  • You can open and rename files within the same editor but outside of the scope of the project, then right click to rename from the editor tab without any errors. If you do the same on a file within the scope of the folder/project repo you may find more quirky behavior:
  • Doing the same on a file within the scope of the project, you receive a warning and file renaming occurs otherwise. However attempting to rename the file the same way a second time produces no rename prompts until you defocus/refocus the file.

// updated for some extra clarity.

lech avatar Jul 03 '21 19:07 lech

Been hitting this same issue on macOS, when a file/folder is renamed Atom throws the getPath is undefined error but will execute the rename despite the error. Don't suppose anyone has a workaround yet?

Atom    : 1.57.0
Electron: 9.4.4
Chrome  : 83.0.4103.122
Node    : 12.14.1

jmooo avatar Jul 08 '21 22:07 jmooo

Same error here on macOS. And exact same versions as @jmooo.

dougc84 avatar Jul 10 '21 05:07 dougc84

+1 except for me, I was not having this issue until I switched to a new Macbook due to a battery issue and tried copying my home directory from the old to new one, but got interrupted midway and did not get the whole $HOME/.atom directory. Reinstalling packages did not help & FYI Atom was installed on the new mac AFTER the copy attempt.

Versions:

Atom    : 1.58.0
Electron: 9.4.4
Chrome  : 83.0.4103.122
Node    : 12.14.1
apm  2.6.2
npm  6.14.13
node 12.14.1 x64
atom 1.58.0
python 2.7.16
git 2.30.1

Installed community packages:

├── [email protected]
├── atom-ide-ui
├── [email protected]
├── [email protected]
├── go-signature-statusbar
├── language-vbscript
├── refactor
└── [email protected]

Issue for me occurs as others have identically mentioned, whenever renaming or moving a file within the editor; though the rename/move operation still gets carried out despite the warning.

k5sql avatar Aug 14 '21 14:08 k5sql

Edit: it's still happening. @lech 's answer explains some behavior: https://github.com/atom/github/issues/964#issuecomment-873461105

My previous answer solves the r trim() issue: https://github.com/atom/markdown-preview/issues/579#issuecomment-902387642

Issues (22 Aug 2021) related to getPath() error:

@lech mentioned:

https://github.com/atom/atom/issues/22542

https://github.com/atom/atom/issues/22686#issue-935562185

Here's another I found:

https://github.com/atom/atom/issues/22720#issue-942225379

wlwl2 avatar Aug 20 '21 03:08 wlwl2

Running into this with Atom 1.58.0, Windows 10. I renamed lots of files over the course of an Atom session, and after ignoring warning after warning eventually one of my renames crashed Atom altogether. Installed community packages:

hexit 1.0.2
mcfunction-lang 1.16.2-snapshot

W-19 avatar Aug 21 '21 06:08 W-19

Still finding this behavior on 1.58.0

lech avatar Aug 21 '21 22:08 lech

@lech @W-19 Thanks for the updates. It was working for a bit and now I'm still getting that error...

wlwl2 avatar Aug 21 '21 22:08 wlwl2

This might have been fixed in https://github.com/atom/atom/pull/22543. Just hasn't reached a stable version of atom yet.

wlwl2 avatar Aug 31 '21 07:08 wlwl2

This might have been fixed in atom/atom#22543. Just hasn't reached a stable version of atom yet.

This PR was merged in June 7, Atom 1.58 was released in July 27, the issue is still in Atom 1.58… I doubt.

AlexWayfer avatar Aug 31 '21 07:08 AlexWayfer

@AlexWayfer https://github.com/atom/atom/releases/tag/v1.58.0 this.editorPath = this.edtior.getPath(); in source code.

wlwl2 avatar Aug 31 '21 08:08 wlwl2

Oh, I found https://github.com/atom/atom/issues/22720#issue-942225379, yes, somehow this PR was out of 1.58, that's weird.

AlexWayfer avatar Aug 31 '21 09:08 AlexWayfer