Error running Rails server on OS 10.10.2 - ruby-on-rails

Versions
Mac OS: OSX 10.10.2
Ruby: 2.2.1p85
Rails: 4.2.0
Context
I am following the "Install Rails" tutorial online at www.installrails.com. Finally made it through after encountering many errors. I am on the last step of creating a sample app, which it worked fine, and then running the server. Now, I run into another error.
Errors
Here is what I am seeing:
/Users/Work/.rvm/gems/ruby-2.2.1/gems/json-1.8.2/lib/json/ext/parser.bundle: [BUG] Segmentation fault at 0x00000000000418
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
-- Control frame information -----------------------------------------------
*A lot of information listed here*
-- Ruby level backtrace information ----------------------------------------
*A lot of information listed here*
-- Machine register context ------------------------------------------------
*A lot of information listed here*
-- C level backtrace information -------------------------------------------
*A lot of information listed here*
-- Other runtime information -----------------------------------------------
* Loaded script: bin/rails
* Loaded features:
*And then a long list of files listed here*
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
Don't forget to include the above Crash Report log file.
For details: http://www.ruby-lang.org/bugreport.html
Abort trap: 6
Help
Now, I am wondering if it is the json gem that is causing a problem?
Let me know if you need any of the removed information. The bug report was really long so I removed the codes where it says A lot of information listed here for brevity.

Per a suggestion by #maxd, I ended up having to uninstall and reinstall ruby.
Here is the process I followed.
I uninstalled Ruby with command line rvm remove 2.2.1
I reinstall 2.2.1 with the command line rvm install 2.2.1
Then I reinstalled rails with command line sudo gem install rails
Then I used bundle install to reinstall missing gems
Next, I used gem install rubygems-update to update Rubygems from 2.0.14 to 2.1.
Then I reset gems to pristine condition with gem pristine --all.
Then for some reason I had to rerun bundle install because actionmailer 4.2.0 was no longer showing as being installed, even though it was in the list after the first bundle install.
Finally running rails -v gave me an output of Rails 4.2.0 instead of error codes.
So, I ran rails server and all is well.

I solved this problem. But I not certain this is a GOOD way.
first, I reinstalled ruby. since, I looks like version problem as I see.
rvm reinstall all
and gem install rails. After this process, I can run server with rails server command.
I hope this could be a your solution too. Have a good day :D

I was experiencing the same problem in my mac mini(M1). The following solution worked for me found in the developer forum.
sudo arch -x86_64 gem install ffi
Then
arch -x86_64 pod install

Related

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

Installing Ruby on Rails Application with Ruby Enterprise Edition 1.8.7

I want to install one Application on my CentOS 5.5 which requires Ruby Enterprise Edition 1.8.7 and Rails 2.3.5.
I have installed REE from rubyenterpriseedition.com. To install my application I need to do some settings.
In my .bash_profile I should change PATH = $PATH:$HOME/bin to
PATH=/opt/ruby-enterprise-1.8.7-2012.02/bin:$PATH:$HOME/bin
then to reload
source .bash_profile
To check whether changes have been reflected, we must run which gem. This has to output output:
/opt/ruby-enterprise-1.8.7-2012.02/bin/gem
But Unfortunately it is outputting
[root#local ~]# which gem
/usr/bin/which: no gem in (/opt/ruby-enterprise-1.8.7-2012.02/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/college/bin:/root/bin)
After that when i do
[root#local ~]# gem update --system
bash: gem: command not found
I am getting above error.
But Look at the Actual PATH Below...
[root#local college]# echo $PATH
/usr/kerberos/sbin:/opt/ruby-enterprise-1.8.7-2012.02/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/college/bin:/root/bin:/opt/ruby-enterprise-1.8.7-2012.02/bin
Please help me out to install this application on my CentOS.
I think you are mixing up versions. I see both 2011.03 and 2012.02 mentioned. Please check which version you actually installed and make sure your PATH variable has this version as well.

installing ruby-2.0.0 Error running 'make -j4',

Does anyone have had this same error before while installing ruby 2.0.0 in rails 4.0?
all this in a MAC OS X 10.8.2
Error running 'make -j4'
couldn't find any answers.
I agree with devnull, we would need a log of some sort to narrow down your problem.
Though I did just install ruby 2.0 on a mac 10.8.4 yesterday using RVM.
Try following the instructions here. That made it very simple.
FWIW, here's the process I went through. Some of the commands might be specific to my environment and you may have to adjust accordingly. This process was a mix and mash of recommendations from various sources, but also following along with whatever the output spit out. I found that I was unable to install ruby 2.0 just from following other stack overflow threads as written, so I had to improvise, somewhat. Hope this helps.
Made sure i downloaded the latest Xcode and Command Line tool (seems to be the general recommendation out there)
run 'brew doctor'
run 'brew update'
run 'rvm requirements'
run 'rvm get head'
Kept seeing this error "Can not automatically remove lines with 'rvm_autolibs_flag=' from '/etc/rvmrc', please clean it manually."
run 'rvmsudo --debug' #as recommended in terminal, but this still wasn't fixing the problem, so i tried....
run 'rvmsudo rvm get head' #because the output recommended 'prefix the command with rvmsudo to fix it'
run 'rvm requirements'
run 'rvm install 2.0.0' #error "There is no checksum for 'http://production.cf.rubygems.org/rubygems/rubygems-2.0.5.tgz' or 'rubygems-2.0.5.tgz', it's not possible to validate it.......If that does not resolve the issue and you wish to continue with unverified download
add '--verify-downloads 1' after the command."
run 'rvm reinstall 2.0.0 --verify-downloads 1'
run 'rvm default 2.0.0'
And it finally worked. My Ruby verison is now ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0].

OSX Ruby Error when starting a Rails scaffolding: Could not load OpenSSL

I had been racking my head on this for far too long.
I am installing ruby via RVM. I had no troubles while installing Ruby. The issue come with using openssl with anything in ruby i have tried the what seems to be the standard solution of installing RVM openssl package and reinstalling Ruby with --with-openssl-dir.
I have tired every combination of gcc-4.2 vs llvm-gcc (from Xcode). Homebrew openssl vs RVM openssl. Several versions of Ruby 1.9.3.
I get this error message when running 'rails new projectName'
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using
RVM are available at rvm.io/packages/openssl.
I have edited the Gemfile and I am able to run the 'bundle install' however after that point, when I go to start the server 'rails s', I get the dreaded 'cannot load such file -- openssl'. This has shown up during a couple for the reinstalls as well but the latest mix of using Homebrew openssl and readline doesn't give these errors during install, just when I get to starting the server.
I will be happy to post any config files or setting that are needed to help diagnose the problem. I am using the stable release of RVM and on OS X 10.8.2. I am new to Mac (this is the second day) and have some basic unix experience, so kid glove explanations are welcome.
Try to change the first line in your Gemfile from
source 'https://rubygems.org' to source 'http://rubygems.org'
I think this could solve your problem.

After upgrading Ruby1.9.2 from p180 to p290, libruby dynamic library path isn't updated

I used RVM to upgrade Ruby 1.9.2 from patch level p180 to p290:
rvm upgrade 1.9.2-p180 1.9.2-p290
Then, I used these commands to update my Rails gem and other gems
gem install rails 3.0.5
gem update
Everything seems to be fine; rvm info shows all Ruby binaries and gems have been moved to the correct p290 path (~/.rvm/*/ruby-1.9.2-p290/*).
However, when I go to my Rails application directory and issue the command rails console, I get the error message saying a gem (activesupport-3.0.5) cannot load the libruby.1.9.1.dylib file.
10:30 AM ~/Development/rails_projects/my_app_0515 $ rails console
/Users/whk/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require': dlopen(/Users/whk/.rvm/gems/ruby-1.9.2-p290/gems/serialport-1.0.4/lib/serialport.bundle, 9): Library not loaded: /Users/whk/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.1.9.1.dylib (LoadError)
Referenced from: /Users/whk/.rvm/gems/ruby-1.9.2-p290/gems/serialport-1.0.4/lib/serialport.bundle
Reason: image not found - /Users/whk/.rvm/gems/ruby-1.9.2-p290/gems/serialport-1.0.4/lib/serialport.bundle
. . .
Rails can't find the dylib file in ~/.rvm/rubies/ruby-1.9.2-p180/lib, because the p180 path no longer exists, but the file is in ~/.rvm/rubies/ruby-1.9.2-p290/lib.
From a separate StackOverflow post, I found a workaround is adding this line to .bashrc
export DYLD_LIBRARY_PATH="/Users/whk/.rvm/rubies/ruby-1.9.2-p290/lib:$DYLD_LIBRARY_PATH"
However, I want to understand why the rvm ruby upgrade doesn't take care of the lib path change? Does anyone know a cleaner solution -- one that removes the p180 path from where it is configured?
Here are my environment:
Mac OS X 10.6.6 (Snow Leopard)
rvm 1.8.4
ruby 1.9.2p290
Rails 3.0.5
Thanks!
the problem was in gems native extension - their were nto rebuild during rvm upgrade 1.9.2-p180 1.9.2-p290 - next time please have closer look on the output ... it should give your information what's wrong.
as for this particular use case it shoudl be enough to reinstall the given gem:
gem install serialport -v 1.0.4
... not sure if it should be uninstalled first

Resources