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

ocra giving trouble with File.open when command line argument is used #95

Open
derekomartin opened this issue Apr 29, 2015 · 2 comments

Comments

@derekomartin
Copy link

Here is my problem:

I have a file "file.txt", contents:
This is a test file.

I have a test script "test.rb", contents:
astr = ARGV[0]
File.open(astr,"r").each { |line| puts line }

If I type "ruby test.rb file.txt" I get:
This is a test file.

If I type "ocra test.rb" I get:
=== Loading script to check dependencies
C:/PATHTOSCRIPT/test.rb:2:in initialize': no implicit conversion of nil into String (TypeError) from C:/PATHTOSCRIPT/test.rb:2:inopen'
from C:/PATHTOSCRIPT/test.rb:2:in <top (required)>' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/ocra-1.3.5/bin/ocra:1185:inload'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/ocra-1.3.5/bin/ocra:1185:in <top (required)>' from C:/Ruby22/bin/ocra:23:inload'
from C:/Ruby22/bin/ocra:23:in `

'

What am I doing wrong?

@derekomartin
Copy link
Author

Oh yeah. This is using ruby 2.2.2 on Windows 7 x64

@ptyagi16
Copy link

Clearly ARGV[0] is nil in the second case since nothing was passed.

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

2 participants