can't add custom script in overcommit gem - ruby-on-rails

I'm not sure if this is something I should post in the official repository issue(I sometimes see 'question' tag there). But if you think this is the appropriate place to ask this, would be great if someone could help me out.
I've been trying to add a custom script in overcommit gem with no luck.
What it says in the official document is to add lines in .overcommit.yml:
PostCheckout:
CustomScript:
enabled: true
required_executable: './bin/custom-script'
(so I've done so:)
PrePush:
customHook:
enabled: true
required_executable: 'custom-hook'
and to put the script in .git-hooks directory in the project root. So I put this script in .git-hook dir for test:
#custom-hook.sh
echo hey
Here's the sweet error message:
Hook must specify a `required_executable` or `command` that is tracked by git (i.e. is a path relative to the root of the repository) so that it can be signed
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_signer.rb:39:in `hook_path'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_signer.rb:92:in `hook_contents'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_signer.rb:88:in `signature'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_signer.rb:61:in `signature_changed?'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_loader/plugin_hook_loader.rb:51:in `select'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_loader/plugin_hook_loader.rb:51:in `modified_plugins'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_loader/plugin_hook_loader.rb:55:in `check_for_modified_plugins'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_loader/plugin_hook_loader.rb:8:in `load_hooks'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_runner.rb:195:in `load_hooks'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_runner.rb:32:in `block in run'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/interrupt_handler.rb:84:in `isolate_from_interrupts'
/Users/hiroki/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/overcommit-0.34.2/lib/overcommit/hook_runner.rb:28:in `run'
.git/hooks/pre-push:79:in `<main>'
Obviously, it complains it can't find the executable so I'm guessing the format isn't right, but there are little information out there and I'm stuck.

From the error message, it seems that the custom-hook must be relative to the root directory of your git repository. Perhaps try putting that one into ./bin/custom-hook?

Related

Could not open library 'lib.dylib' on Mac

Have some issues with launching ruby tests on Mac(Monterey 12.2.1). I've launched bundle install - everything was finished successfully, after that I tried to do a command bundle exec rake db:test:refresh, and got the following error
LoadError: Couldn't load the GEOS CAPI library.
/Users/alexandra_shimanovich/.bundle/ruby/2.5.0/gems/ffi-geos-0.3.0/lib/ffi-geos.rb:1000:in `rescue in <module:FFIGeos>'
/Users/alexandra_shimanovich/.bundle/ruby/2.5.0/gems/ffi-geos-0.3.0/lib/ffi-geos.rb:982:in `<module:FFIGeos>'
/Users/alexandra_shimanovich/.bundle/ruby/2.5.0/gems/ffi-geos-0.3.0/lib/ffi-geos.rb:51:in `<module:Geos>'
/Users/alexandra_shimanovich/.bundle/ruby/2.5.0/gems/ffi-geos-0.3.0/lib/ffi-geos.rb:7:in `<top (required)>'
/Users/alexandra_shimanovich/Documents/Curb/ride_manager/config/application.rb:9:in `<top (required)>'
/Users/alexandra_shimanovich/Documents/Curb/ride_manager/Rakefile:4:in `require'
/Users/alexandra_shimanovich/Documents/Curb/ride_manager/Rakefile:4:in `<top (required)>'
/Users/alexandra_shimanovich/.rbenv/versions/2.5.5/bin/bundle:23:in `load'
/Users/alexandra_shimanovich/.rbenv/versions/2.5.5/bin/bundle:23:in `<main>'
LoadError: Could not open library '/usr/lib/': dlopen(/usr/lib/, 0x0005): tried: '/usr/lib/' (not a file), '/usr/local/lib/' (not a file).
Could not open library 'lib.dylib': dlopen(lib.dylib, 0x0005): tried: 'lib.dylib' (no such file), '/usr/local/lib/lib.dylib' (no such file), '/usr/lib/lib.dylib' (no such file), '/Users/alexandra_shimanovich/Documents/Curb/ride_manager/lib.dylib' (no such file), '/usr/local/lib/lib.dylib' (no such file), '/usr/lib/lib.dylib' (no such file)
I looked inside ffi-geos.rb
def self.search_paths
#search_paths ||= begin
if ENV['GEOS_LIBRARY_PATH']
[ ENV['GEOS_LIBRARY_PATH'] ]
elsif FFI::Platform::IS_WINDOWS
ENV['PATH'].split(File::PATH_SEPARATOR)
else
[ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}' ]
[ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/{x86_64,i386}-linux-gnu' ]
end
end
end
I know that in my computer lib files are not in /usr/local/.. but in /opt/homebrew/lib. But when I looked inside /opt/homebrew/lib I didn't find lib.dylib. There are only libgeos.3.10.2.dylib libgeos.dylib libgeos_c.1.16.0.dylib libgeos_c.1.dylib libgeos_c.dylib.
Please, help me find the right lib and somehow tell ffi-geos.rb to look in the right place, I would REALLY appreciate it! Thank you!
But when I looked inside /opt/homebrew/lib I didn't find lib.dylib
The code from ffi-geos.rb you posted is not looking for lib.dylib (or lib64.dylib), but it's adding /usr/local/lib, /usr/local/lib64, etc, to the search path to look for the specific GEOS dylibs. As your library files are in /opt/homebrew/lib, they won't be found by that automatic procedure.
The first conditional in the code shows you can set an environment variable to define the search path. So, set the library path with:
export GEOS_LIBRARY_PATH=/opt/homebrew/lib
Hope this works!

Heroku CI w/ Postgresql Extensions

I'm attempting to use Heroku's CI to run my Rails application's tests but it's running into a problem when attempting to load my structure.sql file.
-----> Preparing test database
Running: rake db:schema:load_if_ruby
db:schema:load_if_ruby completed (3.24s)
Running: rake db:structure:load_if_sql
psql:/app/db/structure.sql:28: ERROR: must be owner of extension plpgsql
rake aborted!
failed to execute:
psql -v ON_ERROR_STOP=1 -q -f /app/db/structure.sql d767koa0m1kne1
Please check the output above for any errors and make sure that `psql` is installed in your PATH and has proper permissions.
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/postgresql_database_tasks.rb:108:in `run_cmd'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/postgresql_database_tasks.rb:80:in `structure_load'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:223:in `structure_load'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:236:in `load_schema'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:255:in `block in load_schema_current'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:303:in `each'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:254:in `load_schema_current'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/railties/databases.rake:290:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.1/lib/active_record/railties/databases.rake:294:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:structure:load
(See full trace by running task with --trace)
!
! Could not prepare database for test
!
The relevant line here is:
psql:/app/db/structure.sql:28: ERROR: must be owner of extension plpgsql
rake aborted!
Structure.sql contains this line:
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
Any ideas on how to get this working on Heroku's CI?
Ended up overriding db:structure:dump to remove the COMMENT ON ... statements:
namespace :db do
namespace :structure do
task dump: [:environment, :load_config] do
filename = ENV["SCHEMA"] || File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, "structure.sql")
sql = File.read(filename).each_line.grep_v(/\ACOMMENT ON EXTENSION.+/).join
File.write(filename, sql)
end
end
end
Another workaround would be to add something like
if Rails.env.development?
ActiveRecord::Tasks::DatabaseTasks.structure_load_flags = ["-v", "ON_ERROR_STOP=0"]
end
anywhere in the initialisation / tasks pipeline before the db:structure:load is executed.
If Kyle's solution isn't enough and the errors aren't caused only by comments on extensions, but actual extensions installations, you can still go the hard way and add this to an initializer:
# This is a temporary workaround for the Rails issue #29049.
# It could be safely removed when the PR #29110 got merged and released
# to use instead IGNORE_PG_LOAD_ERRORS=1.
module ActiveRecord
module Tasks
class PostgreSQLDatabaseTasks
ON_ERROR_STOP_1 = 'ON_ERROR_STOP=0'.freeze
end
end
end
Note: This isn't specific to Heroku but a broader Rails 5.1 issue
There are two solutions to this problem. First, as it was previously noted, is disabling the ON_ERROR_STOP feature. It'd help regardless of the environment. Custom rake task:
namespace :db do
namespace :structure do
# This little task is a workaround for a problem introduced in Rails5. Most specificaly here
# https://github.com/rails/rails/blob/5-1-stable/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb#L77
# When psql encounters an error during loading of the structure it exits at once with error code 1.
# And this happens on heroku. It renders review apps and heroku CI unusable if you use a structure instead of a schema.
# Why?
# Our `db/structure.sql` contains entries like `CREATE EXTENSION` or `COMMENT ON EXTENSION`.
# Zylion of extensions on heroku are loaded in template0, so "our" db also has them, but because of that
# only a superuser (or owner of template0) has access to them - not our heroku db user. For that reason
# we can neither create an extension (it already exists, but that is not a problem, because dump contains IF NOT EXIST)
# nor comment on it (and comments don't have IF NOT EXIST directive). And that's an error which could be safely ignored
# but which stops loading of the rest of the structure.
desc "Disable exit-on-error behaviour when loading db structure in postgresql"
task disable_errors: :environment do
ActiveRecord::Tasks::DatabaseTasks.structure_load_flags = ["-v", "ON_ERROR_STOP=0"]
end
end
end
# And use it like so:
bin/rails db:structure:disable_errors db:structure:load
Another option, in my opinion, superior if it comes only to Heroku, would be using PostgreSQL in in-dyno plan (https://devcenter.heroku.com/articles/heroku-ci-in-dyno-databases), which is basically a DB instance sitting within dyno, thus we have full access to it. Also, the test suite should be significantly faster because we use a localhost connection, not over the wire. To enable it, change your app.json content to have entries like so:
{
"environments": {
"test": {
"addons": [
"heroku-postgresql:in-dyno"
]
}
}
}

which application_rb file should I edit?

On my server I did a search with sudo find . -name "application_controller.rb". There's so many files of that name. Which one should I edit so the changes will be reflected on my server?
./home/myapp/apps/myapp/releases/20140208000704/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140116094931/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140114154804/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140117124202/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140120094758/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140116102758/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140117125636/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140116123905/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140116115403/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140117090645/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140121091622/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140212214841/app/controllers/application_controller.rb
./home/myapp/apps/myapp/releases/20140205001541/app/controllers/application_controller.rb
./home/myapp/apps/myapp/shared/cached-copy/app/controllers/application_controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/best_in_place-1.1.2/test_app/app/controllers/application_co ntroller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/sass-rails-3.2.5/test/fixtures/sass_project/app/controllers /application_controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/sass-rails-3.2.5/test/fixtures/engine_project/app/controlle rs/engine_project/application_controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/sass-rails-3.2.5/test/fixtures/engine_project/test/dummy/ap p/controllers/application_controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/sass-rails-3.2.5/test/fixtures/scss_project/app/controllers /application_controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/devise-2.0.6/test/rails_app/app/controllers/application_con troller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/rest-graph-2.0.1/example/rails3/app/controllers/application _controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/rest-graph-2.0.1/example/rails2/app/controllers/application _controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/railties-3.2.3/lib/rails/generators/rails/app/templates/app /controllers/application_controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/railties-3.2.3/guides/code/getting_started/app/controllers/ application_controller.rb
./home/myapp/apps/myapp/shared/bundle/ruby/1.8/gems/gmaps4rails-1.5.6/spec/dummy/app/controllers/application_co ntroller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/best_in_place-1.1.2/test_app/app/controllers/application_controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/email_spec-1.2.1/examples/rails3_root/app/controllers/application_contr oller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/sass-rails-3.2.5/test/fixtures/sass_project/app/controllers/application _controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/sass-rails-3.2.5/test/fixtures/engine_project/app/controllers/engine_pr oject/application_controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/sass-rails-3.2.5/test/fixtures/engine_project/test/dummy/app/controller s/application_controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/sass-rails-3.2.5/test/fixtures/scss_project/app/controllers/application _controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/devise-2.0.6/test/rails_app/app/controllers/application_controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/rest-graph-2.0.1/example/rails3/app/controllers/application_controller. rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/rest-graph-2.0.1/example/rails2/app/controllers/application_controller. rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.3/lib/rails/generators/rails/app/templates/app/controllers /application_controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/railties-3.2.3/guides/code/getting_started/app/controllers/application_ controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails3.0/app/controllers/application_control ler.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails3.2/app/controllers/application_control ler.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails2.3/app/controllers/application_control ler.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails4.0/app/controllers/application_control ler.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails3.1/app/controllers/application_control ler.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails_apps/2.3/empty/app/controllers/applica tion_controller.rb
./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails_apps/2.3/mycook/app/controllers/applic ation_controller.rb
myapp#myapp:/$ sufo nano ./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails_apps/ 2.3/mycook/app/controllers/application_controller.rb
-bash: sufo: command not found
myapp#myapp:/$ sudo nano ./home/myapp/.rvm/gems/ruby-1.8.7-p374/gems/passenger-4.0.14/test/stub/rails_apps/ 2.3/mycook/app/controllers/application_controller.rb
myapp#myapp:/$
You shouldn't change any of them. Really.
./home/myapp/apps/myapp/releases suggests you are using something like Capistrano to deploy your application. You should update your source code, commit, and deploy it.
If that's not an option, then you should see if ./home/myapp/apps/myapp/current/app/controllers/application_controller.rb exists and edit that. If not, pick the most recent version in `./home/myapp/apps/myapp/releases.
Once edited you'll need to restart the web server for it to pick up the changes.
Again.. I would highly suggest not doing this unless you have no other option.

Running whenever cron in Windows

Total newbie at cronjobs and that kinda stuff, never done it before, so now I tried to get my hands dirty using whenever as a plugin, after seeing it on RailsCasts.
So I am trying to run a cron job for my Ruby application, but it seems like it's not working, maybe becuase of the code or maybe because of me using Windows 7?
Here is the code from my Server model
def self.ping
Server.all.each do |t|
if t.name.serverUp?
#response = 'Up'
else
#response = 'Down'
end
self.update_attribute(:serverStatus, #response.to_s)
end
end
def serverUp?
if system 'ping '+name.to_s+' -n 1 > nul'
#response = 'Up'
else
#response = 'Down'
end
self.update_attribute(:serverStatus, #response.to_s)
#response
end
And here is the code from my schedule.rb file which has the cron job in it
#every 2.minutes do
# runner "Server.last.name = 'Works'"
# runner "for x in Server.all.each {x.serverUp?}", environment =>"development"
#end
every 2.minutes do
runner "Server.ping", environment =>"development"
end
I tried both methods out, (the latter I used most recently, to which I created the self.ping method in the Server model.
So when I run whenever in my rails directory, this is the output I get:
PS C:\SIS> whenever
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c 'cd C:/SIS
&& script/rails runner -e production '\''Server.ping'\'''
## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.
1st) Funnily enough, the environment doesn't seem to have changed to development even though I stated it in the code.
2nd) The crontab file wasn't updated (I don't even know if there existed one to begin with?)
So I tried to create a crontab whenever file by running whenever -w ping, but the results was
PS C:\SIS> whenever -w ping
[fail] Couldn't write crontab; try running `whenever' with no options to ensure your schedule file is valid.
So this is my problem, any help would be appreciated.
Edit: Ok, I decided to use rufus-scheduler in order to update my Server list frequently. I tested out whether it would work to create a new server into the table every mintues, and that seemed to work.
However, because I wasn't able to stop it from creating servers, I removed it from the bundle, deleted the 'task_scheduler' file and then re-installed it and done everything like before.
However, when I now try to run the server, I get the following error:
C:/SIS/config/initializers/task_scheduler.rb:1:in '<top (required)>': undefined method 'start_new' for Rufus::Scheduler:
Module (NoMethodError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in 'load'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in 'block in load'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in 'block in load_dependency'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in 'new_constants_in'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in 'load_dependency'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in 'load'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/engine.rb:201:in 'block (2 levels) in <class:Engine>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/engine.rb:200:in 'each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/engine.rb:200:in 'block in <class:Engine>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:25:in 'instance_exec'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:25:in 'run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:50:in 'block in run_initializers'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:49:in 'each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:49:in 'run_initializers'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:134:in 'initialize!'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:in 'method_missing'
from C:/SIS/config/environment.rb:5:in '<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in 'require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in 'block in require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in 'block in load_dependency'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in 'new_constants_in'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in 'load_dependency'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in 'require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:103:in 'require_environment!'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:22:in '<top (required)>'
from script/rails:6:in 'require'
from script/rails:6:in '<main>'
The code in the task_scheduler is as follows:
scheduler = Rufus::Scheduler.start_new
scheduler.every '1m' do
# Server.all.each do
# |server| server.name.serverUp?
# end
Server.ping
end
Not sure which of the two methods to use, hence I commented the first one out.
Help would be greatly appreciated.
Thanks in advance
Edit
Ok, finally solved it, had to put require 'rubygems'
require 'rufus/scheduler' on the top of my code.
Now it works fine :-)
Cron is a Unix program. It doesn't exist on Windows.
Although it's nowhere near as flexible as cron, windows has the AT command which may be able to solve your problems, however you can only schedule it to run at most once a day. To see how to use AT run AT /? on your command line.
For much more fine-grained control over running tasks you can use the GUI based windows task scheduler. you can find this in Control Panel -> System and Security -> Administrative Tools -> Task Scheduler
I had the same problem, this is how I solved it:
I created a small EXE in AutoIT, the exe will read the names of files/urls to execute from an ini file (config.ini)
I named the EXE CRON.exe and had it start via schedulled tasks.
The files/urls in the config.ini can be either other executables or urls, the script will work out how to run each type.
AutoIT is a very simple scripting language, you can see my CRON.exe code below:
$iniFile='config.ini'
$i=0
While 1
$i+=1
$file=IniRead($iniFile, 'crons', $i, 'NULL')
If $file='NULL' Then ExitLoop
If StringInStr($file, 'http://') Then
InetGet($file, #TempDir, 1)
Else
$wd=StringSplit($file, '\', 3)
$workingDir=''
For $i=0 To UBound($wd)-2
$workingDir&=$wd[$i]&'\'
Next
RunWait($file, $workingDir)
EndIf
WEnd
Example of ini file:
[CRONS]
;paths of the files to execute
1=C:\anotherEXE.exe
2=http://mySite.com/myCron.php
All files are executed in order with no overlap, you can optionally change the AutoIT code to use Run instead of RunWait if you want to execute all files at the same time.
Yes I agree with Jorg M, cron job is unix program and also rufus scheduler internally call cron unix process so stay away from both and you should use delayed job ActiveRecord which help you to do the same.
This is as per my experience, there could other way but this is best which I ever used.
Best Luck

CVS error - CVS exited with error code 1

I am seeing this error for quite sometime now.
I am running ant build on CYGWIN which inturn runs on WindowsXP.
The resolution(bad one) I found was to delete my gcct/first directory and run ant build again (which runs from another directory). It runs successfully but if I modify some code under gcct/first, I do not want to delete it because of this error.
I did see this link. The resolution here does not apply to me since I do not have .cvspass defined anywhere in the build.xml.
C:\svn\CEL_v3681\buildCore.xml:1883: cvs exited with error code 1
Command line was [Executing 'cvs' with arguments:
'checkout'
'-A'
'-rfirst_v2_126'
'gcct/first'
The ' characters around the executable and arguments are
not part of the command.
environment:
ALLUSERSPROFILE=C:\Documents and Settings\All Users
ANT_HOME=C:/Apps/Apache/apache-ant-1.7.0
APPDATA=C:\Documents and Settings\shankarc\Application Data
CLASSPATH=./;C:/Program Files/Java/jre1.5.0_07/lib/ext/QTJava.zip
COMMONPROGRAMFILES=C:\Program Files\Common Files
COMPUTERNAME=NYKPWM2035798
COMSPEC=C:\WINNT\system32\cmd.exe
CUSTPROF=Roaming700Live
CVSROOT=:pserver:shankarc#amcvs2.lehman.com:/home/eqcvs/cmte
CVS_RSH=/bin/ssh
FP_NO_HOST_CHECK=NO
HOME=C:\Apps\CYGWIN\home\shankarc
HOMEDRIVE=F:
HOMEPATH=\
HOSTNAME=nykpwm2035798
IDEA_PROPERTIES=C:\Documents and Settings\shankarc\idea.properties
INFOPATH=/usr/local/info:/usr/share/info:/usr/info:
JAVA_HOME=C:/Program Files/Java/jdk1.6.0_21/
JDK_HOME=C:\Program Files\Java\jdk1.6.0_21\
LOGONSERVER=\\NYKPSM00069
MANPATH=/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
PATH=C:\Apps\CYGWIN\usr\local\bin;C:\Apps\CYGWIN\bin;C:\Apps\CYGWIN\bin;C:\Apps\CYGWIN\usr\X11R6\bin;C:\Apps\Apache\apache-ant-1.7.0\bin;C:\Program Files\Java\jdk1.6.0_21\bin\;C:\Apps\CYGWIN\bin;C:\Program Files\VisualSVN Server\bin;C:\Program Files\Sudowin\Clients\Console;C:\Program Files\Fortify Software\Fortify 360 v2.5.0\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1
PRINTER=\\NYKPSM04020\NYKLPR1301-03-03C05
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 6, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f06
PROFGROUP=FONP
PROGRAMFILES=C:\Program Files
PROMPT=$P$G
PWD=/cygdrive/c/svn/CEL_v3681/gcct/cel
QHOME=c:\q
QTJAVA=C:\Program Files\Java\jre1.5.0_07\lib\ext\QTJava.zip
SESSIONNAME=Console
SHLVL=1
SITECODE=NYK
SITEIDENT=NYK
SVN_ASP_DOT_NET_HACK=1
SYSTEMDRIVE=C:
SYSTEMROOT=C:\WINNT
TEMP=C:\TEMP
TERM=cygwin
TMP=C:\TEMP
UATDATA=C:\WINNT\system32\CCM\UATData\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77
USER=shankarc
USERDNSDOMAIN=INTRANET.BARCAPINT.COM
USERDOMAIN=INTRANET
USERNAME=shankarc
USERPROFILE=C:\Documents and Settings\shankarc
WINDIR=C:\WINNT
CVS_PASSFILE=C:\Apps\CYGWIN\home\shankarc\.cvspass]
Total time: 58 seconds
How I resolve this?
I had the same issue and found that even though I was not using .cvspass I did have a build property of cvs.pass set which needed to be reset to OVERRIDE to function depending on how you set up your cvs access (though it looked similar from your post). This needed to be changed in build.properties and .build.properties. Hope this helps!

Resources