Debug Ruby/Rails startup issue - ruby-on-rails

Staring at an error like so:
Exiting
/Users/llcool/.rvm/gems/ruby-2.6.3/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/static.rb:111:in `initialize': wrong number of arguments (given 3, expected 2) (ArgumentError)
Where's my best starting point to figuring out what the issue is here? I've tried gem pristine and bundle install but the issue still persists. Some version conflict somewhere I assume.
UPDATE 1
After running some of the commands suggested I'm now getting this error :(
/Users/llcool/.rvm/gems/ruby-2.6.3/gems/bcrypt-3.1.16/lib/bcrypt.rb:12:in `require': incompatible library version - /Users/llcool/.rvm/gems/ruby-2.6.3/gems/bcrypt-3.1.16/lib/bcrypt_ext.bundle (LoadError)
UPDATE 2
Still having issues getting this app to load...
Fast Debugger (ruby-debug-ide 0.7.1.beta3, debase 0.2.5.beta2, file filtering is supported) listens on 0.0.0.0:55189
Uncaught exception: incompatible library version - /Users/llcool/.rvm/gems/ruby-2.6.3/gems/bcrypt-3.1.16/lib/bcrypt_ext.bundle
I've tried update, pristine, uninstall, reinstall, etc all with no luck.

When I have seen this before I delete the Gemfile.lock file, update gem and bundler:
gem update --system
And
bundle update --bundler
Then run bundle install again and see if that clears it up.

Related

Rails / Postgres: Error after changing pg gem version

I encounter this error message when running my specs after messing with gemsets and the pg gem version:
# --- Caused by: ---
# PG::UndefinedColumn:
# ERROR: column "waiting" does not exist
# LINE 1: ...me AS source, age(now(), xact_start) AS duration, waiting, q...
# ^
# /Users/xx/.rvm/gems/ruby-2.3.3#xx/gems/pghero-1.4.2/lib/pghero/methods/basic.rb:84:in `select_all'
I've tried using both versions of pg gem that I've used yesterday(0.18.4 and 0.19.0) by specifiying the exact version in the Gemfile, installing them (bundle install) and confirmed that the version is in deed used by checking Gemfile.lock. Both keep producing the error.
I am not really experienced, especially with Postgres. I don't know how gems and OS-packages play together etc. So I wanted to know if anyone knows what's going on and give me a tip?
Thanks
I have the following questions and advices for you
uninstall all pg gem version in your gemset
uninstall pg hero gem
run bundle install
in case the error still resides then try upgrading the pghero gem - current version is 1.6.2 (mentioning this as your error states pghero)
Did you switch to another ruby version (even minor is relevant)? If so drop the whole gemset (rvm gemset delete) and run a fresh bundle install. This will build all native extensions against the updated ruby version.
Hope this helps.
The problem is Postgres version. in 9.6 pg_stat_activity
... replace the waiting column with wait_event_type and
wait_event.
As workaround you can try change in script, causing exception:
, age(now(), xact_start) AS duration, waiting,
to:
, age(now(), xact_start) AS duration, case when wait_event_type is null then false else true waiting,

Segmentation fault with Rails after upgrading to OS Sierra, possibly related to sqlite3 gem

After upgrading to OSX Sierra I am having an issue with random segmentation faults. It most commonly occurs when running rails test and I believe it is due to the sqlite3_adapter.
My present work around is to simply quit terminal and restart it. This works for about 1 or 2 rails test and by the third one I am almost guaranteed to get another segmentation fault.
Is anybody else having an issue with this or find a better workaround?
$ rails t
Running via Spring preloader in process 13817
/Users/USER/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: [BUG] Segmentation fault at 0x00000000000110
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
Edit:
After digging into the sqlite3_adapter.rb, I see that the line causing the segmentation fault is the creation of a new SQlite3 database.
db = SQLite3::Database.new(
config[:database].to_s,
:results_as_hash => true
)
Edit 2:
Rather than quitting and restarting terminal, I have found that running:
spring stop
stops the problem temporarily. Not a solution, but a better work around.
Edit 3:
This appears to be a problem with Apple's supplied libsqlite3 not being fork safe. More info can be found here:
https://github.com/sparklemotion/sqlite3-ruby/issues/195
For now, I have created an alias at the bottom of my ~/.bashrc file:
alias ss='spring stop'
When the problem occurs, I can now type:
ss
and then rerun the test.
Looks like a patch has been issued! The patch will look for sqlite3 in your brew folder instead of using Apple's supplied version by default. Simply run:
bundle update
to get the latest version of sqlite3-ruby and if you don't already have sqlite3 installed in your homebrew directory, run:
brew install sqlite3
I had the same problem when upgrading to Sierra. A simple bundle update will do the trick! Hope this helps.
Try rebuilding the sqlite3 gem. It has native extensions, and recompiling them in the Sierra environment may fix the issue.
Run:
gem pristine sqlite3
Which should give output like:
Restoring gems to pristine condition...
Building native extensions. This could take a while...
Restored sqlite3-1.3.10
Building native extensions. This could take a while...
Restored sqlite3-1.3.11
I've noticed that I get a segfault as well, when trying to run rails console --sandbox specifically. I found this other question that seemed to fix this issue; specifically running
xcode-select --install
seemed to resolve it. This is by no means scientifically proven yet, however I am now able to run a rails console and all tests without a ruby segment fault.
Same problem w/Sierra. None of the stuff on this page worked for me, i.e. gem pristine sqlite3, xcode-select --install, sqlite3; gem uninstall sqlite3; bundle update. I eventually completely uninstalled the Ruby version with rbenv uninstall 2.3.1, then reinstalled it. This worked. I have no idea why.
I faced the same issue, I upgraded sqlite3 gem to 1.3.12 and it helped
All the previous solutions didn't worked so I've fixed this way:
gem uninstall sqlite3
brew install sqlite3
gem install sqlite3 -- --with-sqlite3-include=/usr/local/Cellar/sqlite/3.15.2/include --with-sqlite3-lib=/usr/local/Cellar/sqlite/3.15.2/lib
(Check the version you have in Cellar)
This is a temporary fix and probably if update the bundle it will stop working and you will do it again but al least I can work on my machine

Rails App - with pg database - errors with setup

I am in rails setup hell.
I tried to make an app 2 years ago and after endless problems with it, I tried to make a fresh app and start again. I"m now having the same problem I had the first time around in getting the pg database setup, but none of the solutions offered for the first problem are working this time. My post about the problem the first time is here: Installing PG gem on OS X - failure to build native extension
Currently - I'm getting this error:
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that gem install pg -v '0.18.4' succeeds before bundling.
I have tried uninstalling and reinstalling pg. I have tried installing with home-brew. I have tried all of the suggestions in the previous post I wrote about this problem with my first app. I've tried the solutions in this post:
Ruby/PgSQL error on Rails start : cannot load such file -- pg_ext (LoadError)
Each time, the gem installs correctly. It's just I can't start the server or do anything from the command line - this error keeps coming up.
One of the steps I tried involved adding this to my command line. It's a straight copy & paste. I don't know what it means. I'm wondering if its a source of my issue:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
When I try:
rake rails:update:bin
I get this error:
rake aborted!
LoadError: cannot load such file -- nokogiri/nokogiri
Does anyone know how to solve this problem? I'm in rails hell!
A similar issue is occur by a user. Please have look to this link. Hope this may helpful!!
Error message: Make sure that `gem install pg -v '0.18.1'` succeeds before bundling

Debugging error in Rails app running on Webrick server

I am running a Rails app on the webrick server and wanted to get error messages to be displayed to me in the console. I installed the debugger 'gem install debugger' and the installation went off without a glitch but when I restarted the server by typing in rails s --debugger, I got:
You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
Therefore I tried installing ruby-debug gem but I got the following error:
ERROR: Error installing ruby-debug:
ERROR: Failed to build gem native extension.
/Users/Me/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
Can't handle 1.9.x yet
* extconf.rb failed *
My query is: what is going wrong with the installation? Secondly, what would be the best way for me to get error messages to be displayed to me?
For sure I'm late but just for anyone stuck on this, I had the same problem and fixed it by adding "gem 'debugger'" to the gemfile and running bundle update

Ruby on Rails TypeError

I have been working on a ruby on rails application and ran into the following error when doing just about anything, including installing a gem, updating the bundle, installing the bundle.
ERROR: While executing gem ... (TypeError)
incompatible marshal file format (can't be read)
format version 4.8 required; 31.139 given
I have uninstalled RVM and completely removed all files from it, then tried to install a gem, but still get the same error.
I had this exact problem, and it took me forever to figure it out. To fix it, I ran the following command:
bundle install --full-index
My guess is that I ended up with a corrupted rubygems index after my computer locked up, and this command forces a fresh download of the index.
Hopefully this helps someone who runs into this.
Change the source in your gemfile to:
source 'https://rubygems.org'
https://github.com/grosser/parallel_tests/pull/183

Resources