Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Local dev instructions result in Webpacker error #62

Closed
jeffmaher opened this issue May 24, 2020 · 9 comments
Closed

[Bug] Local dev instructions result in Webpacker error #62

jeffmaher opened this issue May 24, 2020 · 9 comments

Comments

@jeffmaher
Copy link
Contributor

jeffmaher commented May 24, 2020

Followed the Local development instructions, but on the last step of going to the application in my browser, I got a Webpacker issue.

Steps

(You can basically follow the instructions in the README.md, but for accuracy's sake, placed verbatim what I did on my Mac just in case.)

  1. Get key-submission running at 127.0.0.1:8000: git clone git@github.com:CovidShield/server.git && cd server && docker-compose up
  2. Clone and navigate into this repo on local machine
  3. Install Node.js: nvm install 12.16.3 && nvm use 12.16.3
  4. Install Ruby 2.7.1: rbenv install 2.7.1 && rbenv local 2.7.1
  5. Install MySQL: brew install mysql openssl
  6. Install Mysql2 Gem: gem install mysql2 -- --with-cflags=\"-I/usr/local/opt/openssl@1.1/include\" --with-ldflags=\"-L/usr/local/opt/openssl@1.1/lib\"
  7. Run a local MySQL (running via Docker for tidiness/isolation): rm -rf mysql-data && mkdir mysql-data && docker run -it --rm -p 3306:3306 --name portal-db -v $PWD/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=somepasswordhere -d mysql
  8. Confirm that the database is up in a database tool (TablePlus, in my case)
  9. Update the database.yml file (under default): username: root, password: somepasswordhere, host: 127.0.0.1
  10. Create/setup/seed the database: bundle exec rake db:create && bundle exec rake db:setup && bundle exec rake db:seed
  11. Run the application: KEY_CLAIM_HOST=127.0.0.1:8000 bundle exec rails s
  12. Go to localhost:3000 in browser

Expected Result

Portal web application to render a login or admin screen.

Actual Result

Screen Shot 2020-05-24 at 15 37 51

Other Thoughts

Probably Webpack isn't installed? I'll try that next, but, if that's it, probably should be mentioned in the dependencies. Also, if Docker Compose works (#61 ), these setup steps aren't required.

@jeffmaher
Copy link
Contributor Author

Did npm install webpack, but it did not fix the bug.

@jeffmaher
Copy link
Contributor Author

Next thing I've tried is bundle exec rails assets:precompile, but that results in an error:

...(lots of info statements)...
Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/
Exiting!

Will install Yarn and try again.

@jeffmaher
Copy link
Contributor Author

Tried this next:

brew install yarn
bundle exec rails assets:precompile #This errors, suggests the next command
yarn add -D # This fails with error:Missing list of packages to add to your project.

@jeffmaher
Copy link
Contributor Author

jeffmaher commented May 24, 2020

Next thing I tried:

./bin/webpack -w
# Asks to install webpack-cli, and I say yes

The Webpack server is running, so open a new terminal tab and try this:

KEY_CLAIM_HOST=127.0.0.1:8000 bundle exec rails s

And, I have a login screen! 🥳 🎉

But... 😞

Logging in with the default creds (U: admin@covidshield.app and P: password) results in a different error.

Screen Shot 2020-05-24 at 16 24 11

@LouisStAmour
Copy link

LouisStAmour commented May 24, 2020

I don’t see an npm install or a yarn or yarn install. Try using the Dockerfile’s RUN commands as a set of instructions? https://github.com/CovidShield/portal/blob/master/Dockerfile#L37

As a sanity check, does docker-compose up work locally for you?

@jeffmaher
Copy link
Contributor Author

jeffmaher commented May 24, 2020

@LouisStAmour : A few comments up, did the NPM and Yarn commands (which aren't in the README) -- which gets past the Webpacker error message, but leads to another issue. Unfortunately, Docker Compose didn't work for me either (filed #61 for that).

@jeffmaher
Copy link
Contributor Author

jeffmaher commented May 25, 2020

Perhaps this last part is some aggressive CSRF caching?

This shows up in the logs:

Can't verify CSRF token authenticity.
Completed 422 Unprocessable Entity in 1ms (ActiveRecord: 0.0ms | Allocations: 570)
  
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):

Also, semi-accidental debugging step: I put an Ngrok server in front of this, and when accessed from HTTPS, I'm able to login. (I also had to add the relevant URL to config.host in development.yml)

@TonyLeeVT
Copy link

TonyLeeVT commented May 28, 2020

Hello, I am also experiencing this same issue. Did anyone make progress on troubleshooting it? I added some Application trace info below. Will post back if I find anything.

Application Trace info is the following:
app/views/layouts/application.html.erb:14
app/controllers/application_controller.rb:32:in `switch_locale'

WebpackerError

Per the troubleshooting steps listed, I checked the value of compile and they all seem to be set to true. The blank manifest is step 4, may be the cause?

@jeffmaher
Copy link
Contributor Author

jeffmaher commented May 29, 2020

#73 fixes this issue for me, running via Docker Compose. Thanks!

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

No branches or pull requests

3 participants