How to restabilize my rails project? - ruby-on-rails

I have a rails 3.2.1 project that after having some troubles deploying to heroku, I deleted the vendor/ folder which caused a slew of issues relating to missing gems, dependency issues, etc.
Now it seems every time I either try running bundle install, or rake assets:precompile, or trying to push to Heroku, I'm met with one bug after another. Fixing one just causes another.
What can I do to nuke my environment clean and start completely from scratch?

Related

Webpacker binstubs not installing correctly

I have a perplexing issue here when trying to implement the Rails Webpacker gem into an existing application.
Unfortunately, I do not have much to offer in the way of debugging information, this is also an internal project, so I have limited options in terms of sharing the entire project source.
I am following the exact steps outlined here: https://github.com/rails/webpacker and have done it multiple times now, but during the bundle exec rails webpacker:install command (after running bundle), I see the message:
Skipped webpack and webpack-dev-server since they already exist.
If you want to overwrite skipped stubs, use --force.
This binstubs most-definitely do not exist in my bin/ directory. Either before or after the webpacker install.
I feel like I have tried everything at this point, and nothing seems to be working:
Reinstalling the gem (multiple versions, even via Git)
Manually creating the binstub from a different project (this "worked" until I tried to run the webpacker:install:react script).
Manually running Yarn, attempting to --force create the binstubs
Tried multiple different configuration tweaks in webpacker.yml
I am just out of ideas at this point. Anything else I should be checking, could try?
This is a fix that worked for me:
I copied these two files into the bin directory of my app and then bundle exec rails webpacker:check_binstubs stopped complaining.
As a side effect it made my app deployable on my Paas with the standard buildpack.

SASS: After every change have to reboot my server

Using: rails4 app
Command: For Connecting and Rebooting in order to see the change.
rake assets:precompile
and
control + c
rails s
Is it normal!! Because, sometime I have to do a lot of change and I don't want to reboot the rails server 2000 times per hour.
It's development machine.
Suggestions would be appreciated.
I'm not sure why you're precompiling while still making changes to your SASS.
During development, if making frequent changes to SASS, I'll have cleaned my assets out and the server will pick up and compile these changes as I make them.
rake assets:precompile
is only used when I push to production
There is some guidance here: http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation on why you might want to precompile locally, but I can't speak for your own projects.
I had a lot of headaches when trying to edit js files and refresh them while my assets were precompiled and they all went away went I ditched it in dev.
I solve it with this command
rake assets:clobber
Thanks anyway.

Ruby on Rails: Rakefile not found, Rake suddenly stops working

I recently decided to convert my app's database from SQLite to MySQL and apache (using xampp). I installed xampp with no issues and I followed Convert a Ruby on Rails app from sqlite to MySQL? SO to prepare my app for the switch. I then attempted rake db:migrate and instantly received this:
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
I back tracked made sure the MySql gem was installed and tried another rake command, no luck. I uninstalled ruby on rails and re-installed, created a fresh app, and still no luck. In fact, as soon as I try to use any rake command after re-installing I get that error. I have checked to make sure the rakefile exists. I have no idea what is going on and I couldn't find anyone with the same issue.
the rake commands were working fine for weeks. At some point in the last 24 hours I messed it up somehow.
One other point of interest, i first installed db explorer before xammp but wasn't able to get it to run.
EDIT: Fixed issue by uninstalling rails, backing up and deleting all apps, deleting .gem folder, removing all global paths. Then re-installed with RailsInstaller, set user Paths, went to rake directory and rake command did not return the perpetrating message. I then created a new app with MySql2 and merged in my original app...
I am still no closer to understanding why rake suddenly stopped working. Therefore, I'm leaving this SO up in case I or another user discovers the cause.

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

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.

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