Rack seems to think my environment is ' ' when it is production - capistrano3

Rack app error: # in puma log
when running capistrano production deploy.
Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.1.0'
gem 'mysql'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'puma'
group :development do
gem 'capistrano'
gem 'capistrano-rails'
gem 'capistrano3-puma'
gem 'rvm1-capistrano3',require: false
end
gem 'capistrano3-nginx'
deploy.rb:
lock '3.2.1'
set :application, 'foobar'
set :repo_url, '/home/joeradtke/rails/foobar/.git'
set :app_port, '8500'
set :nginx_domains, "radtke.in www.radtke.in"
set :nginx_template, "config/nginx.conf.erb"
set :app_server_socket, "#{shared_path}/sockets/puma-#{fetch :application}.sock"
set :deploy_to, '/home/joe/foobar'
set :deploy_user, 'joe'
set :sudo_user, 'joe'
set :stage, :production
set :puma_init_active_record, true
set :puma_env, :production
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :linked_files, %w{config/database.yml}
set :rvm1_ruby_version, "2.1.2"
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :ssh_options, {
config:false
}
namespace :deploy do
after :deploy, "nginx:restart"
after :deploy, "puma:restart"
end
deploy/production.rb:
server 'radtke.in', user: 'joe', roles: %w{web app}, primary: true
set :ssh_options, {
keys: %w(/home/joe/.ssh/id_rsa),
forward_agent: true,
auth_methods: %w(publickey)
}
Capfile:
require 'capistrano/setup'
require 'capistrano/deploy'
require 'rvm1/capistrano3'
require 'capistrano/rails'
require 'capistrano/puma'
require 'capistrano/puma/jungle'
require 'capistrano/puma/monit'
require 'capistrano/nginx'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
cap production deploy runs fine but
web page at root shows:
"A really lowlevel plumbing error occured. Please contact your local Maytag(tm) repair man."
can server assets so nginx is fine.
I think I've put production everywhere.
Even tried adding
'':
secret_key_base:.................. to secret.yml file.
I've been fooling with this for two days. Usually can find online answer but not for this. Please help.
Joe Radtke

I ran in to this same problem today while migrating an app from an old Rails 1.9.3 Suspenders environment to a new Rails 2.0 environment on AWS.
First the message the error message "A really lowlevel plumbing error occured. Please contact your local Maytag(tm) repair man." is some smartass way of saying that there was an error with Puma and you should look in puma.log to see what the error is...
tail -f /var/log/puma/puma.log
In my case I found this line:
Rack app error: #<RuntimeError: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`>
sadly I'm not nerd enough to tell you exactly why this was an issue, but I can tell you that my config/secrets.yml was not the issue. For some reason that file wasn't getting loaded correctly in production, so I did two things. First I made sure that the puma gem was getting loaded in production:
group :production do
gem 'puma'
end
I still had problems so I had a look at the application.rb file and changed
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
require "http_logger"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
to
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
Which is what we were using in our newer rails environment.

Related

Unable to use metasploit framework(I'm using windows 8.1)

Bundler could not find compatible versions for gem "bcrypt":
In Gemfile:
metasploit-framework x64-mingw32 was resolved to 5.0.102, which depends on bcrypt (=3.1.12) x64-mingw32
Could not find gem 'bcrypt (=3.1.12)', which is required by gem 'metasploit-framework', in any of the sources.
You are missing a ruby dependency required for Metasploit to run. Simply run gem install bcrypt and you should be good to go (unless other dependencies are missing). If you’re using Linux, apt or yum would help you avoid this and automatically install any dependencies along with your desired binary

Selenium WebDriver - Unable to connect to Mozilla geckodriver

I am not able to run automation cases any longer since last time I set up the Centos 7 server things worked very well with the Bitbucket repo and I have the exact repo cloned and am not able to run the this time, please if you can help?
My Gem File is below:
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.2'
# Use sqlite3 as the database for Active Record gem 'sqlite3', '~> 1.3.6'
# Use Puma as the app server gem 'puma', '~> 3.11'
# Use SCSS for stylesheets gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5'
# Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end
group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end
gem 'rspec'
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
gem 'geckodriver-helper'
gem 'cucumber-rails', :require => false
gem 'database_cleaner'
gem 'rspec-retry'
gem 'rubyXL'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data
gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
I have tried all the version till 3.12.0 from the [change log][1], but still get the same error every time which is as below:
unable to connect to Mozilla geckodriver 127.0.0.1:4444 (Selenium::WebDriver::Error::WebDriverError)
It has been more then half day but not able to find a suitable solution.
Thanks!
May be useful, I got a solution after 2 weeks when the bundle update updated some of the gems and then the Chrome and Frirefox browser were launched successfully.

Can I use different versions of a package for different environments?

I have a project where I need to use SQLite in a local environment but Postgres on a normal server.
Unfortunately, there is no SQLite adapter for Ecto 3 yet, forcing me to keep the Ecto and some related packages at 2.x, which caused some problems such as this one: Ecto 2.0 SQL Sandbox Error on tests
I wonder if it would be possible to specify two different versions of Ecto and thus dependencies for the environments :local and :prod. Currently it seems impossible since there is only one lockfile per project. The only way to achieve it seems to be to store two different lockfiles in the project directory? e.g. https://elixirforum.com/t/only-fetch-deps-compatible-for-a-specific-version-of-elixir/16213
I haven't tried it in depth, but maybe changing the mix.exs file like this would help:
defmodule YourProject.MixProject do
use Mix.Project
def project do
[
app: :your_project,
version: "0.1.0",
elixir: "~> 1.7",
start_permanent: Mix.env() == :prod,
deps: deps(Mix.env()),
lockfile: lockfile(Mix.env())
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
defp lockfile(:local), do: "mix-local.lock"
defp lockfile(_), do: "mix.lock"
# Run "mix help deps" to learn about dependencies.
defp deps(:local) do
[{:ecto, "~> 2.0"}]
end
defp deps(_) do
[{:ecto, "~> 3.0"}]
end
end
Both the lockfile and deps are different for the :local environment.

Unable to install sass using Gem from terminal on Windows

I am trying to develop a Web Application using Angular JS. I am about to develop Admin Panel. I will use this template - http://startangular.com/product/flatlogic-angular-material-dashboard/. I need to set up the that admin panel following this instruction - https://github.com/flatlogic/angular-material-dashboard/blob/master/README.md. As you can see, I need to run this command in terminal.
$ gem install sass
I am using Windows 10. All the steps working fine. But when I run that command, it is giving me this error.
What is that error and how can I solve it? Is there a way to solve that step without using that command?
I found the solution. This question saved me.
Error: SASS installation for windows
I run this command
gem source -a http://rubygems.org/
Before running this
gem install sass
This is additional
If you still getting errors, try this.
gem sources --remove https://rubygems.org/
gem sources --add http://rubygems.org
gem update --system
gem sources --remove http://rubygems.org
gem sources --add https://rubygems.org

sunspot with jruby

Hi can sunspot be used with jruby, also here is my app details
jruby-1.6.1
rails 3.0.7
when i install all the gems and run rake sunspot:solr:start it gives me the following error
Gem::LoadError: Could not find RubyGem sunspot (>= 0)
report_activate_error at /Users/dpatel/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems.rb:861
activate at /Users/dpatel/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems.rb:255
gem at /Users/dpatel/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems.rb:1215
(root) at /Users/dpatel/.rvm/gems/jruby-1.6.1#solr/bin/sunspot-solr:18
However when I run rake sunspot:solr:run, it works fine.
Also, when i search using Model.search, it works fine, but I when I fire up solr webapp on the browser and search something, it does not work.
Can anyone tell me what is happening, new to sunspot.
-Thanks
Hi i kinda figured it out, i am on jruby and fork is not allowed on jruby, and rake sunspot:solr:start tries to fork and thrown out an error but
rake sunspot:solr:run starts solr in the foreground and works fine, a little painful but all is well :-)
-D
You already figured out the forking issue, so if you want to stay in a single shell for development and testing I found these aliases to be particularly useful for running sunspot in a particular rails environment and then finding and killing that process when I am done:
If you keep the default ports:
alias sunspot_run_test="RAILS_ENV=test sunspot-solr run &"
alias sunspot_kill_test="fuser -n tcp 8982 -k"
alias sunspot_run_dev="RAILS_ENV=test sunspot-solr run &"
alias sunspot_kill_dev="fuser -n tcp 8982 -k
If you change ports you will need to change the auto-generated sunspot.yml or put a sunspot.rb in config>initializers and you can add a -p{$port_num} before the & on the run aliases and change the explicit port numbers to {$port_num} for the kill aliases.
As Vlad mentioned, it's hard to know what's going on with in the browser from your explanation. One thing that can catch you if you are new to sunspot is that you need to have an instance running in dev environment (use the sunspot_run_dev alias) before you try to CRUD anything in your database or you will get an connection refused error.
See bash aliases not recognized by a bash function: sunspot_rails, jruby, rspec for some more troubleshooting with functions to wrap commands that require sunspot.
For rake issue:
gem install sunspot -v 1.2.rc4
For 'does not work in browser': what do you mean it does not work?
if no result is returned:
You can debug it by comparing Solr requests made by you manually on script/console and the ones made by the server. By default, the sunspot gem logs requests in 'logs/sunspot-solr-development.log'
error (which?)

Resources