mainmatter / ember-cli-simple-auth-torii

Ember CLI Addon for the Ember Simple Auth Torii package
https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-torii
MIT License
7 stars 11 forks source link

TypeError: Cannot read property 'env' of undefined #10

Closed timini closed 9 years ago

timini commented 9 years ago

OK using ember-cli master now, and I'm getting this error

I've tried using the master of ember-cli-simple-auth-torii too and I still get it

Cannot read property 'env' of undefined
TypeError: Cannot read property 'env' of undefined
    at Class.treeFor (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli-simple-auth-torii/node_modules/torii/ember-addon/index.js:15:48)
    at /Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/models/addon.js:211:32
    at Array.map (native)
    at Class.eachAddonInvoke (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/models/addon.js:209:22)
    at Class.treeFor (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/models/addon.js:256:20)
    at EmberApp.<anonymous> (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/broccoli/ember-app.js:307:20)
    at Array.map (native)
    at EmberApp.addonTreesFor (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/broccoli/ember-app.js:305:30)
    at EmberApp._processedVendorTree (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/broccoli/ember-app.js:664:29)
    at EmberApp._processedExternalTree (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/broccoli/ember-app.js:693:21)
timini commented 9 years ago

https://github.com/Vestorly/torii/issues/147

igorstajic commented 9 years ago

See this Vestorly/torii#156

marcoow commented 9 years ago

will be fixed via #11

timini commented 9 years ago

I'm still getting this error:

ember server
The package `ember-data` is not a properly formatted package, we have used a fallback lookup to resolve it at `/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-data`. This is generally caused by an addon not having a `main` entry point (or `index.js`).
Future versions of Ember CLI will not support v0.10.32. Please update to Node 0.12 or io.js.
version: 0.2.0
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/#watchman for more info.
The package `ember-data` is not a properly formatted package, we have used a fallback lookup to resolve it at `/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-data`. This is generally caused by an addon not having a `main` entry point (or `index.js`).
Cannot read property 'env' of undefined
TypeError: Cannot read property 'env' of undefined
    at Class.treeForAddon (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli-simple-auth-torii/node_modules/torii/ember-addon/index.js:26:46)
    at Class._treeFor (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/models/addon.js:288:31)
    at Class.treeFor (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/models/addon.js:258:19)
    at /Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/models/addon.js:211:32
    at Array.map (native)
    at Class.eachAddonInvoke (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/models/addon.js:209:22)
    at Class.treeFor (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/models/addon.js:256:20)
    at EmberApp.<anonymous> (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/broccoli/ember-app.js:307:20)
    at Array.map (native)
    at EmberApp.addonTreesFor (/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli/lib/broccoli/ember-app.js:305:30)
   npm version 
{ http_parser: '1.0',
  node: '0.10.32',
  v8: '3.14.5.9',
  ares: '1.9.0-DEV',
  uv: '0.10.28',
  zlib: '1.2.3',
  modules: '11',
  openssl: '1.0.1i',
  npm: '1.4.28',
  'repositive.io': '0.0.0' }

   ember version
The package `ember-data` is not a properly formatted package, we have used a fallback lookup to resolve it at `/Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-data`. This is generally caused by an addon not having a `main` entry point (or `index.js`).
Future versions of Ember CLI will not support v0.10.32. Please update to Node 0.12 or io.js.
version: 0.2.0
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/#watchman for more info.
node: 0.10.32
npm: 2.7.3

packages in my project:

├─┬ ember-cli@0.2.0 (git+https://github.com/ember-cli/ember-cli#237cc6024d35d5125bfa5d9ad1fc226dc9f7b2f9)
├── ember-cli-simple-auth@0.7.3
├── ember-cli-simple-auth-cookie-store@0.7.3
├── ember-cli-simple-auth-oauth2@0.7.3
├─┬ ember-cli-simple-auth-torii@0.7.3 (git+https://github.com/simplabs/ember-cli-simple-auth-torii#37eac35a8a7aa95945ead0b89c7268c31f14644c)
│ └─┬ torii@0.3.2
marcoow commented 9 years ago

is /Users/tim/Workspace/repositive/api.repositive.io/frontend/node_modules/ember-cli-simple-auth-torii/node_modules/torii actually 0.3.2?

timini commented 9 years ago

it's package.json says it is. so yes.

timini commented 9 years ago

I'll try with a fresh project

marcoow commented 9 years ago

must be a torii bug then.

timini commented 9 years ago

yep seems like someone else has just reported this bug again..

https://github.com/Vestorly/torii/issues/156

I'll hold tight for torii fix then

thanks marcoow

timini commented 9 years ago

OK so now Torii has declared this not their bug I'm left confused.

├─┬ ember-cli@0.2.1
├── ember-cli-simple-auth@0.7.3
├─┬ ember-cli-simple-auth-torii@0.7.3 (git+https://github.com/simplabs/ember-cli-simple-auth-torii#37eac35a8a7aa95945ead0b89c7268c31f14644c)
│ ├── ember-cli-simple-auth@0.7.3
│ └─┬ torii@0.3.2
└─┬ torii@0.3.2

When I try to run ember serve I get the same error.

Cannot read property 'env' of undefined
TypeError: Cannot read property 'env' of undefined
    at Class.treeForAddon (/Users/tim/Workspace/repositive/torii/node_modules/torii/ember-addon/index.js:26:46)
    at Class._treeFor (/Users/tim/Workspace/repositive/torii/node_modules/ember-cli/lib/models/addon.js:288:31)
    at Class.treeFor (/Users/tim/Workspace/repositive/torii/node_modules/ember-cli/lib/models/addon.js:258:19)
    at /Users/tim/Workspace/repositive/torii/node_modules/ember-cli/lib/models/addon.js:211:32
    at Array.map (native)
    at Class.eachAddonInvoke (/Users/tim/Workspace/repositive/torii/node_modules/ember-cli/lib/models/addon.js:209:22)
    at Class.treeFor (/Users/tim/Workspace/repositive/torii/node_modules/ember-cli/lib/models/addon.js:256:20)
    at EmberApp.<anonymous> (/Users/tim/Workspace/repositive/torii/node_modules/ember-cli/lib/broccoli/ember-app.js:307:20)
    at Array.map (native)
    at EmberApp.addonTreesFor (/Users/tim/Workspace/repositive/torii/node_modules/ember-cli/lib/broccoli/ember-app.js:305:30)

Did anyone get this to work yet?

igorstajic commented 9 years ago

Having the same issue here as well. I've tried making a new cli-project and only installing torii, ember-simple-auth and ember-cli-simple-auth-torii, and still getting the same error when trying to run it. Same versions as you specified.

sarjanen commented 9 years ago

Same issue here using Ember CLI 0.2.2, Torii 0.3.2 and master branch on ember-cli-simple-auth-torii.

jrowlingson commented 9 years ago

@Padchi Is this what you are seeing:

$ ember --version
version: 0.2.2
node: 0.12.0
npm: 2.7.4
$ ember new auth-test && cd auth-test
$ ember install:addon ember-cli-simple-auth
version: 0.2.2
Installed packages for tooling via npm.
installing
Installing browser packages via Bower...
  cached git://github.com/simplabs/ember-simple-auth-component.git#0.7.3
Installed browser packages via Bower.
Installed addon package.
$ ember install:addon ember-cli-simple-auth-torii
version: 0.2.2
Installed packages for tooling via npm.
The package `torii` is not a properly formatted package, we have used a fallback lookup to resolve it at `/Users/jack7913/dev/auth-test/node_modules/ember-cli-simple-auth-torii/node_modules/torii`. This is generally caused by an addon not having a `main` entry point (or `index.js`).
installing
Installing browser packages via Bower...
  cached git://github.com/simplabs/ember-simple-auth-component.git#0.7.3
Installed browser packages via Bower.
Installed addon package.
sarjanen commented 9 years ago

@jrowlingson I had to start using simple-auth 0.6.7 and torii 0.2.1 because the 'env' issue broke my whole app. Now i'm only getting the error below but it works.

"The package `torii` is not a properly formatted package, we have used a fallback lookup to resolve it at `/Users/timmiegoranssonsarjanen/Documents/Ruby On Rails/festivalkartan-frontend/node_modules/torii`. This is generally caused by an addon not having a `main` entry point (or `index.js`).
The package `torii` is not a properly formatted package, we have used a fallback lookup to resolve it at `/Users/timmiegoranssonsarjanen/Documents/Ruby On Rails/festivalkartan-frontend/node_modules/ember-cli-simple-auth-torii/node_modules/torii`. This is generally caused by an addon not having a `main` entry point (or `index.js`)."
jrowlingson commented 9 years ago

@Padchi Thanks - I will use this workaround until the 'env' issue is resolved.

timini commented 9 years ago

Yep will revert to old simple auth for now

jimjamdev commented 9 years ago

Any news on this fix?

brianally commented 9 years ago

@jrowlingson (and anyone else) the syntax for installing addons has changed

$ ember install:addon ember-cli-simple-auth-torii
version: 0.2.3
The specified command install:addon is invalid. For available options, see `ember help`.

Here's what I'm seeing:

$ ember install ember-cli-simple-auth-torii
version: 0.2.3
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/#watchman for more info.
Installed packages for tooling via npm.
installing
Installing browser packages via Bower...
  cached git://github.com/simplabs/ember-simple-auth-component.git#0.8.0-beta.1
Installed browser packages via Bower.
installing
The `ember generate` command requires an entity name to be specified. For more details, use `ember help`.

That last line is an apparently unrelated bug. Continuing ...

$ ember serve
version: 0.2.3
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/#watchman for more info.
Cannot read property 'env' of undefined
TypeError: Cannot read property 'env' of undefined
    at Class.treeForAddon (/var/www/vhosts/auth-test/node_modules/ember-cli-simple-auth-torii/node_modules/torii/ember-addon/index.js:26:46)
    at Class._treeFor (/var/www/vhosts/auth-test/node_modules/ember-cli/lib/models/addon.js:315:31)
    at Class.treeFor (/var/www/vhosts/auth-test/node_modules/ember-cli/lib/models/addon.js:285:19)
    at /var/www/vhosts/auth-test/node_modules/ember-cli/lib/models/addon.js:238:32
    at Array.map (native)
    at Class.eachAddonInvoke (/var/www/vhosts/auth-test/node_modules/ember-cli/lib/models/addon.js:236:22)
    at Class.treeFor (/var/www/vhosts/auth-test/node_modules/ember-cli/lib/models/addon.js:283:20)
    at EmberApp.<anonymous> (/var/www/vhosts/auth-test/node_modules/ember-cli/lib/broccoli/ember-app.js:342:20)
    at Array.map (native)
    at EmberApp.addonTreesFor (/var/www/vhosts/auth-test/node_modules/ember-cli/lib/broccoli/ember-app.js:340:30)
brianally commented 9 years ago

This has been fixed in Torii 0.3.4. In fact there have been several recent fixes for ember-addon/index.js. The problem here was referencing this.app.env instead of process.env.EMBER_ENV.

Unfortunately, simply doing:

npm install --save-dev torii
ember install ember-cli-simple-auth-torii

... the latter still installs 0.3.2 in node_modules/ember-cli-simple-auth-torii/node_modules/torii. So, while there was a bug in torii, it looks like there's a problem with ember-cli-simple-auth-torii. How to tell it to either use the already-installed torii, or to upgrade the copy it insists on installing itself?

Even skipping ember's install and doing

npm install --save torii ember-cli-simple-auth-torii

I again get an embedded torii@0.3.2

brianally commented 9 years ago

This is how I worked around the problem:

npm install ember-cli-simple-auth-torii
cd node_modules/ember-cli-simple-auth-torii/
npm install torii@* --save

torii is now at 0.3.4

mgharbik commented 9 years ago

@brian-ally Awesome!

brianally commented 9 years ago

I'm not out of the woods just yet, unfortunately. I also ran:

ember generate ember-cli-simple-auth

... which left me with an ember-simple-auth package inside bower_components. However:

Could not find module `simple-auth/mixins/application-route-mixin` imported from `client/routes/application`

It's defined in bower_components/ember-simple-auth/simple-auth.js but my app isn't finding it. I'm thoroughly confused as to how all of these modules are supposed to be installed. The various repos, and several tutorials, all seem to have slightly different methods. Sometimes the magic really gets in the way.

marcoow commented 9 years ago

As of Ember CLI 0.2.3 the only thing you should have to do to install Ember Simple Auth is ember install ember-cli-simple-auth (you don't even need to run the generate task). Maybe rm -rf tmp/ and restarting ember serve helps?

brianally commented 9 years ago

Maybe the solution was indeed to remove tmp. I'll keep that in mind for the future.

Starting with a clean project:

$ ember --version
version: 0.2.3
0.2.3
...
node: 0.12.0
npm: 2.7.6

$ ember new foo && cd foo
$ ember install ember-cli-simple-auth
$ ember install ember-cli-simple-auth-torii

Now in node_modules/ember-cli-simple-auth-torii/node_modules/ I have only the torii package, and ember-cli-simple-auth is installed at the same level as ember-cli-simple-auth-torii. However, torii remains at 0.3.2. The package.json has:

"version": "0.8.0-beta.1",
...
"dependencies": {
    "torii": "0.3.2",
    "ember-cli-simple-auth": "0.8.0-beta.1"

The package.json for the latest here at github, also 0.8.0-beta.1, has "torii": "0.3.3".

brianally commented 9 years ago
$ npm uninstall --save ember-cli-simple-auth-torii ember-cli-simple-auth
$ bower uninstall --save ember-simple-auth
$ rm -Rf tmp/
$ npm cache clean
$ ember install ember-cli-simple-auth
installing
Installing browser packages via Bower...
  not-cached git://github.com/simplabs/ember-simple-auth-component.git#0.8.0-beta.2
  resolved git://github.com/simplabs/ember-simple-auth-component.git#0.8.0-beta.2

$ ember install ember-cli-simple-auth-torii
installing
Installing browser packages via Bower...
  cached git://github.com/simplabs/ember-simple-auth-component.git#0.8.0-beta.2

This time it installed torii@0.3.3 (Although I bumped it to 0.3.4 as above.) And it works like a charm!