New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling # frozen_string_literal: true
in ~/.pryc
crashes most operations
#1824
Comments
Sorry, I cannot reproduce this. % cat ~/.pryrc
# frozen_string_literal: true
Pry.color = true
Pry.editor = 'emacs'
# Rest is omitted
% pry
[1] pry(main)> require 'nokogiri'; fp = '~/1540326167346.xml' ; doc = Nokogiri::XML.parse(File.read(fp))
Errno::ENOENT: No such file or directory @ rb_sysopen - ~/1540326167346.xml
from (pry):1:in `read' Any details about your pry & ruby versions, or plugins that you use? What else do you have in your pryrc? Does it fail when it contains only that magic comment and nothing else? |
I managed to replicate it with a minimum example of: Working: # # frozen_string_literal: true
Pry.config.exception_handler = proc do |_output, _exception, _pry_|
_pry_.run_command 'cat --ex'
end Failing: # frozen_string_literal: true
Pry.config.exception_handler = proc do |_output, _exception, _pry_|
_pry_.run_command 'cat --ex'
end Having only the magic comment yields: [1] pry(main)> require 'nokogiri'; fp = '~/1540326167346.xml' ; doc = Nokogiri::XML.parse(File.read(fp))
Errno::ENOENT: No such file or directory @ rb_sysopen - ~/Documents/Forcepoint/WIP/1540326167346_subtest_setup.28_original_test_bba_configure_ATF_Cluster_output.xml
from (pry):1:in `read' but I prefer the more extensive version (not for the example or the REPL per se, but for debugging reasons i.e. using it with pry-byebug) Ruby / Pry version
Side question: Can I somehow write the However, an example of creating new # Hit Enter to repeat last command
Pry::Commands.command(/^$/, 'repeat last command') do
_pry_.run_command Pry.history.to_a.last
end So, I am not sure if |
Can you try upgrading Pry? The latest version is 0.11.3. |
[1] pry(main)> require 'nokogiri'; fp = '~/1540326167346.xml' ; doc = Nokogiri::XML.parse(File.read(fp));
(pry) output error: #<RuntimeError: can't modify frozen String>
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/command.rb:335:in `replace'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/command.rb:335:in `tokenize'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/command.rb:365:in `process_line'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/command_set.rb:400:in `process_line'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:450:in `run_command'
/home/sntentos/.pryrc:4:in `block in __pry__'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:365:in `show_result'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:336:in `block in handle_line'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_class.rb:395:in `critical_section'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:335:in `handle_line'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:242:in `catch'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:242:in `block in eval'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:241:in `catch'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:241:in `eval'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:77:in `block in repl'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:67:in `loop'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:67:in `repl'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:38:in `block in start'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/input_lock.rb:61:in `__with_ownership'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/input_lock.rb:79:in `with_ownership'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:38:in `start'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:13:in `start'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/pry_class.rb:192:in `start'
/var/lib/gems/2.3.0/gems/pry-byebug-3.6.0/lib/pry-byebug/pry_ext.rb:11:in `start_with_pry_byebug'
/var/lib/gems/2.3.0/gems/pry-0.11.3/lib/pry/cli.rb:116:in `start'
/var/lib/gems/2.3.0/gems/pry-0.11.3/bin/pry:12:in `<top (required)>'
/usr/local/bin/pry:23:in `load'
/usr/local/bin/pry:23:in `<main>' $ pry --version
Pry version 0.11.3 on Ruby 2.3.1 |
Small update here The rest is in the same state. I also managed to reproduce this. I guess the proper fix would be using frozen Strings ourselves. |
This change is a preparational step for #1824 (Enabling `frozen_string_literal: true` in `~/.pryc` crashes most operations). The handler was mutating `eval_string` that we pass, and this behaviour will stop working in Ruby 3. I was pondering about keeping this option but couldn't come up with an easy solution. I made a GitHub search to see if anybody uses it, and it seems like nobody configures it. I am not sure why anybody would want to do that, so I hope it won't be missed. The handler's behaviour wasn't deleted, it is still in place. We just moved the handler's code to `pry_instance.rb`.
This change is a preparational step for #1824 (Enabling `frozen_string_literal: true` in `~/.pryc` crashes most operations). The handler was mutating `eval_string` that we pass, and this behaviour will stop working in Ruby 3. I was pondering about keeping this option but couldn't come up with an easy solution. I made a GitHub search to see if anybody uses it, and it seems like nobody configures it. I am not sure why anybody would want to do that, so I hope it won't be missed. The handler's behaviour wasn't deleted, it is still in place. We just moved the handler's code to `pry_instance.rb`.
This is a preparational step for #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most operations) Alternative to #2030 (config: delete the `control_d_handler` option) We had to jump a few hoops to change how the handler works. The problem is that mutation is the default expected behaviour. Therefore, we had to change its API. There's no need to pass `eval_string` because `pry_instance` already has it as an attribute. `config.control_d_handler` is a proxy proc, to preserve backwards compatibility with users of old signature (one known user is Pry Byebug). The handler will emit a warning if the old signature is used.
This is a preparational step for #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most operations) Alternative to #2030 (config: delete the `control_d_handler` option) We had to jump a few hoops to change how the handler works. The problem is that mutation is the default expected behaviour. Therefore, we had to change its API. There's no need to pass `eval_string` because `pry_instance` already has it as an attribute. `config.control_d_handler` is a proxy proc, to preserve backwards compatibility with users of old signature (one known user is Pry Byebug). The handler will emit a warning if the old signature is used.
This is a preparational step for #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most operations) Alternative to #2030 (config: delete the `control_d_handler` option) We had to jump a few hoops to change how the handler works. The problem is that mutation is the default expected behaviour. Therefore, we had to change its API. There's no need to pass `eval_string` because `pry_instance` already has it as an attribute. `config.control_d_handler` is a proxy proc, to preserve backwards compatibility with users of old signature (one known user is Pry Byebug). The handler will emit a warning if the old signature is used.
This is a preparational step for #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most operations) Alternative to #2030 (config: delete the `control_d_handler` option) We had to jump a few hoops to change how the handler works. The problem is that mutation is the default expected behaviour. Therefore, we had to change its API. There's no need to pass `eval_string` because `pry_instance` already has it as an attribute. `config.control_d_handler` is a proxy proc, to preserve backwards compatibility with users of old signature (one known user is Pry Byebug). The handler will emit a warning if the old signature is used.
Fixes #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most operations)
e.g.
vs
The text was updated successfully, but these errors were encountered: