tricknotes / ember-cli-rails

Unify your EmberCLI and Rails Workflows
http://thoughtbot.github.io/ember-cli-rails/
MIT License
712 stars 205 forks source link

Cannot build Heroku app with exact steps specified #537

Open hoopsphere opened 7 years ago

hoopsphere commented 7 years ago

Which operating system and version is the project developed on? Mac OS Sierra 10.12.5 Which version of ruby is the project developed on? ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16] Which version of npm is the project developed on? 5.0.3 Which version of ember-cli is the project developed on? 2.13.2 What is the rails version? 5.1.1 What is the ember-cli-rails version (from Gemfile)? 0.9.0 What is the ember-cli-rails-addon version (from package.json)? 0.8.0 Is your application server multi-threaded (such as puma and unicorn) or is it multi-process (such as thin and webrick)? Don't know What are the contents of config/initializers/ember.rb?

EmberCli.configure do |c|
  c.app :frontend
end

What are the contents of the Rails' view that renders the Ember application? Not sure what this means How are the EmberCLI-related routes defined?

Rails.application.routes.draw do
  Rails.application.routes.draw do
    mount_ember_app :frontend, to: "/"
  end
end

How is the application deployed? Trying to deploy on Heroku

I followed the steps religiously at https://github.com/thoughtbot/ember-cli-rails/ but unable to deploy even a sample app.

$ rails new reg2
$ cd reg2

At that point, I started following step by step, starting with adding the gem 'ember-cli-rails.'

I also created a heroku app

$ heroku login
$ heroku create

However, I am unable to push to Heroku. I get this error stack:

reg2 $ git push heroku master
Counting objects: 141, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (122/122), done.
Writing objects: 100% (141/141), 70.33 KiB | 0 bytes/s, done.
Total 141 (delta 11), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 6.x via semver.io...
remote:        Downloading and installing node 6.11.0...
remote:        Using default npm version: 3.10.10
remote:
remote: -----> Restoring cache
remote:        Skipping cache restore (new-signature)
remote:
remote: -----> Building dependencies
remote:        Installing node modules (package.json)
remote:
remote:        > undefined postinstall /tmp/build_e54c4ba6770484a250f8fb43a009a7c4
remote:        > sh bin/heroku_install
remote:
remote:        bower                           ENOENT No bower.json present
remote:
remote:        npm ERR! Linux 3.13.0-112-generic
remote:        npm ERR! argv "/tmp/build_e54c4ba6770484a250f8fb43a009a7c4/.heroku/node/bin/node" "/tmp/build_e54c4ba6770484a250f8fb43a009a7c4/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_e54c4ba6770484a250f8fb43a009a7c4/.npmrc"
remote:        npm ERR! node v6.11.0
remote:        npm ERR! npm  v3.10.10
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! undefined postinstall: `sh bin/heroku_install`
remote:        npm ERR! Exit status 1
remote:        npm ERR!
remote:        npm ERR! Failed at the undefined postinstall script 'sh bin/heroku_install'.
remote:        npm ERR! Make sure you have the latest version of node.js and npm installed.
remote:        npm ERR! If you do, this is most likely a problem with the  package,
remote:        npm ERR! not with npm itself.
remote:        npm ERR! Tell the author that this fails on your system:
remote:        npm ERR!     sh bin/heroku_install
remote:        npm ERR! You can get information on how to open an issue for this project with:
remote:        npm ERR!     npm bugs
remote:        npm ERR! Or if that isn't available, you can get their info via:
remote:        npm ERR!     npm owner ls
remote:        npm ERR! There is likely additional logging output above.
remote:
remote:        npm ERR! Please include the following file with any support request:
remote:        npm ERR!     /tmp/build_e54c4ba6770484a250f8fb43a009a7c4/npm-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        Some possible problems:
remote:
remote:        - Node version not specified in package.json
remote:        https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to desolate-brook-77892.
remote:
To https://git.heroku.com/desolate-brook-77892.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/desolate-brook-77892.git'

These are some of the fixes I have tried but failed with: * In ./package.json, modify sh bin/heroku_install to ./bin/heroku_install * In https://github.com/seanpdoyle/ember-cli-rails-heroku-example, he suggests running generator using rails g ember-cli:heroku but the ember-cli:heroku command is not even recognized; terminal recommends using ember:heroku so that was a dead end as well.

I built the heroku webpacks as such:

$ heroku buildpacks:clear
$ heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-nodejs
$ heroku buildpacks:add --index 2 https://github.com/heroku/heroku-buildpack-ruby
$ heroku config:set NPM_CONFIG_PRODUCTION=false
$ heroku config:unset SKIP_EMBER

Here is what my reg2/package.json (root package.json) looks like:

{
  "scripts": {
    "postinstall": "sh bin/heroku_install"
  },
  "dependencies": {
    "bower": "*"
  },
  "cacheDirectories": [
    "frontend/node_modules",
    "frontend/bower_components",
    "node_modules"
  ]
}

Here is the one in the ember frontend app (reg2/frontend/package.json):

{
  "name": "frontend",
  "version": "0.0.0",
  "description": "Small description for frontend goes here",
  "license": "MIT",
  "author": "",
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "repository": "",
  "scripts": {
    "build": "ember build",
    "start": "ember server",
    "test": "ember test"
  },
  "devDependencies": {
    "broccoli-asset-rev": "^2.4.5",
    "ember-ajax": "^3.0.0",
    "ember-cli": "2.13.2",
    "ember-cli-app-version": "^3.0.0",
    "ember-cli-babel": "^6.0.0",
    "ember-cli-dependency-checker": "^1.3.0",
    "ember-cli-eslint": "^3.0.0",
    "ember-cli-htmlbars": "^1.1.1",
    "ember-cli-htmlbars-inline-precompile": "^0.4.0",
    "ember-cli-inject-live-reload": "^1.4.1",
    "ember-cli-qunit": "^4.0.0",
    "ember-cli-rails-addon": "~> 0.8.0",
    "ember-cli-shims": "^1.1.0",
    "ember-cli-sri": "^2.1.0",
    "ember-cli-uglify": "^1.2.0",
    "ember-data": "^2.13.0",
    "ember-export-application-global": "^2.0.0",
    "ember-load-initializers": "^1.0.0",
    "ember-resolver": "^4.0.0",
    "ember-source": "~2.13.0",
    "ember-welcome-page": "^3.0.0",
    "loader.js": "^4.2.3"
  },
  "engines": {
    "node": ">= 4"
  },
  "private": true
}

Been banging my head against this for a couple days now; would REALLY appreciate your help!

hoopsphere commented 7 years ago

Would appreciate if someone could help me out!

dirtyhenry commented 7 years ago

Not an expert but you're using npm version 5.0.3 when you develop and Heroku says Using default npm version: 3.10.10.

In addition, Heroku says:

remote:     Some possible problems:
remote:
remote:        - Node version not specified in package.json
remote:        https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

Have you followed this tip?

dirtyhenry commented 7 years ago

Also, can you share the content of sh bin/heroku_install?

seanpdoyle commented 7 years ago
remote:        bower                           ENOENT No bower.json present

Seems to be the problematic line of logging output.

https://github.com/thoughtbot/ember-cli-rails/pull/532 added support for skipping bower install when bower.json is absent.

Unfortunately, that commit did not modify the generated heroku_install.sh script.

Does your project have a bower.json file?

If not, could you try removing any bower-related lines from your bin/heroku_install.sh file?

seanpdoyle commented 7 years ago

@hoopsphere was this issue closed intentionally?

Did removing the bower-related lines resolve your build errors?

gohdaniel15 commented 7 years ago

Hey @seanpdoyle. Just deployed my ember-cli-app today and ran into the same issues. I had to go in there and remove the bower-related lines.

Wondering if something could be done about this (eg; for a different heroku_install.sh template to be run if a bower.json file isn't detected in the app || some documentation).

getaclue00 commented 7 years ago

not sure if its relevant but I just uploaded a new project to heroku and it was failing @ running the heroku_install.sh file. I connected to the box via heroku run bash and then checked the contents of /bin and the file is not there. Check contents of my .gitignore and /bin isnt ignored. Wondering why the file isnt getting there.

seanpdoyle commented 7 years ago

@getaclue did you run the ember:heroku generator?

There are some issues with the way Heroku setup currently works. We're actively working Heroku setup to remove the bash script and no longer rely on NPM's postinstall hook.

getaclue00 commented 7 years ago

@seanpdoyle I did -- also ended up just rewriting the postinstall script using inline with the commands that were in that file... and it ran fine. So that's fine for now.

I'm not sure if my problem (I tried to reach out to you on ember's Slack) is related to this or something else. My ember's image assets are not being moved to public folder from the /tmp. Tried to follow https://github.com/thoughtbot/ember-cli-rails/issues/30 but didn't see a solution that worked for me. Currently reading your code-base to see where the cp function is being ran to see why my images are not being carried over.

(and I'm not using a cdn... just wanting it served via Rails I should add)

nruth commented 7 years ago

Just thought I'd comment that things seem to be working OK now with the latest release?

heroku deploy is working well for us in production with the new gem release, with various combinations of yarn/npm, bower/no-bower, and the bin/heroku_install script deleted.

Images are working fine for us too with ember-cli and rootURL settings.