exercism / exercism

Crowd-sourced code mentorship. Practice having thoughtful conversations about code.
https://exercism.org
7.35k stars 1.04k forks source link

NoMethodError in GET /js/app.js.map #2089

Closed kytrinyx closed 7 years ago

kytrinyx commented 9 years ago

Exception in exercism.io

NoMethodError in GET /js/app.js.map undefined method `exercises' for nil:NilClass

Stacktrace

lib/app/routes/user.rb:62 - block in <class:User>
kytrinyx commented 9 years ago

Could this have something to do with sourcemapping?

The reason that this is showing in the User routes, is that user slurps up everything that it hasn't previously recognized. That can be dealt with as a simple 404, but the real problem of why we sometimes get a link to the /js/app.js.map should be fixed regardless.

KaoruDev commented 9 years ago

from someone who's never used lineman but is somewhat familiar with js build tools, it looks like a dev version app.js got deployed? Is this still an issue? If so what's the url?

kytrinyx commented 9 years ago

aaah, ok that would make sense. Yes, this is probably still a problem, but I would have to check. Basically JavaScript (well, front-end) is my cryptonite, and I've been ignoring that entire aspect of the project :/ There's a lot that could be done in figuring out how to do it right.

KaoruDev commented 9 years ago

ahh I'm pretty comfortable with front-end things, though I'm not familiar with Angular + Lineman I'll spend sometime getting familiar with the both of them and try to figure out what's going on :+1:

kytrinyx commented 9 years ago

I'm not at all married to lineman. It's my understanding that it was made for a very specific use-case and that I kind of don't have it. If we could figure out a better build system that could integrate well with heroku I would be pretty content to ditch lineman.

KaoruDev commented 9 years ago

Front-end workflow is the new wild-west. There is no clear winner. I'm curious to see how lineman works and figure it out before dismissing it entirely. I think I'm on the right track on my assumptions, looking at: http://exercism.io/js/app.js the script is not minified / uglified. This leads me to suspect the wrong tasks are being run on heroku.

KaoruDev commented 9 years ago

On a high level this is what I've gathered about lineman's workflow:

1) setup custom build-pack on heroku by setting a ENV variable BUILDPACK_URL to https://github.com/linemanjs/heroku-buildpack-lineman-ruby

2) then do normal git push heroku master. The custom build pack will run lineman build and move the production files to where you want them to ( configured via lineman.json )

Source: their docs

Problem: their buildpack is about 2 years old and does not support ruby version 2.1.5 I submitted an issue to let them know of the problem. I tried updating their build back by pulling down heroku's ruby build pack but it still failed to build the production version of the js files.

Workaround: Any changes to the js files we would need to run lineman build and manually move ./frontend/dist/js/*.js to ./lib/app/public/js/

Another work around not involving lineman would be to use a build tool I've been working on and am most familiar with. Though it's not nearly as mature as lineman and obviously I am very opinionated. I suppose this is something we can chat about tomorrow.

kytrinyx commented 9 years ago

Cool, yeah, let's definitely talk about it tomorrow.

kgrz commented 8 years ago

Is my understanding correct when I say the issue here is that we need to run a particular npm-related command before the Ruby related build steps commence on Heroku? If yes, I might have a simpler solution than customized buildpacks. I faced the same problem/usecase in the project I'm currently working. Here are the steps I followed:

  1. package.json should be inside the root of the project so that Heroku will automatically pickup the nodejs buildpack. Heroku figures out which buildpack to use based on the presence of certain files. Gemfile in root directory means it has to use a Ruby buildpack. package.json in root would mean a Nodejs buildpack. If both are present, we can tell heroku which one to use first!
  2. Heroku provides a heroku-postbuild npm script hook that would get run once the packages are installed and ready.
  3. Configure the order of buildpacks that Heroku uses by using the command line app

With these two changes, I didn't have to use any custom buildpacks. Just edit the package.json scripts to point. Here is the relevant portion of package.json:

  "scripts": {
    "webpack:server": "./node_modules/.bin/webpack --debug --output-path-info --devtool=eval --display-modules --watch --config=webpack/webpack.config.js -d",
    "webpack:deploy": "./node_modules/.bin/webpack --config=webpack/webpack.config.js -p",
    "heroku-postbuild": "npm run webpack:deploy"
  },
kytrinyx commented 8 years ago

@kgrz that explains it. The package.json is not currently in the root directory. I will experiment with this. It would be quite a relief to get this sorted out!

kytrinyx commented 8 years ago

@tejasbubane here's more javascript (lineman?) stuff. It's very old and might not be relevant still.

tejasbubane commented 7 years ago

I think all of the above mentioned issues are fixed / not relevant anymore except one. The compiled app.js file is not minified. Although it is gzippped so won't be much of an issue with bandwidth utilization, I think we should minify it nonetheless.

Created a separate issue for that #3261 and closing this.

kytrinyx commented 7 years ago

:heart: :heart: :heart: