2011-10-21 19 views
14

Ho appena aggiornato la mia app dalla 1.8.7 alla 1.9.2 usando RVM e ho dovuto aggiungere RubyGems e Bundler, ho eseguito l'installazione di bundle e ho ottenuto tutto a posto tranne SystemTimer. Google-fu non restituisce nulla e vedo che altri hanno avuto problemi con esso nella versione 1.9 ma alcuni lo hanno fatto funzionare. Qualche idea?Come installare SystemTimer su 1.9.2?

pawel:bodb pawel$ sudo gem install SystemTimer 
Building native extensions. This could take a while... 
/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777 
ERROR: Error installing SystemTimer: 
ERROR: Failed to build gem native extension. 

/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
creating Makefile 

make 
/usr/bin/gcc-4.2 -I. -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin10.3.0 
-I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. 
-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers 
-Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -o system_timer_native.o -c system_timer_native.c 
In file included from system_timer_native.c:8: 
/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete 
system_timer_native.c: In function ‘install_first_timer_and_save_original_configuration’: 
system_timer_native.c:46: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:53: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:57: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:62: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:65: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:69: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:82: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:89: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:96: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:101: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c: In function ‘install_next_timer’: 
system_timer_native.c:112: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:119: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:123: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:130: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:136: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:143: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:146: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c: In function ‘restore_original_configuration’: 
system_timer_native.c:157: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:160: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:168: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:170: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:172: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c: In function ‘restore_original_timer_interval’: 
system_timer_native.c:190: warning: passing argument 1 of ‘log_error’ discards qualifiers from pointer target type 
system_timer_native.c:192: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c: In function ‘restore_sigalrm_mask’: 
system_timer_native.c:199: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:201: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c: In function ‘install_ruby_sigalrm_handler’: 
system_timer_native.c:211: error: ‘rb_thread_critical’ undeclared (first use in this function) 
system_timer_native.c:211: error: (Each undeclared identifier is reported only once 
system_timer_native.c:211: error: for each function it appears in.) 
system_timer_native.c: In function ‘restore_original_ruby_sigalrm_handler’: 
system_timer_native.c:217: error: ‘rb_thread_critical’ undeclared (first use in this function) 
system_timer_native.c: In function ‘clear_pending_sigalrm_for_ruby_threads’: 
system_timer_native.c:266: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c: In function ‘set_itimerval’: 
system_timer_native.c:290: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
system_timer_native.c:295: warning: implicit conversion shortens 64-bit value into a 32-bit value 
system_timer_native.c:299: warning: passing argument 1 of ‘log_debug’ discards qualifiers from pointer target type 
make: *** [system_timer_native.o] Error 1 


Gem files will remain installed in /Users/pawel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/SystemTimer-1.2.3 for inspection. 
Results logged to /Users/pawel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/SystemTimer-1.2.3/ext/system_timer/gem_make.out 

risposta

25

Per quanto ne so, SystemTimer non è rilevante per Ruby 1.9 e non deve essere utilizzato con questa versione.

"L'utilizzo di questo gioiello in Ruby 1.9 è inutile e non ha senso! System Timer sta tentando di aggirare alcune limitazioni del modello" filo verde "utilizzato in Ruby 1.8 (MRI). Per ulteriori dettagli, vedere http://ph7spot.com/musings/system-timer. "

+0

Okay, quello che dovrebbe essere utilizzato in Ruby 1.9 invece di 'SystemTimer.timeout_after'? – Nowaker

+0

Ok, guardalo. 'richiede 'timeout'; Timeout :: timeout (5) {...} ' – Nowaker

-3

Montare uso timer di sistema questo comando in Terminale:

sudo gem install system_timer 
+0

Non si desidera utilizzare sudo con RVM. – Simpleton

+0

Anche questo non aiuta poiché system_timer non sarà in grado di funzionare con Ruby 1.8.7 – professormeowingtons

3

A rimpiazzo per SystemTimer è timeout.rb dal nucleo rubino. Non c'è bisogno di gemme di terze parti.

Ruby 1.8:

require 'system_timer' 

SystemTimer.timeout_after(5.minutes, MyException) do 
    # your job here 
end 

Ruby 1.9:

require 'timeout' 

Timeout.timeout(5.minutes, MyException) do 
    # your job here 
end