Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

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

Closed
RossRothenstine opened this issue Oct 20, 2015 · 23 comments
Assignees
Labels

Comments

@RossRothenstine
Copy link

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
Copy link
Member

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


Thanks 🎇

@RossRothenstine
Copy link
Author

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

@samccone
Copy link
Member

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
Copy link
Author

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
Copy link
Member

@RossRothenstine mind running

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

@RossRothenstine
Copy link
Author

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
Copy link
Member

wow, very confusing, well thanks for the info

@RossRothenstine
Copy link
Author

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
Copy link
Member

(╯°□°)╯︵ ┻━┻

kk I will get to this when a have a spare 🕐

@samccone samccone self-assigned this Oct 21, 2015
@samccone samccone added the bug label Oct 21, 2015
@RossRothenstine
Copy link
Author

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
Copy link
Member

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

@notthetup
Copy link

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
Copy link

woisme commented Oct 21, 2015

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

@samccone
Copy link
Member

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 googlearchive/seed-element#69
Along with this commit fec4690

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 🎇 --- Thanks for all of the reports everyone and the excellent debugging work @RossRothenstine 🅰️

@RossRothenstine
Copy link
Author

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
Copy link
Member

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

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 :) npm/npm#7252 (comment)

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

@samccone samccone reopened this Oct 21, 2015
@notthetup
Copy link

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

@robdodson
Copy link
Contributor

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

@robdodson
Copy link
Contributor

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
Copy link

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
Copy link
Member

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
f9e2d0d#diff-2018087f584c4398b5c3a23fc0e5f9dbR60


I will work on a patch when I have a moment 🕐

@RossRothenstine
Copy link
Author

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

@motss
Copy link

motss commented Oct 24, 2015

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

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

No branches or pull requests

7 participants