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 read property 'options' of undefined #3

Closed
kenips opened this issue Nov 4, 2014 · 17 comments
Closed

Cannot read property 'options' of undefined #3

kenips opened this issue Nov 4, 2014 · 17 comments

Comments

@kenips
Copy link

kenips commented Nov 4, 2014

Not sure if I've missed anything but seems like this.app is undefined inside the config hook in my app?

TypeError: Cannot read property 'options' of undefined
  at Class.module.exports.config (/ember/node_modules/ember-cli-dotenv/index.js:12:27)
@fivetanley
Copy link
Owner

Weird, seems to work in the test. I'll try to dig into this. Thanks for reporting!

@kenips
Copy link
Author

kenips commented Nov 5, 2014

Thanks @fivetabley. I can only find info on the included hook and not config hook so sorry couldn't help. Look forward to the fix!

@fivetanley
Copy link
Owner

@kenips can you try again with 0.3.0, and let me know what version of node and ember-cli you are using? thanks!

@kenips
Copy link
Author

kenips commented Nov 11, 2014

Sorry @fivetanley no luck.

# ember -v
version: 0.1.2
node: 0.10.33
npm: 2.1.3

All I did was:

~# mkdir my-app
~# cd my-app
my-app# ember init
...
my-app# nom install ember-cli-dotenv --save-dev
my-app# ember server
version: 0.1.2
Cannot read property 'options' of undefined
...

@kenips
Copy link
Author

kenips commented Nov 11, 2014

For me at config() entry point console.log(Object.keys(this)) gives:

[ 'project',
  'registry',
  '_didRequiredBuildPackages',
  'treePaths',
  'treeForMethods' ]

@fivetanley
Copy link
Owner

Try 0.3.1. I have no idea how I got this working in a different project before. Probably a fluke. if you look at 6353e4b you can see the change required to get this fixed.

I ran into the error in a new app, and upgrading it fixed it for me.

@kenips
Copy link
Author

kenips commented Nov 11, 2014

yeah I was just looking at that - you sure that you can get dotEnv from appConfig? I didn't see that myself. whereas anything declared in environment.js would get passed down. So for me moving the whitelisting to environment.js as ENV['dot-env'] seems reasonable.

@fivetanley
Copy link
Owner

yeah, the tests passed so i figured it was working. so clearly there's some work to do to get this working from the config hook. wish I could get at the app somehow... :\

@fivetanley
Copy link
Owner

I rolled back the change for now, it seems it works in some people's apps but not others. I'll keep looking into it. :(

@fivetanley
Copy link
Owner

0.3.3 is out and seems to fully work in my sample application. hope this fixes it for you @kenips

@fivetanley
Copy link
Owner

Note that the first time you access process.env may not have your environment variable the first time around as it gets merged with the first app config, then passed to all the addons like ember-cli-dotenv.

@kenips
Copy link
Author

kenips commented Nov 12, 2014

@fivetanley it's not working for me. I see that you've added included block but that should be the default behavior anyway. I see the exact same error as first reported now.

@vasilakisfil
Copy link

Hello! I have the same problem. I create a new dir, initialize ember, install ember-cli-dotenv from git repo and try to start ember server but I get this error:

➜  lala git:(master) ember s
version: 0.1.2
Cannot read property 'options' of undefined
TypeError: Cannot read property 'options' of undefined
    at Class.module.exports.config (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli-dotenv/index.js:13:12)
    at /home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/models/project.js:99:27
    at Array.reduce (native)
    at Project.getAddonsConfig (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/models/project.js:97:22)
    at Project.config (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/models/project.js:84:29)
    at Class.module.exports.Command.extend.run (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/commands/serve.js:26:29)
    at Class.Command.validateAndRun (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/models/command.js:86:15)
    at /home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/lib/cli/cli.js:54:22
    at $$$internal$$tryCatch (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
    at $$$internal$$invokeCallback (/home/vasilakisfil/Kollegorna/skl-related/lala/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)

@fivetanley
Copy link
Owner

0.3.4 is out and returns early if the addon gets included too early without the included hook being called. seems to work ok for me, let me know if it works for you.

@kenips
Copy link
Author

kenips commented Nov 14, 2014

Looks good to me! Thanks @fivetanley.

@kenips kenips closed this as completed Nov 14, 2014
@fivetanley
Copy link
Owner

\o/

@vasilakisfil
Copy link

Works perfect! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants