mnyon-grandkru / knowledgebase

An issue tracker of error messages discovered while developing as well as their solution.
https://github.com/mnyon-grandkru/knowledgebase/issues
MIT License
2 stars 0 forks source link

Error getting semantic-ui dropdowns to work on Rails app #95

Closed mnyon-grandkru closed 1 year ago

mnyon-grandkru commented 1 year ago

A new programmer is currently trying to get semantic-ui working with a Rails 6 and Ruby 3.2.2 app:

Hi. i am new to programming and have been following a course, as part of this i have just started a new project using rail 6.1.7.3 and ruby 3.2.2 with semantic-ui for styling. i can get semantic working but the dropdowns dont work. it seems packs/manifest.json is not being created

Error with empty manifest.json

ActionView::Template::Error (unexpected token at ''): 8: <%= csp_meta_tag %> 9: 10: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 11: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> 12: 13: 14:

app/views/layouts/application.html.erb:11

Error message with filled in manifest.json

Started GET "/packs/js/application-0777f7a506acd75b1bfd.js" for ::1 at 2023-04-30 21:26:03 +0100

ActionController::RoutingError (No route matches [GET] "/packs/js/application-0777f7a506acd75b1bfd.js"):

I've opened up a Rails 6.1.7.3 instance and will try to replicate.

Spudos commented 1 year ago

as far as i can understand the problem even though webpacker is installed public/packs/*.json files do not exist which is why i am getting the error when the page tries to load.

i can "fudge" it by creating a manifest.json fine and filling it with boiler plate code but then it looks for the other two .js files in public/packs and doesnt find them so the app runs but returns the error in the console and dropdowns dont work

mnyon-grandkru commented 1 year ago

Ah, let's also add the repo while we're at it (updated to point to Spudos)

Spudos commented 1 year ago

further testing carried out......

i following the following steps to generate my app

rails 6.1.7.3 new appname

set up my root path in routes.rb

root 'home#index'

create my home_controller.rb and add

class HomeController < ApplicationController

end

then create a home folder in layouts and index.html.erb in there, adding some example text

rails s to run the server

go to localhost:3000

and i get the error

Webpacker can't find application.js in /Users/andypierce/Desktop/testy/public/packs/manifest.json. Possible causes:

  1. You want to set webpacker.yml value of compile to true for your environment unless you are using the webpack -w or the webpack-dev-server.
  2. webpack has not yet re-run to reflect updates.
  3. You have misconfigured Webpacker's config/webpacker.yml file.
  4. Your webpack configuration is not creating a manifest. Your manifest contains: { }

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

i can get the app to run by creating the packs folder in public and making a manifest.json file and copying some boiler plate code in there but that is call other .js files that dont exist

i have tried installed yarn and webpacker but nothing seems to create the missing files

Conclusion - its something to do with how i am creating the app as its falling over at stage one by trying to call files in public/packs that dont exist

the repo of my app that doesnt work is [https://github.com/Spudos/chat]

mnyon-grandkru commented 1 year ago

hi @Spudos,

How was this resolved? Were you able to create a manifest.json that Rails accepts, or is this still a challenge?

mnyon-grandkru commented 1 year ago

Hi @Spudos

I was looking at your Gemfile and noticed that you don't have the sprockets-rails gem in the Gemfile. I'd try adding/installing that gem and see if that helps.

Spudos commented 1 year ago

ok i will try that.

I think it is my environment that is messed up, probably from installing several versions of rails and not using gemsets to split it all up

mnyon-grandkru commented 1 year ago

@Spudos Could you benefit from a screencast on using rvm to separate environments and setup to start? Since we're not due to meet until next week, I figured this may help when you have some downtime over the next few days: https://www.youtube.com/watch?v=cQVb7fHFjSM

Spudos commented 1 year ago

thanks i will watch that later