gjaldon/heroku-buildpack-phoenix-static

NPM errors when deploying umbrella application

Closed this issue ยท 11 comments

Hi!

I'm trying to deploy a umbrella application to Heroku, but I'm getting error messages:

npm ERR! addLocal Could not install /tmp/build_7b768e9efd1d658613a08beb7fffbf0e/deps/phoenix
npm ERR! addLocal Could not install /tmp/build_7b768e9efd1d658613a08beb7fffbf0e/deps/phoenix_html

phoenix_static_buildpack.config

clean_cache=true
compile="compile phoenix_static_buildpack.compile"
node_version=6.9.2
phoenix_relative_path=apps/web
remove_node=true

phoenix_static_buildpack.compile

info "Building Phoenix static assets"
brunch build --production
mix phoenix.digest

elixir_buildpack.config

erlang_version=19.2
elixir_version=1.4.0
always_rebuild=true

Been googling it for a while, but I can't figure what the issue is. Any ideas?

Thanks!

@robinsjdotcom what does your Phoenix app's package.json look like?

Structure of package.json

{
  "repository": {},
  "license": "MIT",
  "scripts": {
    "deploy": "brunch build --production",
    "watch": "brunch watch --stdin"
  },
  "dependencies": {
    "phoenix": "file:../../deps/phoenix",
    "phoenix_html": "file:../../deps/phoenix_html",
    "cytoscape": "~2.7.14"
  },
  "devDependencies": {
    "babel-brunch": "~6.0.0",
    "brunch": "2.7.4",
    "clean-css-brunch": "~2.0.0",
    "css-brunch": "~2.0.0",
    "javascript-brunch": "~2.0.0",
    "uglify-js-brunch": "~2.0.1"
  }
}

EDIT: The umbrella application can be found here: https://github.com/robinsjdotcom/TrendingHashtagGraph

The phoenix application resides in apps/web

Can you try changing the following lines from:

 "phoenix": "file:../../deps/phoenix",
"phoenix_html": "file:../../deps/phoenix_html",

to:

 "phoenix": "file:./deps/phoenix",
"phoenix_html": "file:./deps/phoenix_html",

You need to point package.json to the to the correct path for the mix packages phoenix and phoenix_html.

I'm having the same problem I still can not solve. I looked at this solution by changing the path from ../../ to ./ and the error persisted. My error log looks like this:

Counting objects: 38, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (38/38), done.
Writing objects: 100% (38/38), 3.41 KiB | 0 bytes/s, done.
Total 38 (delta 25), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Phoenix app detected
remote:
remote: -----> Loading configuration and environment
remote:        Loading config...
remote:        Will use the following versions:
remote:        * Node 6.9.2
remote:        Will export the following config vars:
remote:        * Config vars DATABASE_URL
remote:        * MIX_ENV=prod
remote:
remote: -----> Installing binaries
remote:        clean_cache option set to true.
remote:        Cleaning out cache contents
remote:        Downloading node 6.9.2...
remote:        Installing Node 6.9.2...
remote:        Using default npm version
remote:
remote: -----> Building dependencies
remote:        Installing and caching node modules
remote:        npm ERR! addLocal Could not install /tmp/build_d573960aaf6fc1b60872d19f8af9c918/apps/site/deps/phoenix
remote:        npm ERR! addLocal Could not install /tmp/build_d573960aaf6fc1b60872d19f8af9c918/apps/site/deps/phoenix_html
remote:        npm ERR! Linux 3.13.0-105-generic
remote:        npm ERR! argv "/tmp/build_d573960aaf6fc1b60872d19f8af9c918/.heroku/node/bin/node" "/tmp/build_d573960aaf6fc1b60872d19f8af9c918/.heroku/node/bin/npm" "install" "--quiet" "--unsafe-perm" "--userconfig" "/tmp/build_d573960aaf6fc1b60872d19f8af9c918/npmrc"
remote:        npm ERR! node v6.9.2
remote:        npm ERR! npm  v3.10.9
remote:        npm ERR! path /tmp/build_d573960aaf6fc1b60872d19f8af9c918/apps/site/deps/phoenix
remote:        npm ERR! code ENOENT
remote:        npm ERR! errno -2
remote:        npm ERR! syscall open
remote:
remote:        npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_d573960aaf6fc1b60872d19f8af9c918/apps/site/deps/phoenix'
remote:        npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_d573960aaf6fc1b60872d19f8af9c918/apps/site/deps/phoenix'
remote:        npm ERR! enoent This is most likely not a problem with npm itself
remote:        npm ERR! enoent and is related to npm not being able to find a file.
remote:        npm ERR! enoent
remote:
remote:        npm ERR! Please include the following file with any support request:
remote:        npm ERR!     /tmp/build_d573960aaf6fc1b60872d19f8af9c918/apps/site/npm-debug.log
remote:  !     Push rejected, failed to compile Phoenix app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !	Push rejected to teste-v4.
remote:
To https://git.heroku.com/theapp.git
 ! [remote rejected] heroku -> master (pre-receive hook declined)

Is it a problem with the umbrella structure?

Maybe try adding mix deps.get to phoenix_static_buildpack.compile? I haven't tested this buildpack w/ an umbrella app so w/o actually digging in I probably can't help more right now.

Updated the package.json to "phoenix": "file:./deps/phoenix", "phoenix_html": "file:./deps/phoenix_html". Also added mix deps.get in the phoenix_static_buildpack.compile but it's still failing.

Log

remote: -----> Phoenix app detected
remote: 
remote: -----> Loading configuration and environment
remote:        Loading config...
remote:        Will use the following versions:
remote:        * Node 6.9.2
remote:        Will export the following config vars:
remote:        * Config vars DATABASE_URL
remote:        * MIX_ENV=prod
remote: 
remote: -----> Installing binaries
remote:        clean_cache option set to true.
remote:        Cleaning out cache contents
remote:        Downloading node 6.9.2...
remote:        Installing Node 6.9.2...
remote:        Using default npm version
remote: 
remote: -----> Building dependencies
remote:        Installing and caching node modules
remote: npm WARN package.json @ No description
remote: npm WARN package.json @ No README data
remote:        npm ERR! addLocal Could not install /tmp/build_2b1060c9cfb596c22c5e2f4d68042361/apps/web/deps/phoenix
remote:        npm ERR! addLocal Could not install /tmp/build_2b1060c9cfb596c22c5e2f4d68042361/apps/web/deps/phoenix_html
remote:        npm ERR! Linux 3.13.0-105-generic
remote:        npm ERR! argv "/tmp/build_2b1060c9cfb596c22c5e2f4d68042361/.heroku/node/bin/node" "/tmp/build_2b1060c9cfb596c22c5e2f4d68042361/.heroku/node/bin/npm" "install" "--quiet" "--unsafe-perm" "--userconfig" "/tmp/build_2b1060c9cfb596c22c5e2f4d68042361/npmrc"
remote:        npm ERR! node v6.9.2
remote:        npm ERR! npm  v3.10.9
remote:        npm ERR! path /tmp/build_2b1060c9cfb596c22c5e2f4d68042361/apps/web/deps/phoenix
remote:        npm ERR! code ENOENT
remote:        npm ERR! errno -2
remote:        npm ERR! syscall open
remote:        
remote:        npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_2b1060c9cfb596c22c5e2f4d68042361/apps/web/deps/phoenix'
remote:        npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_2b1060c9cfb596c22c5e2f4d68042361/apps/web/deps/phoenix'
remote:        npm ERR! enoent This is most likely not a problem with npm itself
remote:        npm ERR! enoent and is related to npm not being able to find a file.
remote:        npm ERR! enoent
remote:        
remote:        npm ERR! Please include the following file with any support request:
remote:        npm ERR!     /tmp/build_2b1060c9cfb596c22c5e2f4d68042361/apps/web/npm-debug.log
remote:  !     Push rejected, failed to compile Phoenix app.
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !	Push rejected to trendinghashtaggraph.

@robinsjdotcom @jhonathas what's the output when running heroku buildpacks? Maybe you guys didn't have https://github.com/HashNuke/heroku-buildpack-elixir.git set as the first buildpack and your mix deps didn't get installed before doing npm install.

@gjaldon @jhonathas I got it working with my project.

I didn't alter the path to my deps in the package.json.

In my case the heroku buildpacks was in incorrect order (phoenix buildpack before the elixir buildpack) and I didn't set my environment variables in the elixir buildpack.

Thanks for the update @robinsjdotcom! Closing the issue now. :)

Since @robinsalehjan 's medium post is gone, I wanted to add some detail for those who might have this same problem. If you start a phoenix app and then move it into an umbrella app, the paths in package.json for the phoenix and phoenix_html deps will be wrong. You need to add "../../" to the head of each of those paths, so they are pointing to the umbrella's deps directory. That block should then look something like this:

"dependencies": {
"phoenix": "file:../../deps/phoenix",
"phoenix_html": "file:../../deps/phoenix_html"
},

Combined with properly setting phoenix_relative_path in your buildpack config and ensuring that the buildpack order is correct (elixir first, then phoenix) this shoudl help you get your app going.

State of the app while it was still hosted on Heroku:
https://github.com/robinsalehjan/trendinghashtaggraph/tree/6974976c9e54f233c1ae8060e5fb1193671c0576

In the apps folder you have two applications: web and hashtaggraph, the web application is the phoenix app. Take a look at the buildpack configuration and the package.json files as the paths has to be altered.