Thanks. I’ll keep this in mind if I need to come back to using Rails. So far, my experiments with Clojure have been successful, so I’m going to continue with that unless and until I hit a show-stopper.
I have already provided the results of my attempts to get this working, more than once.
My guess is that the difficulty here is that there are a lot of moving parts to Rails with significant version sensitivity. In the “Learn Enough Rails to be Dangerous” tutorial, the author cautions against trying to set up your own Rails environment. He used the word “frustration”, as I recall. Instead, he advocates using cloud9, provided by Amazon Web Services, for development, where I’m sure the right combination of versions is provided and his examples work.
You don’t say what version of the MacOS you are running or how you installed ruby, sqlite3, nodejs and yarn. As I posted earlier, I had no luck on my Mac, running up-to-date Catalina. The four packages were installed with homebrew and my versions are somewhat different than yours:
dca@ariadne testit % ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
dca@ariadne testit % sqlite3 --version
3.34.0 2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b
dca@ariadne testit % node --version
v15.5.1
dca@ariadne testit % yarn --version
1.22.10
dca@ariadne testit % rails --version
Rails 6.1.0
@donallen in your original post you indicated “I got the same error on (…) a Mac running Catalina”, where by “same error” you meant Webpacker::Manifest::MissingEntryError
. As this refers to a step occurring after installing/checking your ruby/node/yarn/rails dependencies, I had inferred that you got these installed correctly on your mac. FYI I run macOS Big Sur 11.1 but this should AFAIK not matter directly.
Anyways it appears to me the front-end compilation issue is caused by Node 15 being used although a fresh Rails install will resolve node-sass to 4.14.1 (this is not visible in the logs you provided but I can observe it in my fresh rails new blog
install), which to my understanding is not compatible with Node 15. (NB: This is in the case of a fresh rails new
install, where @rails/webpacker
should resolve to 5.2.1
, but as you had been modifying this dependency in earlier comments please double-check that you indeed have the version 5.2.1 installed—or better, restart from rails new blog
in a new directory just to be sure.)
Therefore brew uninstall node && brew install node@14
or something of that sort would solve your issues, could you try that?
If confirmed it would indeed be good to update the getting started guide to indicate Node 14 is required, or at least instructing the user to check for their compatibility. An even better fix would be to enforce/check this compatibility by specifying the required Node version in the app itself (similar to the line ruby
present in Gemfile
), but I don’t know how that’s done as front-end is not by strong suit.
I get your point that getting started is not that easy, but from my experience, it gets better and I find Rails to be an amazing framework. The more I use it and the more I feel like sticking with it, whereas I can’t say as much about some other technologies. There is also some hope that front-end dev could get easier or more integrated based on some comments of DHH.
PS: as you are just getting started, now could also be a good time to start straight away with Ruby 3 which just came out.
I’ve opened an issue (hoping I understood the situation right):
Installing an earlier version of node is very far from trivial with homebrew. The Mac is not my primary environment – Arch Linux is – and the same is true of Arch. If your theory that all this fuss is being caused by Rails and node v15 not getting along, then I’ve got to do something special to get the right versions installed. I’m just not prepared to do that now. As I said in an earlier message, I’m working with Clojure/Heroku and making progress, though I have seen some version issues there, too. But it seems simpler than Rails, the initial example works and my website is pretty simple – no dynamic pages, no database. So I’m quite sure I can get the site up based on the simple example. I don’t need a Ferrari to drive to the grocery store.
If I’m wrong and returning to Rails seems like the best alternative, then I’ll have to figure out how to get a working Rails environment (probably installing Ubuntu or Debian on a spare machine would be the best approach; both are much more conservative, version-wise, than Arch).
Today I myself (for unrelated reasons) downgraded my mac from Node 15 to 14 and did not encounter special issues. brew install node@14
is actually probably all it takes, I guess it can be installed in parallel with v15 if you want to keep that one too. Then make sure with node --version
that it’s in the PATH for the rails app.
Yes, you’re right. I guess everything you read on the web isn’t necessarily true:-)
I’ve found it helpful to use language version managers to switch between ruby versions, node versions, etc. So instead of using homebrew to install node, I’d use something like Node Version Manager (NVM) or the general purpose version manager ASDF. This is helpful for your use case and for folks who manage multiple/many projects each with their own requirements.
@rossta also in another thread someone recommended chruby over rvm/rbenv for managing ruby versions. Personally I don’t have such tools, just run a single version.
So @donallen is the tutorial working ok for you now?
Yes – the tutorial works with nodejs v14, as you suggested. Thanks for figuring this out and documenting it by submitting an issue. Unfortunately, it has not been acted upon yet – no change to the document.
I did end up coming back to Rails for my project, with which I’m now making good progress after you solved the nodejs version problem. The Clojure stuff is poorly documented and has other problems. So that was not an improvement.
Documentation is part of the project source and ships with new releases. When a new release is out, the documentation for that release is published. There are no intermediate updates.
Ok. Thanks for the explanation.
@donallen normally the issue should be fixed with next release of webpacker:
I experienced the same frustration as I worked through the tutorial here: Getting Started with Rails — Ruby on Rails Guides
I do not have a lot of Ubuntu experience, and found that my problems stemmed from not knowing how to install the latest versions of Node, NPM, and Yarn.
After some searching, I found this great page provided by Node. It showed me how to install on Ubuntu: distributions/README.md at master · nodesource/distributions · GitHub
These commands installed both Node and NPM. In addition, during the install, the commands produced a comment that showed me how to install Yarn.
After getting all the latest versions of Node, NPM, and Yarn installed, I re-created a new Rails application and all of the Webpack issues were gone. Yay!
I am experiencing the same issue on all my ubuntu machines. I installed ruby and rails from Install Ruby On Rails on Ubuntu 22.04 Jammy Jellyfish | GoRails
Then tried to work with Getting Started with Rails — Ruby on Rails Guides
Could not make rails to say “Hello” It says
Webpacker can't find application.js in /home/tarek/Codes/ror_practice/blog/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:
{
}
Make sure to NOT start Rails with the command rails server
. The Ruby on Rails server alone does not compile javascript assets.
With Rails 6.x, you should install the for foreman gem (bundle add foreman). Then you create a file named Procfile_dev
with the following content:
web: bundle exec rails s -p 3000
webpacker: ./bin/webpack-dev-server
When you type foreman start -f Procfile_dev
, that should start both the wev server (Ruby on rails) and the webpacker compiler in watch mode.
When you update a file, the webpacker compiler will detect such a change and re-compile your assets.