Rails 5.2 on Heroku - missing coffee_script - ruby-on-rails

I have been using Rails 5.2 from the 5-2-stable branch of Rails to use ActiveStorage, now I am updating a bunch of apps to use the released version again. As mentioned in this issue the rails versions from Github all requires coffee_script. Now I want to remove coffee.
I cannot recreate this in my local environment or on CI, but when deploying to Heroku it fails with:
LoadError: cannot load such file -- coffee_script
/tmp/build_2b0eaffa6f7fd662e3233ac5b4de6d62/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
I cannot find any mention of coffee in my code.
Could this be a caching issue on Herkou or similar? Any clues are welcome.
Failing gemfile
https://github.com/fsek/voting/blob/50d063d16ae8d323f0cfe57e5bb6b4299c592019/Gemfile
Working gemfile (separate project, can be deployed)
https://github.com/pensionsupplysning/web/blob/cb256668640e38af4b59e8cf23fbfa939728abb7/Gemfile

Add the gem coffee-rails to your project or migrate to sprockets 4.x and make sure you follow this migration guide: https://github.com/rails/sprockets/blob/master/UPGRADING.md#manifestjs

Related

/config/initializers/secret_token.rb not being generated. Why not?

Currently going through a rails tutorial and I need to make some modifications to /config/initializers/secret_token.rb, however, I can't find this file anywhere within the initializers directory. I am running the latest version of rails. This is the line I used in the terminal to create a rails project:
rails new sample_app
Anyone know why it isn't showing up?
Thanks for pointing this out. The issue is probably due to using Rails 4.1 instead of Rails 4.0 as specified in the Rails Tutorial. It's because of issues like this that Section 1.2.2 states (bold in original)
Unless otherwise noted, you should use the exact versions of all software used in the tutorial, including Rails itself, if you want the same results.
To get things to work, first uninstall the current version of Rails:
$ gem uninstall rails railties
Then follow the instructions exactly as written in the tutorial to install Rails 4.0:
$ gem install rails --version 4.0.4
Generating a test app (skipping Bundler for convenience) and piping the output through grep then verifies that secret_token.rb gets generated:
$ rails -v
Rails 4.0.4
$ rails new test_app --skip-bundle | grep secret_token
create config/initializers/secret_token.rb
At this point, you should be able to follow the rest of the tutorial as written.
By the way, I'm about to start work on a 3rd edition of the tutorial, and will plan to take care of this issue as part of a more general update.
The tutorial you're looking at was likely written for an older version of Rails than you're using.
secret_token.rb existed in Rails 3 and Rails 4.0 apps; it does not exist in Rails 4.1 apps.
It has been replaced in Rails 4.1 by the secrets.yml file:
http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#config-secrets-yml
I am using 4.1.1. Dont copy nothing to the secrets.yml, just dont forget to update the gitignore file (http://www.railstutorial.org/book/beginning#code-gitignore)
With this you can keep going on the tutorial

Downgrading from Rails 3.2.6 to 3.0.11

I am facing issue when I am trying to work with rails 3.0.11. I initially worked with rails 3.2.6. Build a prototype application in Rails 3.2.6, Ruby 1.9.2 and gem 1.8.7. But then found, server on which we need to host is a shared server which can only support Rails 3.0.11, Ruby 1.8.7 and gem 1.7.2.
Hence I want to keep my dev environment exactly same before I ran into further issues. As I found there was some discrepancy in routes.rb of both the versions.
Steps I followed:
Uninstalled rails
Uninstalled ruby
Installed ruby from here.
This installed ruby version 1.8.7-p370 and gem 1.8.7
After this I installed rails by specifying version as 3.0.11
But still when I run command rails -v, it throws an error to me saying 'missing gem rails 3.2.6. Run bundle install to resolve the issue'
When I ran bundle install, it again completely installed rails 3.2.6 and problem remained unresolved.
Please suggest the clean way how shall I start my development on rails 3.0.11 without running into any issues?? Am I need to delete some registry or mapping in my system through which it is detecting rails 3.2.6 and creating issues??
Its urgent as I need to complete my dev by 7th September.
As I am new to stackexchange, please guide is it appropriate to ask question on the same related thread or shall I open new discussion for my problem?
#Gun - please note in response to one of your comments posted above - you DO need to change your Gemfile - if you are running rails -v from withing your project's directory, it will read the Gemfile.
There is a script located at script/rails - this is what runs when you run the rails command from the project directory. NOTE that this rails script requires your config/application.rb file - which in turn reads the Gemfile and bundles the referenced gems. Thus is your Gemfile still references 3.2.6, and it is not installed, rails -v will not work
Glad to hear the problem is fixed :)
As for the asset pipeline - if you are using rails 3.2.6 (or were using it) then you may have been using the asset pipeline to serve your assets (javascript files, CSS files, images, etc). If you were, and you downgrade to anything pre rails version 3.1, then anything being served through the asset pipeline will no longer work.
Here is a pretty good description of the asset pipeline: http://guides.rubyonrails.org/asset_pipeline.html
You should check also remove your Gemfile.lock or manually 'bundle update rails' when you change your rails dependency.
I suggest to use rbenv or rvm to create a virtual environment/sandbox where you can install your preferred ruby versions (e.g. 1.8.7) and keep tracking of your dependencies separately. This would save you a lot of effort.
Keep in mind that rails 3.0 has no asset pipeline support (it has been included in rails 3.1)! This is a very important difference and if you depend on it you will have big issues to solve for the downgrade.
Thanks a lot everyone for help.
I believe it was weird issue. I had heroku on the system. I was initially deploying my app on the same and then changed to another hosting server.
After uninstalling the heroku, it works perfectly fine. Probably, that was interfering somewhere. Although, not sure but problem is resolved.
Thanks a lot again for a great great help!!!
Meanwhile, I would request alup to throw some more light on asset pipeline support. Wots that? Could you please explain more??
Need to delete C:\Users\.ror folder and C:\Users\.gemfile and C:\Users\.gemfile.lock from your desktop..

Cannot running 'rake db:migrate' on a cloned github repo

Since I am new to rails and have learned the very basics from books I now figured that I can learn quite a bit more from reading other peoples code and trying to make sense of it so I have signed up at github and set up everything there. Now I read that one good open source project to learn from is radiant so I went to https://github.com/radiant/radiant and cloned it to a local directory. THen I proceeded as follows:
cd radiant
bundle install, which went fine
rake db:migrate, which first returned:
rake aborted! You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Using bundle exec may sol
So I typed in bundle exec rake db:migrate and recieved the following:
NOTE: Gem.source_index is deprecated, use specification. It will be removed on or after 2011-11-01. Gem.source_index called from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.14/lib/rails/gem_dependency Rake aborted! No such file to load -- radius
So here I am wondering how to fix this problem? I also noticed that a Gemfile and a Gemfile.lock already existed in the radiant folder when it was cloned, which perhaps could be part of the problem?
Also I wonder if it is crutial that I run the same version of rails as the project is written in?
Now it should be said that I currently have rails 3.0.5 installed and run on windows
I hope someone can help me here, it has been quite frustrating since I have not been able to run any cloned github repos (radiant here just being one example).
You should edit your Gemfile and make it require newer rake.
Also you can run rake db:migrate --trace to get additional error information.
The deprecation warning is still just a warning, and it shouldn't be causing you any issues. The part of that error that is relevant is the No such file to load -- radius. You probably need to follow the instructions for installing Radiant, which include running a gem install radiant before dropping this project code somewhere.
Bundler manages installing and using the gems in your Gemfile, and if a Gemfile.lock is present it'll use those exact versions. This means you can't run Radiant with Rails 3.0.5 since the Gemfile specifies 2.3.14. Bundler will install Rails 2.3.14 and its dependencies automatically, though, so you don't need to worry about it.
By the way, this project looks like it has been very mismanaged. It's not common for a Rails project/gem to force you to actually clone it to use it. If you want to check out a Rails 3 project to learn from, I have a slim Rails 3 app that was intended to be an API up publicly on Github with some really clean code: http://github.com/coreyward/instavibe

Problem deploying frozen Rails app - "could not find RubyGem rack"

I have a rails app which I develop on Windows with Rails 2.3.5, using sqlite3 as my database engine, and the internal Mongrel server as my webserver.
I deploy this app to a hosted Linux machine running Rails 2.1.0, using Postgres as my database, and Apache (calling dispatch.cgi) as my webserver. I do not have permissions to update the native Ruby or Rails installations, or to install gems natively.
In order to make my deployment easier (I thought...), I have taken a branch of my code-base for the deployed system. On this branch, I have updated database.yml to refer to postgres and run rake rails:freeze:gems and rake gems:unpack:dependencies. I have then exported this branch to my production server.
When I try to view my app on the production server, I get the error:
Application error
Rails application failed to start properly"
Checking the Apache error logs, I see the following:
./../config/../vendor/rails/railties/lib/initializer.rb:271:in `require_frameworks': Could not find RubyGem rack (~> 1.0.1) (RuntimeError)
from ./../config/../vendor/rails/railties/lib/initializer.rb:134:in `process'
from ./../config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
from ./../config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
from ./../config/environment.rb:9
from dispatch.cgi:5:in `require'
from dispatch.cgi:5
I'm confused. If Rack is required, why wasn't it included by gems:unpack? How can I get this working?
(If it's relevant, vendor$ find . -name rack* gives the following:
./rails/railties/lib/rails/rack
./rails/railties/lib/rails/rack.rb
./rails/railties/lib/rails/.svn/text-base/rack.rb.svn-base
./rails/actionpack/test/controller/rack_test.rb
./rails/actionpack/test/controller/.svn/text-base/rack_test.rb.svn-base
./rails/actionpack/lib/action_controller/rack_lint_patch.rb
./rails/actionpack/lib/action_controller/.svn/text-base/rack_lint_patch.rb.svn-base
)
Rack isn't included because it is a framework gem. To vendor this gem you can manually unpack it into vendor/gems like this:
cd vendor/gems; gem unpack rack -v="1.0.1"
You could also start using bundler to manage your dependencies, as Rails now does by default in version three to avoid problems like the one you're currently experiencing.
Your first problem is that Rails 2.1.0 does not use Rack as a middle layer.
You also need to change the rails version in the config/environment.rb file.
Also, depending on the other gems you have used, you may need to go back to a stable version that works with 2.1.0.
Personally, I would install 2.1.0 on my local machine create a new app with that rails version, copy the app folder over from the 2.3.5 project (and of course your unit tests and public folder, etc, and see if you can get it to run under 2.1.0 on your local machine, substituting gems as you go that are failing in the backtrace on the server log or in the browser. This will be much easier than running in production mode and looking at apache logs. Presuming that you have good unit tests that render all your views and flex your model code, then you should flush out any methods you have used that were added since 2.1.0 that are not supported in the older versions of Rails pretty quickly.

Problems while upgrading the rails version

I'm a newbie to Ruby on Rails. My problem is, I am trying to upgrade the rails version from 1.2.3 to 2.3.4.
I changed the .rhtml files to .html.erb according to the rails version 2.3.4. I changed the environment and boot.rb settings according to the rails version, but when I try to run the application, I'am getting missing template error it is searching for the view with .rhtml extension but not for the html.erb. Please kindly help me with this.
Thank you
Did you change your RAILS_GEM_VERSION in the config/environment.rb file? It may still be looking for the 1.2.3 gem, as opposed to the 2.3.4 gem.
You can make sure whether you have upgraded properly or not by going to script/console and whether it prints out
Loading development environment (Rails 2.3.4)
or not as you enter the console, that might give you some hints.
Check if you have a copy of rails in the vendor directory. Also, what does script/about show?

Resources