Ruby, Sinatra and Passenger config on Apache - ruby

This is potentially a simple question but I wanted to ask to avoid running around in circles.
I have installed ruby 1.9.2 on Ubuntu and have set up passenger to run with Apache 2.2 on the machine. I am getting the following error when I view the site:
Permission denied - log/sinatra.log
I have changed the permissions for the log directory, but still no luck. The full trace from passenger can be seen on the site page: http://monkeh.me/
Does anyone know if/what I've done wrong or what's happening?
Many thanks
EDIT
I have discovered that the site runs well using WEBrick on port 4567 on the production server, but the same code errors using Passenger. I have added to show exceptions for errors, so am now getting the following:
NoMethodError at /
undefined method `include?' for nil:NilClass
file: resource.rb location: block in attributes= line: 332
You can see this here: http://www.monkeh.me/?url=http://www.google.co.uk
Any ideas? Please help :)

The new issue with the nil class was due to not finalizing the classes properly. I needed to add the following after the models were loaded:
DataMapper.finalize
Thanks to #Frost for his continued help within the comments.

Related

Selenium WebDriverException: Reached error page

I am following a Django TDD tutorial at:
http://www.marinamele.com/taskbuster-django-tutorial/taskbuster-working-environment-and-start-django-project
I get the following error when running 'all_users.py' before and after I start the development server 'python manage.py runserver':
Traceback (most recent call last):
File "functional_tests/all_users.py", line 15, in test_it_worked
self.browser.get('http://localhost:8000')
File "/Users/samgao/.virtualenvs/tb_test/lib/python3.6/site->packages/selenium/webdriver/remote/webdriver.py", line 264, in get
self.execute(Command.GET, {'url': url})
File "/Users/samgao/.virtualenvs/tb_test/lib/python3.6/site->packages/selenium/webdriver/remote/webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "/Users/samgao/.virtualenvs/tb_test/lib/python3.6/site->packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: >about:neterror?e=connectionFailure&u=http%3A//localhost%3A8000/&c=UTF->8&f=regular&d=Firefox%20can%E2%80%99t%20establish%20a%20connection%20to%20the%20s>erver%20at%20localhost%3A8000.
Basically the connection to localhost cannot be established.
The settings and configurations are identical to the tutorial in the previous link.
I have been struggling with the issue for two days, and would thank you most kindly if you could provide any help.
I got the same error and what solved for me was changing from localhost to 127.0.0.1:
old: self.browser.get('http://localhost:8000')
better: self.browser.get('http://127.0.0.1:8000')
I encountered the same problem, the final solution is: re-install again geckodriver
Unzip the geckodriver.zip
Move the file to /usr/bin directory sudo mv geckodriver /usr/bin
Goto /usr/bin directory cd /usr/bin,then you would need to run something like sudo chmod a+x geckodriver to mark it executable.
this might not be your situation, but I got the same error message when running a test (same book, hehe) without having anything actually listening on the targeted port (8000, in my case). Make sure there's something listening for a request by manually opening your browser and going to localhost:8000. In my case - silly me - I didn't have the server up at all =)
I also followed the same tutorial and came across the same error. I noticed that I am not running the django server. The following is what helped.
python manage.py runserver
python functional_test.py
Being that this is a snapshot (around Django 1.8's time) of "Obey The Testing Goat" - perhaps the instructions there are no longer relevant. I suggest going straight to the goat's mouth and starting over!
The issue could be related to virtualenvwrapper (which is no longer necessary) or it could be related to the port/address that you were trying to access. Depending on your version of Selenium and Firefox there may be issues related to that as well.
It depends on the situation.
Based on mine, after I changed the target URL, I can get the browser to load the URL normally, which means the original URL is not available.
Another way to check:
import requests
html = request.get(url)
Print the HTML, if you get the 503, which means the website is reachable.
Since this is probably a common search result for those working through Obey the Testing Goat, I wanted to share the solution that worked for me. I had written self.browser.get('http://localhost:8000') and needed to use http instead of https to resolve the error.
I got this problem in this situation: the application put the computer name to the proxy host,so the proxy like this:
theComputerName:proxyPort
but the theComputerName:proxyPort can not be visit,so I put this into the host:
127.0.0.1 theComputerName
then restart the application,the problem resolved perfect
I learning TDD tutorial too. My problem was that inputed uncorrect url
http://http://mysite insted of http://mysite

Github pages Jekyll static blog outdated

I setup a Jekyll blog on Github-Pages 5 months ago. It was working at that time, and I though it would be a nice place to post things.
Long story short, I wrote a first post, but then I never used, until yesterday when I wanted to check that all was working fine, but it was not. I also could not run Jekyll locally.
I do not use ruby on my daily basis ,so they were outdated. I though maybe if I update it and generate the site again everything is going to be working fine.
I updated ruby from 2.1.2 to 2.2.1, and I tried other things to make it work. Now is working locally, but throwing this
Generating...
Defaults: An invalid front-matter default set was found:
[{"scope"=>{"path"=>"_posts/"}, "values"=>{"author"=>"Agustin Gambina"}}]
Defaults: An invalid front-matter default set was found:
[{"scope"=>{"path"=>"_posts/"}, "values"=>{"author"=>"Agustin Gambina"}}]
I also added a Gemfile to the root directory
source 'https://rubygems.org'
require 'json'
require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
gem 'github-pages', versions['github-pages']
When I run
github-pages health-check
I get this
Checking domain littlebit.me...
Uh oh. Looks like something's fishy: Domain does not resolve to the GitHub Pages server
Does anyone know why it happened to me that is not working anymore? was because it was outdated and something changed?
thank you
You have an error in your _config.yml file :
-
-
scope:
path: "_posts/scala"
values:
author: Agustin Gambina
Must be :
-
scope:
path: "_posts/scala"
values:
author: Agustin Gambina
This is not a fatal error, so your site build, but your rule is not applied.
Concerning the health-check, it works for me as it checks littlebit.me that resolve to github IPs.
$: dig littlebit.me
...
littlebit.me. 1800 IN A 192.30.252.154
littlebit.me. 1800 IN A 192.30.252.153
If it doesn't work on your PC, you may have a DNS problem. Maybe you've set a bad value in your hosts file ?

Unable to use application_ruby cookbook with Chef 11.8.0, Cannot find a resource for bundle_options

I have been attempting to setup a chef recipe which installs ruby using RVM and then uses the application_ruby cookbook to configure the application, however I keep running into the error
NameError: Cannot find a resource for bundle_options on ubuntu version 12.04
I am using the following code
application "application setup" do
owner "ubuntu"
group "ubuntu"
repository "https://github.com/me/myapplication.git" // Real address removed
path rails_app_path
revision "master"
rails do
bundler true
precompile_assets true
bundler_deployment true
end
end
I noticed that the bundle_options was recently added, https://github.com/opscode-cookbooks/application_ruby/commit/e7719170a661a957796e8e5d58ba8f4ecd937487 however I am unable to track down if this is causing the issue. I have included
depends "application"
depends "application_ruby"
in my metadata.rb and made sure all my dependencies are installed so I am unsure what I am doing wrong at this point.
According to documentation bundle_options is an attribute of the rails resource, not a resource itself.
The only correct way of using it is INSIDE the "rails" block, so you got the message because you either used it as :
an attribute of the application resource (but outside of the "rails" block)
standalone resource (outside of any resource).
Message you mentioned is being displayed when nonexistent resource is being referenced. e.g. if you had tried to execute following code on your system:
nonexistent_resource "failure gonna happen" do
some_attribute "whatever_value"
end
you would've got a message
NameError: Cannot find a resource for nonexistent_resource on Ubuntu version 12.04
I ran into this problem today as well. It appears the problem is that commit e771917 forgot to add the necessary getter for the bundle_option. Someone filed a PR to fix it (https://github.com/poise/application_ruby/pull/44), but it has not yet been merged. I can confirm that when I made that change locally, this error went away. The forked branch in the PR is located at https://github.com/mauriciosilva/application_ruby/tree/bundle_options_fix.

How can I define PATH for Phusion Passenger under nginx with Bundler?

Please forgive my near total ignorance of Ruby, but I am having an issue with Phusion Passenger in that it attempts to run something that relies on $PATH (and blindly assumes it is defined and a string). However, nginx evidently clears out the variable.
Error message:
private method `split' called for nil:NilClass
...
Backtrace:
# File Line Location
0 /usr/lib64/ruby/gems/1.8/gems/bundler-1.1.0/lib/bundler.rb 254 in `which'
That line reads:
path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p|
If there is a workaround for this, I would greatly appreciate it, as I would like to avoid using Apache if at all possible.
have you tried setting the path within your nginx config? Something to the effect:
env PATH=/some/path/expected:/another/path;
See: http://wiki.nginx.org/CoreModule#env

wrong number of arguments (3 for 2) after upgrading from Rails 3.0.14 to Rails 3.1.4

Everything was working fine in Rails 3.0.14, but after changing
gem 'rails', '3.0.14' to gem 'rails', '3.1.4' and running bundle update rails I now get the following error:
Started GET "/" for 127.0.0.1 at 2012-03-16 11:11:44 -0400
Processing by PagesController#index as HTML
Completed 500 Internal Server Error in 54ms
ArgumentError (wrong number of arguments (3 for 2)):
app/controllers/application_controller.rb:37:in `customize_by_subdomain'```
The most popular answer seemed to be that sqlite3 needed to be updated, but I did bundle update sqlite3 and I still have the same problem.
Here is the full trace: https://gist.github.com/2050530
The method that it is complaining about looks like this:
35 def customize_by_subdomain
36 subdomain = (request.subdomain.present? && request.subdomain != 'www' && request.subdomain) || 'launch'
37 #current_org = Organization.find_by_subdomain(subdomain) || Organization.find_by_subdomain('launch')
38 end
I have looked at the multitude of similar questions and I not found anything that solves my problem. The closest was question to mine was: wrong number of arguments (3 for 1) after upgrading rails from 3.1.1 to 3.1.3 but I am using authlogic and the version I am using didn't change after upgrading rails.
The only other interesting thing is my entire test suite passes, except for one request/integration spec which goes through the process of creating a new user. It seems strange that my request specs work fine when I can't even access a page in development.
Any ideas on what I can do to get to the bottom of this?
It looks like your New Relic plugin may need to be updated to a new version. In your stacktrace, the first line is from the New Relic code in your plugins folder. From their site, it looks like they released new Rails 3.1-specific code:
http://blog.newrelic.com/2011/07/29/for-the-active-record-new-relic-support-for-rails-3-1-is-here/
In the blog post, they talk about changes to the way ActiveRecord does logging, and your exception was triggered on the log_with_instrumentation method.
It looks like now you should install it as a gem rather than a plugin:
https://github.com/newrelic/rpm
Hope this helps.

Resources