yeoman / generator-polymer

Scaffold out a Polymer project
http://polymer-project.org
926 stars 149 forks source link

yo polymer:seed error. "AssertionError: Trying to copy from a source that does not exist" #240

Closed RossRothenstine closed 8 years ago

RossRothenstine commented 8 years ago

I'm getting a stacktrace when I attempt to use the polymer:seed generator.

events.js:141
      throw er; // Unhandled 'error' event
      ^
AssertionError: Trying to copy from a source that does not exist: /Users/212422863/apps/node-v4.2.1-darwin-x64/lib/node_modules/generator-polymer/seed/templates/seed-element/.gitignore
    at EditionInterface.exports._copySingle (/Users/212422863/apps/node-v4.2.1-darwin-x64/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:45:3)
    at EditionInterface.exports.copy (/Users/212422863/apps/node-v4.2.1-darwin-x64/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:23:17)
    at module.exports.yeoman.generators.Base.extend.seed (/Users/212422863/apps/node-v4.2.1-darwin-x64/lib/node_modules/generator-polymer/seed/index.js:125:15)
    at /Users/212422863/apps/node-v4.2.1-darwin-x64/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:368:17)

Versions:

OS: Mac Yosemite node: v4.2.1 npm: 2.14.7 yo: 1.4.8

Listing of the directory generator-polymer/seed/templates/seed-element/

drwxr-xr-x  10 212422863 Domain Users   340B Oct 20 16:13 .
drwxr-xr-x   3 212422863  Domain Users   102B Oct 16 00:10 ..
-rw-r--r--   1 212422863  Domain Users    17B Oct 16 00:10 .npmignore
-rw-r--r--   1 212422863  Domain Users   1.6K Oct 16 00:10 README.md
-rw-r--r--   1 212422863  Domain Users   646B Oct 16 00:10 bower.json
drwxr-xr-x   3 212422863 Domain Users   102B Oct 16 00:10 demo
-rwxr-xr-x   1 212422863  Domain Users   1.1K Oct 16 00:10 hero.svg
-rw-r--r--   1 212422863  Domain Users   1.1K Oct 16 00:10 index.html
-rw-r--r--   1 212422863  Domain Users   4.0K Oct 16 00:10 seed-element.html
drwxr-xr-x   4 212422863Domain Users   136B Oct 20 16:13 test
samccone commented 8 years ago

@RossRothenstine What version of the generator are you using, can you try installing the latest version of the generator


Thanks :sparkler:

RossRothenstine commented 8 years ago

Currently using 1.2.4, rolled back to 1.2.1 and it worked fine.

samccone commented 8 years ago

ok so to be clear 1.2.4 is giving you issues then? I am fairly confident we resolved the issue with the 1.2.3 release with 1.2.4... if not that is disconcerting

RossRothenstine commented 8 years ago

Yes. I attempted the latest, v1.2.3 and v1.2.2. Was only successful at running the seed generator on v1.2.1.

I'm not 100% confident in my setup, seeing how its a work issued Mac with some corporate biz installed on it. I would like to see if any one else can replicate it first.

samccone commented 8 years ago

@RossRothenstine mind running

ls /Users/212422863/apps/node-v4.2.1-darwin-x64/lib/node_modules/generator-polymer/seed/templates/seed-element/

RossRothenstine commented 8 years ago

Sure thing mate.

The below is after a fresh npm install of the latest version.

.           bower.json      seed-element.html
..          demo            test
.npmignore      hero.svg
README.md       index.html

Then, after an uninstall and reinstall of version v1.2.1. (using "npm install -g generator-polymer@v1.2.1")

.           bower.json      seed-element.html
..          demo            test
.npmignore      hero.svg
README.md       index.html

If it's worth anything, here is an ls of my directory after having ran v1.2.1.

total 48
drwxr-xr-x  11 212422863  Domain Users   374B Oct 20 20:10 .
drwxr-xr-x   6 212422863  Domain Users   204B Oct 20 19:51 ..
-rw-r--r--   1 212422863  Domain Users    17B Oct 20 20:10 .gitignore
-rw-r--r--   1 212422863  Domain Users    58B Oct 20 20:10 .yo-rc.json
-rw-r--r--   1 212422863  Domain Users   1.6K Oct 20 20:10 README.md
-rw-r--r--   1 212422863  Domain Users   633B Oct 20 20:10 bower.json
drwxr-xr-x  41 212422863  Domain Users   1.4K Oct 20 20:10 bower_components
drwxr-xr-x   3 212422863  Domain Users   102B Oct 20 20:08 demo
-rw-r--r--   1 212422863  Domain Users   1.1K Oct 20 20:10 index.html
-rw-r--r--   1 212422863  Domain Users   4.0K Oct 20 20:10 my-foo.html
drwxr-xr-x   4 212422863  Domain Users   136B Oct 20 20:08 test
samccone commented 8 years ago

wow, very confusing, well thanks for the info

RossRothenstine commented 8 years ago

FWIW I freshly installed npm, yo, bower, and generator-polymer@1.2.4 on my Windows 10 home machine and got similar output.

C:\Users\Ross\foo>yo polymer:seed my-ele
? ==========================================================================
? ==========================================================================
We're constantly looking for ways to make yo better!
May we anonymously report usage statistics to improve the tool over time?
More info: https://github.com/yeoman/insight & http://yeoman.io
========================================================================== Yes

     _-----_
    |       |    .--------------------------.
    |--(o)--|    | Out of the box I include |
   `---------´   |  Polymer's seed-element. |
    ( _´U`_ )    '--------------------------'
    /___A___\
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

? What is your GitHub username? 212422863
? Would you like to include web-component-tester? Yes

events.js:141
      throw er; // Unhandled 'error' event
      ^
AssertionError: Trying to copy from a source that does not exist: C:\Users\Ross\AppData\Roaming\npm\node_modules\generator-polymer\seed\templates\seed-element\.gitignore
    at EditionInterface.exports._copySingle (C:\Users\Ross\AppData\Roaming\npm\node_modules\generator-polymer\node_modules\yeoman-generator\node_modules\mem-fs-editor\actions\copy.js:45:3)
    at EditionInterface.exports.copy (C:\Users\Ross\AppData\Roaming\npm\node_modules\generator-polymer\node_modules\yeoman-generator\node_modules\mem-fs-editor\actions\copy.js:23:17)
    at module.exports.yeoman.generators.Base.extend.seed (C:\Users\Ross\AppData\Roaming\npm\node_modules\generator-polymer\seed\index.js:125:15)
    at C:\Users\Ross\AppData\Roaming\npm\node_modules\generator-polymer\node_modules\yeoman-generator\lib\base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:368:17)
samccone commented 8 years ago

(╯°□°)╯︵ ┻━┻

kk I will get to this when a have a spare :clock1:

RossRothenstine commented 8 years ago

This diff may be of some use to you. I was able to get this working locally by changing the if statement to check the template path for the .npmignore.

diff --git a/seed/index.js b/seed/index.js
index af603e4..0dcec88 100644
--- a/seed/index.js
+++ b/seed/index.js
@@ -116,7 +116,7 @@ module.exports = yeoman.generators.Base.extend({

     // Handle bug where npm has renamed .gitignore to .npmignore
     // https://github.com/npm/npm/issues/3763
-    if (this.fs.exists('.npmignore')) {
+    if (this.fs.exists(this.templatePath('.npmignore'))) {
       this.fs.copy(
         this.templatePath('.npmignore'),
         this.destinationPath('.gitignore')

Regards

samccone commented 8 years ago

:bow: thx @RossRothenstine I am sure it will be something like that :) -- I am mostly curious what broke it initially

notthetup commented 8 years ago

I'm seeing this on OSX ElCap as well. I'm on node v4.2.1, yo 1.4.8 and generator-polymer 1.2.4.

~/node/lib/node_modules/generator-polymer/seed/templates/seed-element/.gitignore doesn't exist.

woisme commented 8 years ago

Having the same issue with the same error message. I am using a codeanywhere on a node virtual server.

samccone commented 8 years ago

Ok so all fixed @RossRothenstine

Basically what was happening is when we were bundling up the seed elements, npm was trying to be smart and renaming (all) our .gitignore files to .npmignore so the file was no longer there,

This fix https://github.com/PolymerElements/seed-element/issues/69 Along with this commit https://github.com/yeoman/generator-polymer/commit/fec46907cc3a9441245c7d140db8047209734750

Will make it so this error will not hit you.

The reason why this was tricky to reproduce locally, was because the npm renaming behavior only happens on publish thus when deving locally it was mystifying!


Onto 1.2.5 :sparkler: --- Thanks for all of the reports everyone and the excellent debugging work @RossRothenstine :a: :heavy_plus_sign:

RossRothenstine commented 8 years ago

I think this may need further discussion, as I'm still seeing the issue with v1.2.5.

Could it be that the seed/templates/seed-element submodule is at the wrong revision?

samccone commented 8 years ago

You are correct, I am a bit confused as to how I got this to work locally in the last pass :crying_cat_face:

Well I was not super crazy with the idea that adding a .npmignore would prevent this behavior even people on the team are confused by it :) https://github.com/npm/npm/issues/7252#issuecomment-72345759

ok, alas I think we need to copy .npmignore and then rename it to a .gitignore

notthetup commented 8 years ago

Maybe commit the file as npmignore and then rename them to .npmignore on copy?

robdodson commented 8 years ago

@samccone can we use the method outlined about of using fs.exists instead of fs.exists(this.templatePath) ?

robdodson commented 8 years ago

er sorry, I think I reversed my codes. It should check this.fs.exists(this.templatePath(.npmignore))

also, we may want to see if this happens in npm 4 vs 0.12.

wilbertverayin commented 8 years ago

I checked my npm version (2.14.2) and node version (v4.0.0)

events.js:141
      throw er; // Unhandled 'error' event
      ^
AssertionError: Trying to copy from a source that does not exist: C:\Users\wilbert\AppData\Roaming\npm\node_modules\generator-polymer\seed\templates\seed-element\.gitignore
    at EditionInterface.exports._copySingle (C:\Users\wilbert\AppData\Roaming\npm\node_modules\generator-polymer\node_modules\yeoman-generator\node_modules\mem-fs-editor\actions\copy.js:45:3)
    at EditionInterface.exports.copy (C:\Users\wilbert\AppData\Roaming\npm\node_modules\generator-polymer\node_modules\yeoman-generator\node_modules\mem-fs-editor\actions\copy.js:23:17)
    at module.exports.yeoman.generators.Base.extend.seed (C:\Users\wilbert\AppData\Roaming\npm\node_modules\generator-polymer\seed\index.js:125:15)
    at C:\Users\wilbert\AppData\Roaming\npm\node_modules\generator-polymer\node_modules\yeoman-generator\lib\base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:371:17)

wilbert@WILBERTPC /d/Projects/polymer/aj-autocomplete
$ npm --version
2.14.2

wilbert@WILBERTPC /d/Projects/polymer/aj-autocomplete
$ node --version
v4.0.0
samccone commented 8 years ago

yeah this is not an issue with node 4 vs node .12 it is simply an issue with the renaming of gitignore on publish and explicitly trying to copy it, since it is being renamed to npmignore

I think it all is related to https://github.com/yeoman/generator-polymer/commit/f9e2d0da558d0b71525e7019b14667d9f2381f42#diff-2018087f584c4398b5c3a23fc0e5f9dbR60


I will work on a patch when I have a moment :clock1:

RossRothenstine commented 8 years ago

@samccone, thanks for the diligence and speed to fix this issue. +1 mate, I really appreciate it.

motss commented 8 years ago

Had the same issue on Ubuntu 14.04 in version 1.2.5. Rolled back to 1.2.1 and worked fine.