"ERROR Errno::EPIPE: Broken pipe" with Culerity - ruby-on-rails

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)

Related

`<module:RailsSettings>': uninitialized constant ActiveSupport::CurrentAttributes when running rails server

I have a ROR application I'm trying to stand up locally on a windows machine. Since it requires passenger I am using WSL2 to run Ubuntu. I've installed ruby (2.6.5) and made sure rails in installed (4.2.11.3). I've run bundle install successfully, but every time I try to run a command such as rails server, rake, ect. I get an error saying uninitialized constant ActiveSupport::CurrentAttributes. From googling, there isn't really one answer for this. I've tried removing and re-installing rails. Removed railties as well, but the error keeps happening. My suspicion is that it has something to do with me running on WSL2, but I am not sure.

Bundler::RubyVersionMisMatch when Rails controller invokes external script

Ubuntu 20 > Apache 2.4 > Passenger 6 > ruby 2.7.4 > Rails 6.1 > `ruby script`
I'm invoking a ruby script via backticks from within a Rails controller (and collecting a return integer).
In production, somwhere in this chain, something is insisting on trying to run the ruby script with ruby 2.7.0 (the native system version) and complaining that it should be 2.7.4 (which it should).
The Rails app itself runs fine until I invoke a script.
When invoking the script, Passenger (I think?) is logging in the Apache error.log with
/home/rcm/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/definition.rb:495:in `validate_ruby!':
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.4 (Bundler::RubyVersionMisMatch)
I have searched and tried numerous suggestions (most of which were already done).
All scripts use: #!/usr/bin/env ruby
$PATH includes /home/rcm/.rbenv/shims:/usr/local/sbin:... and the usual suspects (I see that's rather explicit with /home/rcm/.rbenv instead of ~/.rbenv --- does it matter?)
The apache .conf file has: PassengerRuby /home/rcm/.rbenv/versions/2.7.4/bin/ruby
I have .ruby-version files at every layer I can think of specifying 2.7.4
I have used rbenv to declare global 2.7.4.
I have updated bundler.
I have run bundle install.
Restarted apache, rebooted the system, etc.
I can't figure out where in the chain anything could be trying to run the script with 2.7.0.
It all works fine in dev mode on macOS and Ubuntu, and even works fine running the project in e -production mode with the built in Puma on both macOS and Ubuntu. Only in the full Apache > Passenger production mode is there a problem. So, I'm thinking it has to be Passenger that's confused, but it's running the Rails app itself just fine -- which makes me confused.
The screwy part is, this was all working fine, and "all of a sudden" I'm getting this failure. (No idea which bit I twiddled.)
Would appreciate any ideas to give me something new to chase. Thanks.
ruby is not necessarily the same as the ruby running Rails. It will run whatever the first one it finds in its PATH. Since this is running on a webserver, this will be different from the PATH of your own user.
Use bundle exec ruby to run the Ruby associated with the application.
The best thing to do is to not run a script, instead incorporate the script code as a class in your Rails project. This is faster and easier to test.

thinking sphinx index rebuild with ruby error

Running a cron job via Whenever gem where rake "ts:index" is set to run at a certain frequency, the sphinx_index.log is returning an odd error (the only info in the log):
Your Ruby version is 1.9.3, but your Gemfile specified 2.2.3
if bundle exec rake ts:rebuild is run on the server manually, the process executes properly. (I have yet to test whether the indexing does actually occur and picks up changes). The Ubuntu server does have 2.2.3 installed, though it may have had 1.9.3 natively installed.
Why is this occurring and what is its consequence?
It sounds like cron isn't picking up your preferred Ruby version. If you're using RVM, then https://stackoverflow.com/a/24092907/54500 might be helpful? I'm not sure what's needed for other Ruby version managers.
Pat's answer is the correct thread of investigation.
Ben Scheirman's solution works as described for applications using the whenever gem. To use the proper ruby versions, rbenv's shims folder needs to be declared to the PATH.

Rails could not find gem, found in bundle show

So if I try to start my server I get the error
Could not find abstract-1.0.0 in any of the sources
Try running bundle install.
I run that and I get
Using abstract (1.0.0)
Furthermore running a bundle show abstract gives me the correct path for the gem. That path is also referenced in gem env.
I'm really not sure how it can't be found...
You might have conflicting installations of ruby. One with the proper gem which you are using in the shell but one the server is using which doesn't have it installed properly.
I would check your environment variables to see if there is a conflict.
This can also happen if you are using RVM and have switched to a different version/gemset than the default one.
What command are you using to start the server?
If rails server is what is giving you the error, I recommend trying: bundle exec rails server
If that's not the issue, another question that might help troubleshoot; are you using rvm? What does rvm info give you?

Capistrano user-related problem

I'm deploying a rails application using Capistrano to a shared server (on WebFaction). This means there are several different Ruby version installed there.
Everything works fine until I want to run some rake tasks. These tasks fail by saying I don't have the right RubyGems version.
From this thread I understood that fixing it would be as easy as adding the full path to the correct rake folder to my rake commands. I tried that but failed again, now because the Ruby interpreter that is used is the wrong one.
I assumed that capistrano would use the username/password I gave it to run commands on the server but it seems not to be the case.
Am I missing something? How can I fix that?
Thanks!
This is indeed a path issue. I solved it by symlinking my ruby, rake, and rails executables to my path. For instance, if the executables that you want (but are failing to work) are located at /opt/ruby/bin/ruby, you'll symlink it to:
ln -s /opt/ruby/bin/ruby /usr/local/bin/ruby

Resources