Skip to content
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

Invoking from within code fails #33

Closed
rpattcorner opened this issue Oct 29, 2013 · 5 comments
Closed

Invoking from within code fails #33

rpattcorner opened this issue Oct 29, 2013 · 5 comments

Comments

@rpattcorner
Copy link

Probably an error on my part, but ...

Invoking byebug from shell works fine, e.g.

byebug -- myprogram.rb --option1

However inserting the command

byebug

in ruby code results in, for example:

[root@ip-10-0-1-100 deploy]# ruby sshtest.bb.rb
sshtest.bb.rb:9:in <main>': undefined local variable or methodbyebug' for main:Object (NameError)

Code looks like:

[root@ip-10-0-1-100 deploy]# cat sshtest.bb.rb
require 'net/http'
require 'json'
require 'rexml/document'

require 'net/ssh'
require 'net/ssh/multi'

connect_fail_retries = 0;
byebug
begin
puts "before do",connect_fail_retries
...

What obvious thing am I missing?
Documentation says to just insert

@deivid-rodriguez
Copy link
Owner

Yes, maybe the documentation is not very clear regarding this. You need to require byebug before calling byebug, but if you use bundler it will take care of that for you.

In your case, you can do

ruby -rbyebug sshtest.bb.rb

to tell the ruby to require it before running your program.

@rpattcorner
Copy link
Author

Thanks so much Deivid … that completely fixed the problem! Apologies for the simplicity of the question …

R.

From: David Rodríguez [mailto:notifications@github.com]
Sent: Tuesday, October 29, 2013 5:01 PM
To: deivid-rodriguez/byebug
Cc: Robert Patt-Corner
Subject: Re: [byebug] Invoking from within code fails (#33)

Yes, maybe the documentation is not very clear regarding this. You need to require byebug before calling byebug, but if you use bundler it will take care of that for you.

In your case, you can do

ruby -rbyebug sshtest.bb.rb

to tell the ruby to require it before running your program.


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-27342940.

@deivid-rodriguez
Copy link
Owner

You are welcome @rpattcorner , no need to apologize!

@meowsus
Copy link

meowsus commented Jun 14, 2015

@deivid-rodriguez I would recommend adding the require 'byebug' bit to the documentation.

@tuxayo
Copy link

tuxayo commented Jun 29, 2015

I fell in the same trap, however require 'byebug' failed with with a 'cannot load such file' error even thought the gem was installed. But adding it to the Gemfile worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants