lamabiker / atom-ember-cli-helper

Ember CLI integration for the Atom editor
https://atom.io/packages/ember-cli-helper
MIT License
26 stars 13 forks source link

Uncaught TypeError: Cannot read property 'show' of undefined #14

Closed rabarar closed 8 years ago

rabarar commented 9 years ago

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 0.188.0 System: Mac OS X 10.10.2 Thrown From: ember-cli-helper package, v0.7.2

Stack Trace

Uncaught TypeError: Cannot read property 'show' of undefined

At /Users/robert/.atom/packages/ember-cli-helper/lib/ember-cli-helper-view.coffee:125

TypeError: Cannot read property 'show' of undefined
    at EmberCliHelperView.module.exports.EmberCliHelperView.showGeneratorList (/Users/robert/.atom/packages/ember-cli-helper/lib/ember-cli-helper-view.coffee:219:28)
    at HTMLButtonElement.<anonymous> (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-space-pen-views/node_modules/space-pen/lib/space-pen.js:220:36)
    at HTMLButtonElement.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/jquery/dist/jquery.js:4430:9)
    at HTMLButtonElement.elemData.handle (/Applications/Atom.app/Contents/Resources/app/node_modules/jquery/dist/jquery.js:4116:28)

Commands

  2x -0:24.7 ember-cli-helper:toggle (atom-pane.pane.active)
     -0:21.8 application:new-file (atom-pane.pane.active)
  2x -0:20.2 core:backspace (atom-text-editor.editor)
     -0:19.7 ember-cli-helper:toggle (atom-text-editor.editor)

Config

{
  "core": {
    "themes": [
      "atom-dark-ui",
      "atom-dark-syntax"
    ]
  },
  "ember-cli-helper": {}
}

Installed Packages

# User
ember-cli-helper, v0.7.2
html-helper, v0.2.3

# Dev
No dev packages
alexlafroscia commented 9 years ago

So is this not an issue or what?

rabarar commented 9 years ago

I assume it's not. I'm new to the whole framework so I thought I should dig in deeper. I'm assuming I must be doing something wrong when I press generate - I'm uncertain where the input to the generate should be coming from ...

On Mar 26, 2015, at 12:39 PM, Alex LaFroscia notifications@github.com wrote:

So is this not an issue or what?

— Reply to this email directly or view it on GitHub.

alexlafroscia commented 9 years ago

New to Ember? Or new to using this addon? I'm not sure what you mean by

where the input to the generate should be coming from

If you elaborate, maybe I can help!

rabarar commented 9 years ago

Alex,

New to both - I went to grab a screen capture to show you the error, and now I see a dialog box (as I would expect to see) for the Generate.

Interestingly, spun up a new ember to show you the error.

ember new demo

and when I opened atom in that directory initially it failed… I quit atom reopened it and it works… The error message that I sent you was the initial error that I received so I believe it’s a valid error if that helps.

Rob

On Mar 27, 2015, at 10:07 AM, Alex LaFroscia notifications@github.com wrote:

New to Ember? Or new to using this addon? I'm not sure what you mean by

where the input to the generate should be coming from

If you elaborate, maybe I can help!

— Reply to this email directly or view it on GitHub https://github.com/alexlafroscia/atom-ember-cli-helper/issues/14#issuecomment-86950386.

madhenry commented 9 years ago

Exactly the same error for me in every situation ( On the latest OS X Yosemite ), generate button sadly doesn't work at all, even after restarting. Generated my boilerplate project using ember-cli:

$ ember --version
version: 0.2.3
node: 0.12.2
npm: 2.7.6

"Server", "Test" and all the other buttons are working nicely though.

alexlafroscia commented 9 years ago

@madhenry is it possible for you to try using the Generator command, and then openning the developer console and sending me the output?

seanmhoffman commented 9 years ago

I'm having the same issues. Sometimes when clicking the generate button a TypeError gets thrown:

TypeError: Cannot read property 'show' of undefined
  at EmberCliHelperView.module.exports.EmberCliHelperView.showGeneratorList (C:\Users\sean\.atom\packages\ember-cli-helper\lib\ember-cli-helper-view.coffee:125:15)
  at HTMLButtonElement.<anonymous> (C:\Users\sean\AppData\Local\atom\app-0.190.0\resources\app\node_modules\atom-space-pen-views\node_modules\space-pen\lib\space-pen.js:220:36)
  at HTMLButtonElement.jQuery.event.dispatch (C:\Users\sean\AppData\Local\atom\app-0.190.0\resources\app\node_modules\jquery\dist\jquery.js:4430:9)
  at HTMLButtonElement.elemData.handle (C:\Users\sean\AppData\Local\atom\app-0.190.0\resources\app\node_modules\jquery\dist\jquery.js:4116:28)

Usually a restart will prevent the TypeError from getting thrown again, but it seems to be inconsistent. Sometimes it shows up, sometimes it doesn't. When the error isn't thrown the input shows up but the generator list is completely empty and even as I type something like 'component' no results ever show up in the list.

I'm running Windows 7 Pro (SP1) using Atom v.0.190.0. The ember-cli version is as follows:

$ ember --version
version: 0.2.3
node: 0.12.2
npm: 2.7.6
alexlafroscia commented 9 years ago

Huh, very interesting. Just trying to get a handle on possible issues -- can you check out the default locations for the Ember and NPM executables (found in the Preferences for the plugin) and ensure that they match the locations of the executables in your system? Unfortunately, Atom isn't able to just use your default PATH so I have to, as far as I know, specify a direct path to both programs.

nigelsmith commented 9 years ago

Ello,

I just ran into this. The issue is that the commands are being added to the command palette before it's established that you've found ember and so this.generator is not set, then when the command is chosen a call to this.generator.show fails.

initialize: ->
    # Register Commands
    atom.commands.add 'atom-text-editor',
      "ember-cli-helper:toggle":        => @toggle()
      "ember-cli-helper:generate-file": => @showGeneratorList()

    # Add the path to the Node executable to the $PATH
    nodePath = atom.config.get('ember-cli-helper.pathToNodeExecutable')
    nodePath = nodePath.substring(0, nodePath.length - 4)
    process.env.PATH += ":#{nodePath}"

    # Enable or disable the helper
    try
      ember = require("#{atom.project.getPaths()[0]}/package.json").devDependencies["ember-cli"]
    catch e
      error = e.code

    if ember?
      @generator = new GeneratorListView @
      @toggle()
    else
      @emberProject = false
      @addLine "This is not an Ember CLI projet!"

The other issue here is that it looks like this plugin assumes that the root dir is an ember project but in many cases ember is within a sub-folder and other files, for example backend code might be in another.

alexlafroscia commented 9 years ago

Regarding the first part, thank you! I'll try to look into this ASAP.

In regards to the second part, I'm aware of the issue but not 100% sure how to fix it. It has to know the context in which to run the ember commands, so it assumes the current project directory is the right one. Maybe I could make it recursively look through the tree in an attempt to find the right one? I'm not really sure what the best solution here would be.

natecox commented 9 years ago

I just had this error occur myself. This issue should probably be reopened until resolved.

5e3785c32c5e9819fb98d519e1937dea

eibrahim commented 9 years ago

I am having the same issue on a mac. fresh install of atom, latest install of ember cli as of July 24, 2015

ajgordo commented 9 years ago

I came across this issue also. Tracing it I found that the issue was caused by ember-cli not existing under devDependencies in package.json So if your project has been setup incorrectly then it's possible that's the cause of your issue. A nicer error for that scenario would be good.

mariusandra commented 8 years ago

Hey, I have hopefully made the errors more verbose. Let me know if there are other issues. Closing again.