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,
Related
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
Does anybody else spend more time wrestling with rails than actually coding with it??
Very new to rails and programming in general, so I apologize if this is a stupidly easy question. I don't know enough to understand what's wrong here.
I upgraded to ruby 2.2.2 and somehow lost rails in the process. I don't know why. Now every time I try to load it again, I get the following:
Could not find a valid gem 'rails' (>= 0) in any repository
I've tried sudo gem install rails and gem install rails to the same effect. I've already checked similar postings here, here, here, here, and here to no effect.
How can I fix this and move on?
Macbook pro 10.10.3
Ruby 2.2.2
Chases-MacBook-Pro:pinteresting Chase$ sudo gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
Chases-MacBook-Pro:pinteresting Chase$ gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
Chases-MacBook-Pro:pinteresting Chase$ bundle install
-bash: bundle: command not found
Chases-MacBook-Pro:pinteresting Chase$
edit
I'm behind a VPN, but that shouldn't make a difference because I've checked this several times and it has never been a problem for coding in the past. Since I live in China I have to use VPN a lot, but most of the coding sites are open.
Right now I'm systematically going through each solution and copying down the error messages.
Here's what happened when I did everything at this link
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
1) railsinstaller.org = the packages are out of date. Nothing over 10.6. Does that matter?
2)where ruby? = -bash where: command not found
3)rvm gem install rails = Please note thatrvm gem ...was removed, trygem install railsorrvm all do gem install railsinstead. ( see: 'rvm usage' )
4) gem install rails = could not find a valid gem 'rails' (>= 0) in any repository.
5) rvm all do gem install rails
= nothing. It just sat there and didn't seem to do anything.
6) curl -L https://get.rvm.io | bash -s stable --autolibs=enabled [--ruby] [--rails] [--trace]
= A bunch of information but no action. I opened to new terminal window 10 minutes ago and it still hasn't done anything.
7) curl -L https://get.rvm.io | bash -s stable --rails
= installs rvm and then ends with the same error could not find a valid gem for rails
8) gem sources -a https://rubygems.org = added the site to the sources... idk if that will change anything...
no change after following all the previous steps
Since I know rails is not on my computer and something might have changed since I did the steps above, I just set my VPN to a new setting and used sudo gem install rails. This appears to have installed rails and many gems, however...
I then ran rails -v and got the following error:
[!] There was an error parsingGemfile: no .<digit> floating literal anymore; put 0 before dot - gem 'rails', 3.2.11
^
/Users/Chase/Desktop/pinteresting/Gemfile:4: syntax error, unexpected tINTEGER, expecting '('. Bundler cannot continue.
# from /Users/Chase/Desktop/pinteresting/Gemfile:4
# -------------------------------------------
#
gem 'rails', 3.2.11
# gem 'sass-rails', '~> 5.0'
# -------------------------------------------`
I solved the same problem as follows:
gem source -a http://rubygems.org/
I think the reason is about https.
After trying all the steps I listed earlier, I connected to VPN through a new setting. The one I was using only routed the VPN through my browser, but the new one affects the entire internet connection. I think this is what finally allowed me to download rails again.
After downloading rails, it was just a matter of messing with the Gemfile to get everything downloaded, and voila!
How do I avoid the circular argument reference warning in activesupport. Happens on ruby 2.2.0
/home/ec2-user/apps/foo_prod/shared/bundle/ruby/2.2.0/gems/activesupport-3.2.21/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
/home/ec2-user/apps/foo_prod/shared/bundle/ruby/2.2.0/gems/ruby-ole-1.2.11.7/lib/ole/types/base.rb:265: warning: duplicated key at line 266 ignored: 4095
Use Rails 3.2.22
gem 'rails', '3.2.22'
OR
warning fixes in version 1.2.11.8:
bundle update ruby-ole
This is an issue of Active Support and has been fixed with these two commits:
https://github.com/rails/rails/commit/8fd52705eda6a2cd7e9a8a5bc723fa094e359eb7
https://github.com/rails/rails/commit/3a30b12c774dfaa72acfe520e823374131631ea9
Unfortunately, these commits have been never included into the 3.2 releases,
because the current last release (v3.2.21) was out on 18 Nov 2014
and after that these commits were merged.
If you don't want to see this warning message definitely, you should change
your Gemfile like this:
# gem 'rails', '3.2.21'
gem 'rails', git: 'https://github.com/rails/rails.git', branch: '3-2-stable'
Otherwise, you should downgrade ruby to 2.1 or wait the release of v3.2.22,
which won't come until a grave security hole is found.
After all, there is no easy way to avoid this issue. Changing Gemfile
for such a trivial annoyance may be an overreaction in my view.
It will delay your deployment process quite a lot.
I was not using compass in my application Based on this post here I upped my Rails version from 4.1.1 to 4.1.9 which worked.
This is compass issue here. They haven't release new version yet so you may need to wait for it.
here is what i did to resolve that, i had the latest ruby and the gems are not compatible with that, so after having a fight for nearly a day i switched to older ruby version using rvm
from ruby-2.2.1 to ruby-2.0.0 ,
again this is not an issue with ruby version but incompatibility with gems,try and have good luck with that.
Well, Here is a solution to this:
Try doing all these changes in your .rbenv/.rvm folder and change in these files:
https://github.com/tmm1/rails/commit/8fd52705eda6a2cd7e9a8a5bc723fa094e359eb7
Hypothetically, updating to Rails 4.2.0 - which you should be able to do via the following commands - should fix this error, although it hasn't worked for me:
rvm use ruby-2.2.0#rails4.2 --create
gem install rails
rails -v
I'm getting the same "circular argument error" message as well (I posted more about my failed attempts to fix it here, will update if I find an answer: Rails gem update not working (version 4.1.1 to 4.2.0) as a solution to "warning: circular argument reference" error).
I altered the time_zone.rb file, instead of now=now, I entered now=Time.now and problem solved.
I ran into the same issue as well, yo can sue the following steps to resolve it (worked for me).
$ gem uninstall compass
$ gem update --system
$ gem install compass
I've tried a number of things like uninstalling/reinstalling rails and gems but to no avail.
When I go into my new project and run rails s or bundle exec rails server I'm getting this error:
bin/rails:6: warning: already initialized constant APP_PATH
/Users/toabui/Sites/cms/bin/rails:6: warning: previous definition of APP_PATH was here Usage: rails COMMAND [ARGS]
Inside my bin/rails I see this code:
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
Does anyone know why I keep getting that error when I run rails s?
I've googled and it seems like there is an error with the spring gem but I can‛t seem to get it to work.
I couldn't find the an_initilizer.rb in my directory and I tried uninstalling/installing the spring gem but it didn't work.
However I did managed to finally get it working.
Apparently there is some conflict with spring and rails 4+.
I needed to run:
rake rails:update:bin
But I ran across another error:
Library not loaded: libmysqlclient.18.dylib
I ran the following command which I found on another stackoverflow post:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Then ran the original command:
rake rails:update:bin
Then run the server command:
rails s
And now my WebBrick Server is running.
rake rails:update:bin to the rescue.
If you are on El Capitan (OS X 10.11), Security Integrity Protection (SIP) will prevent linking into /usr/lib to fix mysql. Link it into /usr/local/lib instead:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
This is work for me.
gem uninstall mysql2
bundle install or gem install mysql2
I was getting the same error. Removed spring from Gemfile and re-bundled. Not really a solution though.
I found the code that created this error in config/initializers/an_initializer.rb
require "lib/a_file_i_need"
I changed it for
require "#{ Rails.root }/lib/a_file_i_need"
I got this error by trying to update rails 4 and imagemagick and rmagick.
So I just ran
gem uninstall rmagick
Select the All Versions option. Then try again
EDIT: This happaned again with me just now because I tried to use a gem without installing the required base gem. In my case the solution was to install 'omniauth-google' before trying to use 'omniauth-google-oauth2', but because I didn't install I got the same error again
I got the same error. I had ruby 2.1.3 and rails 4.1.6 running on Mavericks and then I migrated to Yosemite and installed the 4.2.0 rails version an ruby 2.1.5 and my apps I made in the previous version didn't work with the new one, so I made some gem sets with RVM and installed the 2.1.3 version.
Now when I wanted to run the server I got these error:
bin/rails:6: warning: already initialized constant APP_PATH
/Users/Lexynux/_WebProjects/RoR_Apps/SAIIP2/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
And as tobu mentioned I ran:
rake rails:update:bin
I got this:
LoadError: dlopen(/Users/Lexynux/.rvm/gems/ruby-2.1.3#SAIIP2/extensions/x86_64-darwin-14/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Then I ran this:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
And finally I repeated the first command it the terminal asked me for this:
Overwrite /Users/Lexynux/_WebProjects/RoR_Apps/SAIIP2/bin/rails? (enter "h" for help) [Ynaqdh]
I just typed 'Y' and hit return.
After all this I started working and going well.
Thanks.
I received this error after upgrading postgresql.
$ gem uninstall pg
$ gem install pg
resolved this issue for me.
This happened to me after doing a brew upgrade. My guess is that this broke some gems with native extensions, even though there was no error message pointing to that.
What I ended up doing was completely removing my installed gems (In my case I completely uninstalled and reinstalled the ruby version using rbenv).
Running bundle install recompiled the native extensions, and everything was running again.
I'll post what worked for me.
Comment out
gem 'spring'
Add gem 'net-shh'
and run bundle install
And restart your sever
I got the same error, it happend to be related to gem dotenv.
Instructions were to add the following to Gemfile:
gem 'dotenv', :require => 'dotenv/rails-now'
But as it turned out, dotenv/rails-now caused the error. If you use dotenv don't require rails-now
Are you using pg and mysql in different branches ? If yes, please confirm db config file.
I received this error after upgrading rails. Disabling spring give me a hint that the issue was with:
gem 'google-api-client', require: 'google/api_client'
Changed to:
gem 'google-api-client', '0.9'
Resolved the issue.
I had the same error message output when trying to start an application within a Vagrant environment. It cropped up out of nowhere after zero changes to the application code (and other weird behaviour followed, such as development.rb being deleted upon attempting to run the app).
In the end I simply halted the VM & restarted it, everything was then fine so I'm assuming it was an issue with file syncing / shared folders perhaps? (default Vagrant shared folder being used).
Run these in console:
rake tmp:clear
rake secret
IF rake rails:update:bin gives additional errors:
I had recently been doing some server maintenance and had subsequently updated OpenSSL.
When I tried running the rake rails:update:bin command, I was presented with an error relating to openSSL.
Having rebuilt my version of Ruby (`rvm reinstall ruby-x.x.x' with RVM), both errors went away.
This is always worth a try I guess.
My problem was I was using an outdated version of ruby 1.9.3 with rails 4.2. I upgraded to 2.1.2 , removed the broken project, ran rails new blog to recreate my project, navigated into my newly created app and ran rails server and it worked.
I just had this problem and found that it was being caused by the fact that I had removed a gem from the gemfile without deleting the other require references. In my case, I just had to remove it from config/application.rb.
Had this error recently, it is caused by spring, because of its suggested code in executables:
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
It originally expects a LoadError for spring itself in production, but by this code all other load error will be ignored too.
Thus if you have any other LoadError in rails loading process (for example in routes/init) spring worker startup fails and then there goes branch that tries to load everything again like there was no spring.
For me this issue presented as a result of bundle upgrading rvm-capistrano amongst other things.
Adding this require:false fixed things in the end as per this previous post
gem 'rvm-capistrano', require: false
Although could possibly be an additional issue - as running rake rails:update:bin may have helped clear the initial issue.
After uninstalling Rails 4(RC1) I still get Rails 4 apps generated with rails new.
➲ rails -v
Rails 4.0.0.rc1
➲ which rails
/Users/brandon/.rvm/gems/ruby-1.9.3-p392/bin/rails
➲ gem uninstall rails
Select gem to uninstall:
1. rails-3.2.13
2. rails-3.2.3
3. All versions
>
What's the cleanest way to fix this?
It is quite easy.
gem uninstall rails -v=4.0.0.rc1
gem uninstall railties
gem install rails -v 3.2.13
gem update --system
rails -v
By using commands above I was able to install older version of rails as needed :)
Rails does not come as an all-in-one package. You have a base Rails gem, plus it's many dependencies:
Action Mailer
Action Pack
Active Record
Active Resource
Active Support
Bundler
Railties <---- (contains generators)
Sprockets adapter for Rails
To get rid of your Rails 4 installation as a whole, you must remove all of these gems.
The easiest way to do this is to delete your entire gem folder, then reinstall whatever you need.
Try specifying your installed version:
gem uninstall rails -v=4.0.0.rc1
EDIT:
If you've already uninstalled (which you have), the following should work:
gem update --system
rails _3.2.2_ new app_name # or whatever version you're on
Fortunately, this worked as a simple fix for me:
Please note that in order to shift back to 3.2.13 (or whatever version you'd like to go back to), you must remove Railties as well as Rails.
Just do:
gem uninstall rails
Then, select the version of Rails 4 you have and delete it.
Then, do:
gem uninstall railties
And do the same thing.
When I uninstalled the Rails 4 version of railties, it told me that dependencies for a couple gems (coffee-rails and sass-rails) wouldn't be met. So I just did the same thing with both of them as I did above (such as, gem uninstall sass-rails), and deleted their Rails 4 versions as well. For example, for sass-rails, I had a version installed called sass-rails-4.0.0.rc1, so I uninstalled that version).
And that's it; the terminal will list 3.2.13 as your current Rails version, and new apps will be generated from this version as well.
TL;DR:
The simplest and safest solution to the immediate problem is
gem uninstall railties
Slightly Longer & More Complete Approach
If you want to uninstall everything that gem install rails installed, you can get a list of commands to run with this:
gem dependency rails --pipe | ruby -ne 'puts $_.gsub(/\([0-9\. <>=~,]*\)/,"")' | ruby -ne 'puts "gem uninstall #{$_}"'
Copy those and run them one-by-one, and for each one you'll be told what else depends on it, and asked if you want to go ahead with uninstallation. If you see anything in the list that is not part of rails (say you've installed something else that needs that version of active_record) then leave it, otherwise go ahead and uninstall.
The longer explanation
The version displayed is taken from the version of the railties gem, which is not uninstalled by uninstalling the rails gem.
If you open the rails executable with
vim `which rails`
(or the equivalent with the editor of your choice) you'll see the code at the bottom that decides which version of rails to use based on the version of railties:
#!/usr/bin/env ruby_noexec_wrapper
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/
version = $1
ARGV.shift
end
end
gem 'railties', version
load Gem.bin_path('railties', 'rails', version)
The simplest solution, therefore, is just to gem install railsties. There is no solution built-into RubyGems (that I can find) that will detect which other gems were installed with rails and are no longer used by anything else and uninstall them. RubyGems does not have the idea of an exclusive dependency, so even though nothing else besides rails uses railties, you're still stuck having to know that it (and several other things) are left over and must be manually uninstalled. This is not ideal, but it's what we've got right now, and it's not that bad, especially if you use the solution above to find and remove all the rails dependencies.