Error appears when I try to run pry in Bash - ruby

I've just downloaded Pry gem to use it running a Ruby code. I tried to open the pry prompt in Git Bash on Windows 10 and returns a huge error:
For a better Pry experience on Windows, please use ansicon:
https://github.com/adoxa/ansicon
If you use an alternative to ansicon and don't want to see this warning again,
you can add "Pry.config.windows_console_warning = false" to your pryrc.
â–½Error: Bad file descriptor
C:/tools/ruby30/lib/ruby/3.0.0/reline/ansi.rb:177:in `raw'
C:/tools/ruby30/lib/ruby/3.0.0/reline/ansi.rb:177:in `cursor_pos'
C:/tools/ruby30/lib/ruby/3.0.0/reline.rb:375:in `may_req_ambiguous_char_width'
C:/tools/ruby30/lib/ruby/3.0.0/reline.rb:212:in `inner_readline'
C:/tools/ruby30/lib/ruby/3.0.0/reline.rb:188:in `readline'
C:/tools/ruby30/lib/ruby/3.0.0/forwardable.rb:238:in `readline'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:198:in `block in input_readline'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/input_lock.rb:114:in `interruptible_region'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:197:in `input_readline'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:185:in `block in read_line'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:132:in `handle_read_errors'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:171:in `read_line'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:98:in `read'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:68:in `block in repl'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:67:in `loop'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:67:in `repl'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:38:in `block in start'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/input_lock.rb:61:in `__with_ownership'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/input_lock.rb:78:in `with_ownership'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:38:in `start'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/repl.rb:15:in `start'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/pry_class.rb:188:in `start'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/lib/pry/cli.rb:112:in `start'
C:/tools/ruby30/lib/ruby/gems/3.0.0/gems/pry-0.14.1/bin/pry:13:in `<top (required)>'
C:/tools/ruby30/bin/pry:23:in `load'
C:/tools/ruby30/bin/pry:23:in `<main>'
FATAL: Pry failed to get user input using `Reline`.
To fix this you may be able to pass input and output file descriptors to pry directly. e.g.
Pry.config.input = STDIN
Pry.config.output = STDOUT
binding.pry
When I run it in CMD Prompt works perfectly and I don't know how to fix this.

use gitbush inside vscode with terminal, no error

Related

Getting an error when starting ruby irb in a rclone mounted volume on Linux

When I am in a mounted share on Linux I get the following error when starting a ruby program or just irb. As long as I am outside the share everything works fine. The share is a mounted by rclone. Maybe its rclone specific. For irb the error is:
/usr/local/lib/site_ruby/2.3.0/rubygems/bundler_version_finder.rb:80:in `pwd': No such file or directory - getcwd (Errno::ENOENT)
from /usr/local/lib/site_ruby/2.3.0/rubygems/bundler_version_finder.rb:80:in `lockfile_contents'
from /usr/local/lib/site_ruby/2.3.0/rubygems/bundler_version_finder.rb:68:in `lockfile_version'
from /usr/local/lib/site_ruby/2.3.0/rubygems/bundler_version_finder.rb:22:in `bundler_version_with_reason'
from /usr/local/lib/site_ruby/2.3.0/rubygems/bundler_version_finder.rb:7:in `bundler_version'
from /usr/local/lib/site_ruby/2.3.0/rubygems/bundler_version_finder.rb:39:in `compatible?'
from /usr/local/lib/site_ruby/2.3.0/rubygems/specification.rb:1042:in `block in find_by_path'
from /usr/local/lib/site_ruby/2.3.0/rubygems/specification.rb:1041:in `each'
from /usr/local/lib/site_ruby/2.3.0/rubygems/specification.rb:1041:in `find'
from /usr/local/lib/site_ruby/2.3.0/rubygems/specification.rb:1041:in `find_by_path'
from /usr/local/lib/site_ruby/2.3.0/rubygems.rb:212:in `try_activate'
from /usr/lib/ruby/2.3.0/irb/locale.rb:150:in `block in search_file'
from /usr/lib/ruby/2.3.0/irb/locale.rb:158:in `block in each_localized_path'
from /usr/lib/ruby/2.3.0/irb/locale.rb:167:in `each_sublocale'
from /usr/lib/ruby/2.3.0/irb/locale.rb:157:in `each_localized_path'
from /usr/lib/ruby/2.3.0/irb/locale.rb:145:in `search_file'
from /usr/lib/ruby/2.3.0/irb/locale.rb:124:in `find'
from /usr/lib/ruby/2.3.0/irb/locale.rb:108:in `load'
from /usr/lib/ruby/2.3.0/irb/locale.rb:32:in `initialize'
from /usr/lib/ruby/2.3.0/irb/init.rb:113:in `new'
from /usr/lib/ruby/2.3.0/irb/init.rb:113:in `init_config'
from /usr/lib/ruby/2.3.0/irb/init.rb:17:in `setup'
from /usr/lib/ruby/2.3.0/irb.rb:378:in `start'
from /usr/bin/irb:11:in `<main>'
Does anyone know how to fix this?
Have you checked your assumptions:
Do you have proper permissions for the share?
Can you run pwd from the mounted share?
Do you have a pot of coffee as well as a vile of hemlock in case things go south?

OpenShift setup invalid argument

I've been following getting started of openshift, but I am stuck at this error.
OpenShift Client Tools (RHC) Setup Wizard
This wizard will help you upload your SSH keys, set your application namespace, and check that other programs like Git
are properly installed.
If you have your own OpenShift server, you can specify it now. Just hit enter to use the server for OpenShift Online:
openshift.redhat.com.
Enter the server hostname: |openshift.redhat.com| C:/Ruby193/lib/ruby/gems/1.9.1/gems/highline-1.6.21/lib/highline.rb:86
4:in `gets': Invalid argument - <STDIN> (Errno::EINVAL)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/highline-1.6.21/lib/highline.rb:864:in `get_line'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/highline-1.6.21/lib/highline.rb:885:in `get_response'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/highline-1.6.21/lib/highline.rb:260:in `ask'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/highline_extensions.rb:12:in `block (2 levels) in <c
lass:HighLineExtension>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/wizard.rb:188:in `block in server_stage'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/highline_extensions.rb:190:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/highline_extensions.rb:190:in `section'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/highline_extensions.rb:204:in `paragraph'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/helpers.rb:339:in `block (2 levels) in <module:Helpe
rs>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/wizard.rb:185:in `server_stage'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/wizard.rb:67:in `block in run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/wizard.rb:65:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/wizard.rb:65:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/commands/setup.rb:57:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/commands.rb:294:in `execute'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/commands.rb:285:in `block (3 levels) in to_commander
'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.2.1/lib/commander/command.rb:155:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.2.1/lib/commander/runner.rb:421:in `run_active_command'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/command_runner.rb:72:in `run!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/commander-4.2.1/lib/commander/delegates.rb:12:in `run!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/lib/rhc/cli.rb:37:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rhc-1.38.4/bin/rhc:20:in `<top (required)>'
from C:/Ruby193/bin/rhc:23:in `load'
from C:/Ruby193/bin/rhc:23:in `<main>'
I tried reinstalling ruby (and rhc gem) to older version (1.93) as found in a different question. It probably isn't what has been causing my error. I tried using defauld windows commandline and PowerShell 5.0 with the same result.
I am expecting a promp for server hostname, but this stacktrace happens right after entering 'rhc setup'.
I tried everything nothing worked except this which says "change the CMD window properties. Simply select the 'Use Legacy console'" and It really worked
Ruby 2.0 64bit worked for some reason
previously the error was evoked by anything with
raw_answer = #input.gets
I (and people I've asked) have to classify this as 'Windows Magic'. Windows are such a good development enviroment.

Terminal error using Test First Ruby

I'm just starting Test First Ruby & I'm having trouble running rakes to start solving problems.
I think it's either my version of RSpec or my version of Ruby that's causing the error.
Here's the error,
AT MacBook-Pro:01_temperature AT$ rake
(in /Users/AT/Desktop/learn_ruby)
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- temperature (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/AT/Desktop/learn_ruby/01_temperature/temperature_spec.rb:18:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `each'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:96:in `setup'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:84:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:69:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/lib/rspec/core/runner.rb:37:in `invoke'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.1.2/exe/rspec:4:in `<top (required)>'
from /usr/bin/rspec:23:in `load'
from /usr/bin/rspec:23:in `<main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -S rspec /Users/AT/Desktop/learn_ruby/01_temperature/temperature_spec.rb -I/Users/AT/Desktop/learn_ruby/01_temperature -I/Users/AT/Desktop/learn_ruby/01_temperature/solution -f documentation -r ./rspec_config failed
I had a similar problem a few minutes ago but fixed by uninstalling RSpec v-3, and installing v-2.14.
Any help would be appreciated!
Your file temperature_spec is requiring what I presume is the source for the class under test, temperature - but the RSpec loader is not able to resolve the path for this file.
It would be helpful for you to post both the source of your rspec file and your class under test.

allow_dynamic_fields: true' (ArgumentError)

Strange error occuring at server start , please look at logs
umair-2:game-minion umairejaz$ rails server
/Library/Ruby/Gems/1.8/gems/railties-3.1.0.rc5/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Could not load SystemTimer >= v1.2.0. Falling back to timeout.rb. SystemTimer is STRONGLY recommended for timeouts in Ruby 1.8.7. See http://ph7spot.com/blog/system-timer-1-2-release for details.
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 1, col 24: ` allow_dynamic_fields: true' (ArgumentError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in `load'
from /Library/Ruby/Gems/1.8/gems/mongoid-2.0.0.beta.20/lib/mongoid/railtie.rb:53
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `send'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
from /Users/umairejaz/Projects/game-minion/config/environment.rb:5
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
from /Users/umairejaz/Projects/game-minion/config.ru:3
from /Library/Ruby/Gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
from /Library/Ruby/Gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
from /Users/umairejaz/Projects/game-minion/config.ru:1:in `new'
from /Users/umairejaz/Projects/game-minion/config.ru:1
Check any of your YAML files under the config folder, specifically one that has the allow_dynamic_fields setting in it. It's likely an error either above, below, or on that particular line. Remove any extraneous whitespace and reformat things (i.e. either use tabs or spaces, not both). Check for any other clutter or extraneous keywords.

How do I suppress the huge stack trace after a rake TestTask failure?

I'm setting up a rakefile for a project, and I've defined some rake TestTasks. I ran a simple sanity test that does an assert_equal(1, 2) just to check the output, and, in addition to the usual failure output, I get this mess:
rake aborted!
Command failed with status (1): [/usr/bin/ruby -w -I"lib:." "/usr/lib/ruby/...]
/usr/lib/ruby/1.9.1/rake.rb:993:in `block in sh'
/usr/lib/ruby/1.9.1/rake.rb:1008:in `call'
/usr/lib/ruby/1.9.1/rake.rb:1008:in `sh'
/usr/lib/ruby/1.9.1/rake.rb:1092:in `sh'
/usr/lib/ruby/1.9.1/rake.rb:1027:in `ruby'
/usr/lib/ruby/1.9.1/rake.rb:1092:in `ruby'
/usr/lib/ruby/1.9.1/rake/testtask.rb:115:in `block (2 levels) in define'
/usr/lib/ruby/1.9.1/rake.rb:1110:in `verbose'
/usr/lib/ruby/1.9.1/rake/testtask.rb:100:in `block in define'
/usr/lib/ruby/1.9.1/rake.rb:634:in `call'
/usr/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
/usr/lib/ruby/1.9.1/rake.rb:629:in `each'
/usr/lib/ruby/1.9.1/rake.rb:629:in `execute'
/usr/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/usr/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites'
/usr/lib/ruby/1.9.1/rake.rb:602:in `each'
/usr/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites'
/usr/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/usr/lib/ruby/1.9.1/rake.rb:581:in `invoke'
/usr/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
/usr/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
/usr/lib/ruby/1.9.1/rake.rb:2019:in `each'
/usr/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
/usr/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
/usr/lib/ruby/1.9.1/rake.rb:1992:in `run'
/usr/bin/rake:31:in `<main>'
How do I get rid of it? I don't want to have to scroll up past 20 lines of junk to see my test failures.
I had the same problem as you and solved it by updating rake: gem install rake
This updated from whatever I had to 0.8.7.
I'm running 1.9.2-p180 (OS X, installed with Homebrew) and was running tests on a newly created project (made with Hoe).
Rake shouldn't be returning a backtrace in this situation -- the error is with the external command, not rake's internals. I've sent a email to Jim Weirich regarding the following patch: https://gist.github.com/1003628
Rake normally does not show a backtrace unless you specify --trace. Perhaps you have configured Rake to always run in --trace mode?
By default, rake does not print out the stack trace if you get an error in the code that rake calls. You can get the stack trace by running with the --trace flag, but usually I'd just rather see it anyway. You can do that by putting Rake.application.options.trace = true into the rakefile.
If not, you might try setting Rake.application.options.trace = false in your Rakefile.
I still had unwanted stack traces in rake 0.8.7, updating to 0.9.2 finally helped for me (ruby 1.9.2p180 [i386-mingw32] on Win7 32bit).
Look in config/initializers/backtrace_silencers.rb
You should be able to add something like
Rails.backtrace_cleaner.add_silencer { |line| line =~ %r{/usr/lib/ruby/1.9.1/rake.rb} }

Resources