Ruby on Rails crash during request - ruby-on-rails

I use windows, ruby 2.5, rails 5.1.7, I have a controller with get request, from Unirest or RestClient libs. When I trigger it, the RoR server closes, I see windows error about ruby.
The same request command processed in rails console fine.
That theme was not helped Ruby on Rails server crashes during a HTTPS POST request
UPDATED
Rubymine log error:
Process finished with exit code -1073741819 (0xC0000005)
Controller code:
u = RestClient.get('https://google.com/')

Windows error 0xC0000005 is memory access violation, it means that something is wrong with binaries - most probable native gem extensions or ruby itself,
so try bundle pristine to reinstall gems and if that does not help - cleanup and reinstall ruby.

Related

Oracle instant client with gem ruby-oci8 not able to connect with DB in rails c

I am using Oracle instant client in my project and using ruby-oci8 gem. I am using Mac Mojave OS
I am able to run the rails server and server does connect with database but when I run rails c and try to connect with any table it throws following error.
Running via Spring preloader in process 95609
Loading development environment (Rails 5.1.1)
User.last
objc[96849]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called.
objc[96849]: +[__NSPlaceholderDictionary initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
/Users/arvindmehra/.rvm/gems/ruby-2.4.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:142: [BUG] Illegal instruction at 0x007fff6efbf2e5
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin18]
I am not able to connect with DB using rails console, strange thing is rails server is working and Application is able to connect with DB.
I was finally able to solve it by upgrading ruby version to 2.4.4 and adding export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES. I guess issue is with Combination of OSX Mojave and ruby-2.4.0 and its actually working for OSX High Sierra

Rails accessing Desk.com api results in RuntimeError concerning FaradayMiddleware

I was pairing with a coworker, and after writing a feature using the desk.com api, everything was working fine. It was deployed to a staging server, where it too worked fine. However, when I run the code on my local dev machine, when I try to query the api (for example, request all the users on our account), I get a runtime error.
I'm using the desk ruby gem: https://github.com/chriswarren/desk
Here is a session in the rails console:
[1] pry(main)> Desk.users
RuntimeError: missing dependency for FaradayMiddleware::Deashify: undefined method `type' for class `Hashie::Mash'
from /home/rooney/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/middleware.rb:20:in `new'
This is the error I get. I haven't been able to find any info on this error. If anyone needs more info just ask.
Methods "type" and "id" are removed in Hashie version >= 3.4.2
You can fix by rolling back to Hashie v3.4.1
Are you using bundle exec? It's possible that you're using the wrong version of a gem. Try uninstalling versions of the gem other than the one you need.

Rails server crashing in windows without any error in stacktrace

Rails server keeps crashing after a few seconds of starting it.
rails version 2.3.8
ruby version 1.8.7
I'm using windows and Apatana Studio.
There is no error in stacktrace too.
Could you please help me to identify what is causing this issue or suggest me where can I check the same? (eg. any specific logs etc.)
Stacktrace :
=> Booting Mongrel
config.load_paths is deprecated and removed in Rails 3, please use autoload_paths instead
config.load_paths= is deprecated and removed in Rails 3, please use autoload_paths= instead
=> Rails 2.3.9 application starting on
/servers/trunk/main/app/models/market.rb:32: warning: already initialized constant MARKET_CODE_US
I solved this by unstalling SQLite and reinstalling from the command line.
gem uninstall sqlite3
gem install sqlite3
Found the solution here: Rails segmentation fault when starting server?
Error says that you already initialized MARKET_CODE_US in your code. And trying to initialize again in your market model.
Find MARKET_CODE_US in your application direction and remove any unnecessary initialization.
In my case, I was not able to connect to Sybase DB from my application. There were issues with the underlying drivers and I hadn't tested connectivity to DB separately (not using my rails app) using those. But there was a .rb script in the driver folders for testing connection to Sybase from a standalone Ruby code. I used that to diagnose issues. So whenever you are setting up dev env from existing code, just test connectivity to required DB using those drivers separately before plugging them together and then testing.

Using Gem Dependencies if a server is 2.0 instead of 2.1

At work for internal Rails applications, the server is running Rails 2.0.4 and Ruby 1.86. As far as I know, that's not going to change anytime soon and I have no control over it. I was going to try and test this out between a couple of computers and was curious if anyone knew what would happen.
Being the server is on 2.0.4, I'd like to build Rails 2.3.5 applications for that server if at all possible. From what I understand so far, it won't be a problem if I freeze gems and upack dependancies. Does that sound right?
Also, the internal work server has no gems beyond what Rails installs. What I'm wondering is, if I can successfully run a 2.3.5 application on the 2.0.4 server, can I also use extra gems and unpack those to use even though the server doesn't have them? I know that it was version 2.1 that introduced Gem Dependencies so would a 2.3.5 Rails app running on a 2.0.4 server be able to use required gems that are unpacked into an application?
One of the worst things with this situation is even if the above stuff works, the server being on 1.86 would exclude me from using a lot of really cool gems that require Ruby 1.87 (like Formtastic).
Thanks
You can manually specify the version of Rails being used in the application in the conf/environment.rb file with the RAILS_GEM_VERSION variable.
You won't be able to gems that aren't installed on your server because the application won't be able to find the libraries.
I went ahead and did the leg work to test this out. If this helps anyone else:
Rails 2.3.5 will run fine on a 2.0.x server.
With Rails 2.1 or above, you can unpack gems and your app will work on a 2.0.x server (lower version server). These are the steps I took in order. The only thing unique here is the Rack version is specific to Rails 2.3.5 (and below). In version 2.3.6 and up they switched to rack 1.1. I'm sticking to 2.3.5 because of the Rack issues with 2.3.6 and up, like broken multipart uploads).
(inside your application directory).
rake rails:freeze:gems
rake gems:unpack:dependencies
(Create a Gems Folder in the vendor folder if it's not there)
(Navigate inside the gems folder: your_app\vendor\gems)
gem unpack rack -v="1.0.1"
(There should now be a folder called "rack-1.0.1" inside the gem folder)
(Navigate back out to your application root folder)
rake gems:refresh_specs
I tested this out using the authlogic gem - moving the project over to a spare laptop that only had Rails 2.0.4 installed and no other gems (except MySQL and Mongrel). The only thing I'm not sure about yet is if a gem that requires a script file be run for installation after the gem file (like Simple Forms) will work. I'm going to test that out next when I get time.

"ERROR Errno::EPIPE: Broken pipe" with Culerity

I've recently installed culerity to use on top of cucumber. But when I run my cucumber specs, they turn red (they were all green before).
The errors I get have this form:
Celerity::Exception::NavigationException:
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException:
500 Internal Server Error for
http://localhost:3001/
(Culerity::CulerityException)
features/admin.feature:82:in `And I am
logged in'
When I look at the web server console (launched by rake culerity:rails:start), the error is:
ERROR Errno::EPIPE: Broken pipe
I've noticed that these errors happen whenever I have cucumber steps (like "go to") that do $browser.goto.
Any idea ?
PS: I have made sure that JRuby is installed and in my path
i believe that an upgrade of jruby to a version matching the patch level of ruby that we were running solved our issue, we had to install jruby from source to get the right one
This is what the readme for the gem states:
I get a broken pipe error:
* make sure JRuby is installed and in your path: running jruby -v should not
produce an error
maybe this is related to the issue that i experienced: http://github.com/langalex/culerity/issues/#issue/29
We ran into a similar problem (broken pipe) with a Rails app on Bundler:
server = Culerity::run_server
didn't actually start the server, leaving
Culerity::RemoteBrowserProxy.new(server, …)
high and dry.
Turns out Bundler messes with RUBYOPT env var (see how Bundler modifies the environment for details), bin/run_celerity_server.rb (from the culerity gem) runs with JRuby as interpreter and JRuby honors RUBYOPT.
As Bundler is not a JRuby gem, the script does not start the server. Culerity::run_server must be invoked in a Bundler-free environment (i.e., with a clean RUBYOPT)

Resources