Locomotive CMS app crashes after Heroku deploy - Couldn't load redcloth_scan - ruby-on-rails

I have an instance of Locomotive CMS running on Heroku and it has been running fine for about a year. I am the only developer so there have been no deployments since the last working deployment.
Yesterday I made an update to the config/environments/production.rb - all that I changed were the values for the existing ActionMailer settings. Committed and pushed, et voila - the app no longer functions.
The app works on the dev machine, when run in production and dev mode.
I'm a newb when it comes to Rails and Heroku, so I'm having some difficulty interpreting the log.
I've posted the log at: http://pastebin.com/GZpRaue6
The only clear error that I can see in the log is:
Couldn't load redcloth_scan
I have tried adding gem 'RedCloth' to my gems file and bundle installed, as it wasn't explicitly required in the original version of the source, but this has made no difference.
There is no mention of redcloth_scan in my gemfile.lock, but RedCloth is listed as a dependency of Locomotive.
locomotive_cms (2.0.0.rc9)
RedCloth (~> 4.2.8)

After much messing about with the gemfile, each gemfile alteration simply causing different problems with loading the binaries for a different gem. So not an issue specific to redcloth.
I came across this SO post: What is the purpose of vendor/bundle? Heroku tells me to remove it
This use of --path is certainly not an elegant solution, my app never needed this before - something must have changed in Heroku and I'm hoping to be able to move away from this in future. But it's fixed it for now and that's good enough for me.

Related

Redeploying (Updating) Rails App w/ Phusion Passenger

I have what I hope is a simple question. I'm pretty new to rails/web apps, so I apologize for any obvious lack of knowledge demonstrated in asking this question.
Essentially, I've been updating/maintaining an existing Rails app that I didn't develop/deploy. Up to this point, all the changes I've made are so minor that I felt comfortable doing them live (undesirable, I know), but I've recently had to make some changes that involved installing some new gems and updating the database. To do so, I pulled the app/db from the production server, recreated the production environment, and made all necessary changes locally. Put simply, my question is: what is the safest/easiest way to update the app/bundle/db on the production server?
I know there are myriad tutorials regarding deployment with Passenger, but I haven't been able to find anything that specifically references updating an app that's already in production. Is there a distinction between initial deployment and redeploying an updated app?
Tech stack is Ruby 1.9.3, Phusion Passenger on Apache, and PostgreSQL 9.1.3.
Thanks in advance.
You could simply upload the code, run bundle install then bundle exec rake db:migrate and call it a day, but the standard procedure would be to use something like Capistrano, for which myriad tutorials and guides are available on deploying Rails apps.

Missing Gemfiles in Rails Install

Bit of a strange question, but here goes.
I'm a relative beginner to rails, and I've just started working on my second app locally. However, after each install I'm getting the following problem - that several gemfiles are missing (railties being the most obvious).
So, I deleted the install, re-ran it and listed the gemfiles - they are all there. However, after initializing a git repo and pushing the project up to my GitHub a gem list command shows that a number of gems are now missing - at this point I can't run any rake commands or for example rails server.
So I cleared the repo and re-installed. gem list says the gems are all present, server and rake commands work; but push the repo and it subsequently packs up - gem list shows only a handful of gems remain.
Bearing in mind my experience, I'm prepared to believe I'm missing something very obvious, but any advice would be appreciated.
welcome ;-)
I suppose you want to create a Rails 3 application. So first make sure you have installed bundler.
gem install bundler
The steps for creating the application are:
rails new your_app
Then run bundler in the applications folder:
cd your_app
bundler install
Now you should be able to run the application:
rails s
Go and visit localhost:3000. If that does not work, you have other problems. Paste the stack trace then ...
The problem was I forgot that I had two versions of Ruby installed and I had not properly set a default with rvm for some reason. Specifying the default then checking the gems were present for that version of Ruby fixed it.

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..

Some gems work in development but don't get loaded in production environment

Today I've had three issues with gems being loaded in the production environment. First one was HighVoltage, second with ActiveAdmin, and now with SASS (uninitialized constant Sass::Rails::SassTemplate (NameError))
Everything seems to work on my development machine, but once I deploy the app to my nginx & unicorn server, it usually dies while Refreshing Gem list.
It seems to me, that the problem is in the order in which I specify gems in my Gemfile, but I can't figure out a correct way to add them.
I also don't understand, why is this happening only in production with Unicorn, and doesn't happen locally when using WEBrick.
Is there any rule for specifying order of gems in a Gemfile?
Here's my Gemfile
I don't think you can specify gem order in a Gemfile -- Bundler goes through, analyzes dependencies, then installs in an order that works.
But why do you think the problem is one of gem order? That seems extremely unlikely. Let's see the error messages...

Why won't Heroku accept my Gemfile.lock in Windows?

I have a rails application that I deploy on Heroku. I'm using several different machines, and I noticed that when I add new dependencies (so that Gemfile.lock is rebuilt) and do bundle install on my Windows computer at home, push to Heroku fails with the following error:
Unresolved dependencies detected; Installing...
Windows Gemfile.lock detected, ignoring it.
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
...
Gemfile.lock IS under version control, but Heroku appearently chooses to ignore it since it's created in Windows, and then complains that it's missing seconds later. Why does this happen? And how can I solve it?
I fixed mine by opening Gemfile.lock and deleting the following two lines:
PLATFORMS
x86-mingw32
So now i just need to make a script that bundles then removes that from the lock file.
Like matt commented above:
The problem is that Bundler creates different Gemfile.locks for Windows. The only solution is to create and commit the lock file on a *NIX system.
I would suggest to create a virtual machine running e.g. Ubuntu – maybe using Virtual Box. You can even get ready-to-use virtual machines – for example here.
From the Heroku Docs:
If the platforms section of your Gemfile contains Windows entries,
such as mswin or mingw, then the Gemfile.lock file will be ignored.
Just battled through this problem for a while.
I trimmed my gemfile back to just rails and still had the issue. Then, thinking that heroku had demanded an update of the heroku gem today, I looked closer at heroku changes.
It seems the 1.9.2 ruby "bamboo" stack is now the default one - my app is still running on the 1.8.7 stack. So I ran "heroku stack:migrate bamboo-mri-1.9.2" and updated the stack to 1.9.2 - not something I wanted to do, but you know what, it fixed the issue above.
Of course, I didn't want to be on the 1.9.2 stack, so I migrated back down to the 1.8.7 stack, and things installed correctly again. So I think this is a workaround - and probably an overly complex one - but it seemed to "flush" whatever the error was heroku-side. As nothing I did locally (and I tried a LOT of things from StackOverflow articles) had any effect, the push just kept failing as above.
So yeah, this fixes it. Doesn't take too long either. But suspect a better workaround may be spotted by more heroku-knowledgeable developers !
Make sure you commit the changes to Gemfile.lock after installing the bundle. On your next push to Heroku, the new gems should be installed correctly.

Resources