How to rackup a config file from outside the root directory? - ruby

When I run rackup from within my app directory, it works fine:
walkraft#li234-166:~/discourse$ rackup config.ru
Flushing redis (development mode)
/home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require': iconv will be deprecated in the future, use String#encode instead.
/home/walkraft/discourse/vendor/gems/message_bus/lib/message_bus.rb:130: warning: already initialized constant ENCODE_SITE_TOKEN
>> Thin web server (v1.5.0 codename Knife)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:9292, CTRL+C to stop
However, if I try running rackup from outside this directory:
walkraft#li234-166:~$ rackup discourse/config.ru
/home/walkraft/discourse/config/application.rb:7:in `require': cannot load such file -- ./lib/discourse_plugin_registry (LoadError)
from /home/walkraft/discourse/config/application.rb:7:in `<top (required)>'
from /home/walkraft/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/walkraft/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/walkraft/discourse/config/environment.rb:2:in `<top (required)>'
from /home/walkraft/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/walkraft/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/walkraft/discourse/config.ru:2:in `block in <main>'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/lib/rack/builder.rb:51:in `instance_eval'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/lib/rack/builder.rb:51:in `initialize'
from /home/walkraft/discourse/config.ru:in `new'
from /home/walkraft/discourse/config.ru:in `<main>'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/lib/rack/builder.rb:40:in `eval'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/lib/rack/builder.rb:40:in `parse_file'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/lib/rack/server.rb:200:in `app'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/lib/rack/server.rb:304:in `wrapped_app'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/lib/rack/server.rb:254:in `start'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/lib/rack/server.rb:137:in `start'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.4/bin/rackup:4:in `<top (required)>'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/bin/rackup:19:in `load'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/bin/rackup:19:in `<main>'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:14:in `eval'
from /home/walkraft/.rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:14:in `<main>'
How can I run rackup when I'm not inside of the root directory?

If you don't want to manually cd to the Discourse root folder, then why not just add a fix to the rackup config.ru file:
# Insert as first line in config.ru
Dir.chdir(File.dirname(File.expand_path(__FILE__)))

Actually, it's not a problem with rackup; it's a problem with your code.
You have
require './lib/discourse_plugin_registry'
somewhere. This is not ideal. It should rather be something like:
require File.expand_path('../../lib/discourse_plugin_registry', __FILE__)
The way you have it, it uses the current directory explicitly, and no matter what you do to rackup, until you change the current directory - it won't work.

Related

Issue with falcon web server when running containerized

I tried to use falcon within a container built from this Dockerfile:
FROM docker.io/library/ruby:3.1.2 AS build-stage
COPY Gemfile .
COPY Gemfile.lock .
RUN bundle install
WORKDIR /app
COPY . .
CMD falcon host
My falcon.rb looks as follows
#!/usr/bin/env -S falcon host
# frozen_string_literal: true
load :rack, :supervisor
rack 'localhost' do
endpoint Async::HTTP::Endpoint
.parse('http://0.0.0.0:3001')
end
supervisor
But when I try to launch this container I get the following error message:
{"time":"2022-12-02T14:29:44+00:00","severity":"info","class":"Falcon::Command::Host","oid":2680,"pid":2,"subject":"Falcon::Command::Host","message":"Falcon Host v0.42.3 taking flight!\n- Configuration: falcon.rb\n- To terminate: Ctrl-C or kill 2\n- To reload: kill -HUP 2\n"}
/usr/local/bundle/gems/falcon-0.42.3/lib/falcon/service/supervisor.rb:23:in `require': cannot load such file -- process/metrics (LoadError)
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/service/supervisor.rb:23:in `<top (required)>'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/environments/supervisor.rb:23:in `require_relative'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/environments/supervisor.rb:23:in `block in load'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:134:in `instance_eval'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:134:in `block in load'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:127:in `each'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:127:in `load'
from /app/falcon.rb:4:in `load_file'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:118:in `instance_eval'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:118:in `load_file'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/configuration.rb:85:in `load_file'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:54:in `block in configuration'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:52:in `each'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:52:in `configuration'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/controller/host.rb:39:in `initialize'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:62:in `new'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:62:in `controller'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/host.rb:84:in `call'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command/top.rb:105:in `call'
from /usr/local/bundle/gems/samovar-2.1.4/lib/samovar/command.rb:36:in `call'
from /usr/local/bundle/gems/falcon-0.42.3/lib/falcon/command.rb:30:in `call'
from /usr/local/bundle/gems/falcon-0.42.3/bin/falcon:26:in `<top (required)>'
from /usr/local/bundle/bin/falcon:25:in `load'
from /usr/local/bundle/bin/falcon:25:in `<main>'
Interestingly everything works fine when running natively, but it seems when run inside a container there is an issue with the process/metrics dependency but I'm not sure how to resolve it.
As pointed out by #anothermh in the comments the solution was to use the bundler for running falcon in the Dockerfile:
CMD bundle exec falcon host

"ruby:latest" has multiple versions and cannot find the correct GEM

I have following dockerfile
FROM ruby:latest
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /usr/src/app/
COPY Gemfile Gemfile.lock ./
RUN bundle install
ADD . /usr/src/app/
EXPOSE 3333
CMD ["/usr/src/app/startup.sh"]
and Ruby app to start
require 'sinatra'
set :port, 3333
set :bind, '0.0.0.0'
get '/' do
'Hello World!'
end
startup.sh
#!/bin/bash
ruby /usr/src/app/helloworld.rb &
sleep infinity
Fails with:
/usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/regular.rb:22:in `initialize': wrong number of arguments (given 2, expected 1) (ArgumentError)
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/pattern.rb:59:in `new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/pattern.rb:59:in `block in new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/equality_map.rb:43:in `fetch'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann/pattern.rb:59:in `new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann.rb:67:in `new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann.rb:70:in `block in new'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann.rb:70:in `map'
from /usr/local/bundle/gems/mustermann-1.0.3/lib/mustermann.rb:70:in `new'
from /usr/local/bundle/gems/sinatra-2.0.5/lib/sinatra/base.rb:1641:in `compile'
from /usr/local/bundle/gems/sinatra-2.0.5/lib/sinatra/base.rb:1629:in `compile!'
from /usr/local/bundle/gems/sinatra-2.0.5/lib/sinatra/base.rb:1271:in `error'
from /usr/local/bundle/gems/sinatra-2.0.5/lib/sinatra/base.rb:1838:in `<class:Base>'
from /usr/local/bundle/gems/sinatra-2.0.5/lib/sinatra/base.rb:894:in `<module:Sinatra>'
from /usr/local/bundle/gems/sinatra-2.0.5/lib/sinatra/base.rb:22:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /usr/local/bundle/gems/sinatra-2.0.5/lib/sinatra/main.rb:1:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /usr/local/bundle/gems/sinatra-2.0.5/lib/sinatra.rb:1:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
from /usr/src/app/helloworld.rb:1:in `<main>'
<internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- sinatra (LoadError)
from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /usr/src/app/helloworld.rb:1:in `<main>'
And ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
Why this happens? Error says /usr/local/lib/ruby/3.1.0/rubygems/ but installed version is 3.1.2.
Am I missing something here?

Ruby `require` call fails on custom code

I have found that I have no problem using require to load something like the Sinatra web framework, but I can't seem to use require to load my own custom code?
For example I have two files:
test1.rb
test2.rb
The content of 'test1.rb' is:
#!/usr/bin/env ruby
require 'test2'
The content of 'test2.rb' is:
class String
def vowels
self.scan(/[aeiou]/i)
end
end
And if I try and run ruby test1.rb then I get the following error...
/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- test2 (LoadError)
from /Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from test1.rb:3:in `<main>'
I then noticed if I tried to use the shotgun gem to load the web server then I get a different but more detailed stack trace of the error...
Boot Error
Something went wrong while loading test1.rb
LoadError: cannot load such file -- test2
/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/<username>/Dropbox/Library/Ruby/Passage/test1.rb:3:in `<top (required)>'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:114:in `inner_app'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:102:in `assemble_app'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:86:in `proceed_as_child'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:31:in `call!'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in `call'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/favicon.rb:12:in `call'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/static.rb:14:in `call'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/connection.rb:80:in `block in pre_process'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/connection.rb:78:in `catch'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/connection.rb:78:in `pre_process'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/connection.rb:53:in `process'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/connection.rb:38:in `receive_data'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/bin/shotgun:156:in `<top (required)>'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/bin/shotgun:19:in `load'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/bin/shotgun:19:in `<main>'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `eval'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `<main>'
I'm not sure what the problem is?
Any help appreciated please.
Thanks.
The current directory (relative to the main ruby file) is not part of the load paths (the set of paths that require looks in). So you either need to add it to the load path (best done by invoking ruby as ruby -I. test1.rb), by using require "./test2.rb" or by using require_relative "test2.rb", which requires files relative to the directory of the file.

Ruby rails WEBrick server exiting with errors I don't understand

I've created an app but when I start the rails server I'm getting the following output. Anyone point me in the right direction as to what I'm doing wrong please? I'm pulling my hair out!
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require': no such file to load -- openssl (LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/session/cookie.rb:1
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_dispatch/middleware/session/cookie_store.rb:4
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/application/configuration.rb:131:in `const_get'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/application/configuration.rb:131:in `session_store'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/application.rb:172:in `default_middleware_stack'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/application.rb:146:in `tap'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/application.rb:146:in `default_middleware_stack'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/engine.rb:446:in `build_middleware_stack'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/application/finisher.rb:37
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `run_initializers'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/application.rb:96:in `initialize!'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/khussain/delete/config/environment.rb:5
from /home/khussain/delete/config.ru:4:in `require'
from /home/khussain/delete/config.ru:4
from /usr/local/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/builder.rb:51:in `instance_eval'
from /usr/local/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/builder.rb:51:in `initialize'
from /home/khussain/delete/config.ru:1:in `new'
from /home/khussain/delete/config.ru:1
If the above doesn't work, then it's probably because you don't have a .Gemfile ?
This looks like a gem is missing (openssl), without seeing the code I'm not sure.
The best thing would be to run:
bundle install
If this still doesn't work try adding openssl to your Gemfile and running bundle install again

Problem using require command

I am simply requiring a file present in the same folder as the testfile however I am getting this wierd message again and again...
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- a.rb (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/dummyFirefox/test_a.rb:1:in `<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `block in load_spec_files'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `map'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load_spec_files'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:18:in `run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `block in autorun'
the code that I write in my testfile test_a.rb is simply:
require 'a.rb'
and when I issue the command : rspec test_a.rb the message is the above mentioned error.
I am using ruby-1.9.2 for development.
Hope I don't miss any details.
Thanks in advance.
In Ruby 1.9.2 the current working directory is no longer part of the load path ($LOAD_PATH or $:). You have to add it manually using:
$LOAD_PATH.unshift '.'
or
$:.unshift '.'
Or you can require the file explicitly:
require './test_a.rb'

Resources