ember-cli-deploy / ember-cli-deploy-revision-data

An ember-cli-plugin to create a unique revision key for the build
MIT License
21 stars 58 forks source link

Deploy fail: `TypeError: path must be a string` (simple-git) #43

Closed ludalex closed 7 years ago

ludalex commented 7 years ago

I have been getting this error lately:

$ ember deploy production
- TypeError: path must be a string
TypeError: path must be a string
TypeError: path must be a string
    at TypeError (native)
    at Object.fs.statSync (fs.js:844:18)
    at exists (/Users/ldx/Documents/project/node_modules/ember-cli-deploy-s3-pack/node_modules/ember-cli-deploy-revision-data/node_modules/simple-git/src/util/exists.js:7:21)
    at module.exports (/Users/ldx/Documents/project/node_modules/ember-cli-deploy-s3-pack/node_modules/ember-cli-deploy-revision-data/node_modules/simple-git/src/util/exists.js:28:11)
    at module.exports (/Users/ldx/Documents/project/node_modules/ember-cli-deploy-s3-pack/node_modules/ember-cli-deploy-revision-data/node_modules/simple-git/src/index.js:10:21)
    at /Users/ldx/Documents/project/node_modules/ember-cli-deploy-s3-pack/node_modules/ember-cli-deploy-revision-data/lib/scm-data-generators/git.js:14:7
    at initializePromise (/Users/ldx/Documents/project/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:588:5)
    at PromiseExt.Promise (/Users/ldx/Documents/project/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1076:31)
    at new PromiseExt (/Users/ldx/Documents/project/node_modules/ember-cli/lib/ext/promise.js:32:8)
    at CoreObject.module.exports.CoreObject.extend.generate (/Users/ldx/Documents/project/node_modules/ember-cli-deploy-s3-pack/node_modules/ember-cli-deploy-revision-data/lib/scm-data-generatorPipeline aborted

The culprit is the latest version of the package simple-git@1.59.0 . If I pin it to 1.57.0 in my package.json it works again.

MarkMT commented 7 years ago

I've just run into this as well. I don't think simple-git is the real problem. 1.59.0 adds an exists test that fails, but this is apparently because the following method in ember-cli-deploy-revision-data/index.js

      _getScmData: function() {
        var ScmDataGenerator = this.readConfig('scm');
        if (ScmDataGenerator) {
          return new ScmDataGenerator({
            plugin: this
          }).generate();
        } else {
          return Promise.resolve();
        }
      }

instantiates ScmDataGenerator with {plugin: this}, but the init() method in lib/scm-data-generators/git.js wrongly (I believe) uses that to set its path property:

  init: function(path) {
    this._super();
    this.path = path;
  }

When ScmDataGenerator's generate() method is called, that path gets passed to simpleGit() and the error "TypeError: path must be a string" happens because {plugin: this} is not a string.

josephroffey commented 7 years ago

Ahh so you think it was failing silently before? Makes more sense, I was struggling to understand how that could ever have been a path... May I suggest using 1.57 for now to not break code that depends on this project, but then opening a fork/branch to fix the path used in ScmDataGenerator?

kpfefferle commented 7 years ago

@ludalex @MarkMT @josephroffey I've submitted #45 with a fix for this by passing the context.distDir string to the ScmDataGenerator initializer. Can you try it out and chime in if it fixes this error for you as well (or doesn't)?

noslouch commented 7 years ago

@kpfefferle I just deployed something using your branch and it worked as a drop-in replacement

MarkMT commented 7 years ago

Thanks, works perfectly here.

ghedamat commented 7 years ago

will close the issue then, thanks again @kpfefferle for the fix, and sorry for the trouble guys