I'm using pry-rails with jRuby 1.7.5(1.9.3p392) with rails 3.2.9. Whenever I'm in pry and it outputs more than one page(e.g.: when I do help) and has to put a page-break I will be stuck, the end of the screen looks like this:
<page break> --- Press enter to continue ( q<enter> to break ) --- <page break>
^M^M^M^M^M^M^M^M^C^C[2013-10-31 21:46:20] ERROR Interrupt: Interrupt
/Users/macbook/.rbenv/versions/jruby-1.7.5/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_class.rb:103:in `load_traps'
^C^C^C[2013-10-31 21:46:22] ERROR Interrupt: Interrupt
/Users/macbook/.rbenv/versions/jruby-1.7.5/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_class.rb:103:in `load_traps'
I won't be able to get out from pry with q or any other keys. When I do ctrl-c, it will print more ERROR Interrupt. The only way out is force closing the tab or ctrl-Z, which is even uglier. Is this a bug or am I doing it wrong? Thanks.
You can work around this by turning off paging.
Pry.pager = nil
Related
In a coding project I am doing I keep getting the EOF error whenever the user inputs a space, and I am not sure how to fix it, I can not make it a function because of the set up of my if and while statements, any help would be great
I tried turning the choice into a function but due to the layout it does not work. I attempted to use try and execpt but it led to a endless loop of the menu being printed I set it up as follows
try:
playerschoice = int(input(menu)) #Saves player choice again
execpt EOFErrors:
break
I did not know where to ask that question, so I am asking here.
I have trouble onfiguring org-mode (specficly org capture) in spacemacs.
In my .spacemacs file (in the fucntion dotspacemacs/user-init) I have added the following code :
(setq org-default-notes-file "~/Desktop/notes2.org")
(setq-default dotspacemacs-configuration-layers
'((org :variables org-projectile-file "~/Desktop/TODOs.org")))
But whene I press SPC a o c saves the "TODO" in ~/notes.org file and not in ~/Desktop/notes2.org.
Also it throws the following error message :
Error (use-package): org-projectile/:config: Symbol’s function definition is void: org-projectile:per-repo
Thanks in advance.
This is not your fault. It's a bug for which the fix has not been merged into master for a very long time (scroll to the buttom to see how people still confirm having the same problem):
https://github.com/syl20bnr/spacemacs/issues/9374
One thing that you can do is use the develop branch of spacemacs. The bug is fixed and merged there, and the release is not that ¨unstable" as it may sound.
Just starting with noflo, I'm baffled as why I'm not able to get a simple flow working. I started today, installing noflo and core components following the example pages, and the canonical "Hello World" example
Read(filesystem/ReadFile) OUT -> IN Display(core/Output)
'package.json' -> IN Read
works... so far fine, then I wanted to change it slightly adding "noflo-rss" to the mix, and then changing the example to
Read(rss/FetchFeed) OUT -> IN Display(core/Output)
'http://xkcd.com/rss.xml' -> IN Read
Running like this
$ /node_modules/.bin/noflo-nodejs --graph graphs/rss.fbp --batch --register=false --debug
... but no cigar -- there is no output, it just sits there with no output at all
If I stick a console.log into the sourcecode of FetchFeed.coffee
parser.on 'readable', ->
while item = #read()
console.log 'ITEM', item ## Hack the code here
out.send item
then I do see the output and the content of the RSS feed.
Question: Why does out.send in rss/FetchFeed not feed the data to the core/Output for it to print? What dark magic makes the first example work, but not the second?
When running with --batch the process will exit when the network has stopped, as determined by a non-zero number of open connections between nodes.
The problem is that rss/FetchFeed does not open a connection on its outport, so the connection count drops to zero and the process exists.
One workaround is to run without --batch. Another one I just submitted as a pull request (needs review).
I recollect getting log files that were nicely ordered, so that you could follow one request, then the next, and so on.
Now, the log files are, as my 4 year old says "all scroggled up", meaning that they are no longer separate, distinct chunks of text. Loggings from two requests get intertwined/mixed up.
For instance:
Started GET /foobar
...
Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.8ms)
Patient Load (wait, that's from another request that has nothing to do with foobar!)
[ blank space ]
Something else
This is maddening, because I can't tell what's happening within one single request.
This is running on Passenger.
I tried to search for the same answer but couldn't find any good info. I'm not sure if you should fix server or rails code.
If you want more info about the issue here is the commit that removed old way of logging https://github.com/rails/rails/commit/04ef93dae6d9cec616973c1110a33894ad4ba6ed
If you value production log readability over everything else you can use the
PassengerMaxInstancesPerApp 1
configuration. It might cause some scaling issues. Alternatively you could stuff something like this in application.rb:
process_log_filename = Rails.root + "log/#{Rails.env}-#{Process.pid}.log"
log_file = File.open(process_log_filename, 'a')
Rails.logger = ActiveSupport::BufferedLogger.new(log_file)
Yep!, they have made some changes in the ActiveSupport::BufferedLogger so it is not any more waiting until the request has ended to flush the logs:
http://news.ycombinator.com/item?id=4483390
https://github.com/rails/rails/commit/04ef93dae6d9cec616973c1110a33894ad4ba6ed
But they have added the ActiveSupport::TaggedLogging which is very funny and you can stamp every log with any kind of mark you want.
In your case could be good to stamp the logs with the request UUID like this:
# config/application.rb
config.log_tags = [:uuid]
Then even if the logs are messed up you still can follow which of them correspond to the request you are following up.
You can make more funny things with this feature to help you in your logs study:
How to log user_name in Rails?
http://zogovic.com/post/21138929607/running-time-in-rails-logs
Well, for me the TaggedLogging solution is a no go, I can live with some logs getting lost if the server crashes badly, but I want my logs to be perfectly ordered. So, following advice from the issue comments I'm applying this to my app:
# lib/sequential_logs.rb
module ActiveSupport
class BufferedLogger
def flush
#log_dest.flush
end
def respond_to?(method, include_private = false)
super
end
end
end
# config/initializers/sequential_logs.rb
require 'sequential_logs.rb'
Rails.logger.instance_variable_get(:#logger).instance_variable_get(:#log_dest).sync = false
As far as I can say this hasn't affected my app, it is still running and now my logs make sense again.
They should add some quasi-random reqid and write it in every line regarding one single request. This way you won't get confused.
I haven't used it, but I believe Lumberjack's unit_of_work method may be what you're looking for. You call:
Lumberjack.unit_of_work do
yield
end
And all logging done either in that block or in the yielded block are tagged with a unique ID.
For some reason, a simple piece of decorator-code fails on my production machine, but runs fine on development[1].
I dumbed it down, and found that the following is the simplest failing piece:
Spree::Variant.class_eval do
def price=(value)
self.price = normalize_number(value)
end
end
Failing with SystemStackError (stack level too deep):
Debugging shows me that, indeed, the function keeps being called. self.price= calls price=.
What is a usual Rails/Ruby pattern to tackle this? What I want is:
When attribute_foo=(bar) gets called, delegate it to my custom code, where I can run the passed bar trough a small piece of custom code. Then assign that altered bar to attribute_foo.
[1]:
The only difference is the Ruby patch version and the fact that the production machine has 64-bit version, versus 32bit-version on dev: ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux].
The solition was simple: just use write_attribute.
Spree::Variant.class_eval do
def price=(value)
write_attribute(:price, bar(value))
end
end