This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
AnthonyD98™'s profile picture

[ Error ] [ SOLVED ] Why is my program STILL displaying errors?

Started by AnthonyD98™, 07 February 2013 - 08:49 PM
AnthonyD98™ #1
Posted 07 February 2013 - 09:49 PM
Why does my program display errors when I run it in a directory other than the root directory - ( But the program is still working )

Pastebin link:
http://pastebin.com/3LHYK5Md

Could someone help solve this?

Thanks, AnthonyD98

EDIT: Moved the EDIT to the latest post.
theoriginalbit #2
Posted 07 February 2013 - 09:54 PM
What errors is it displaying?
remiX #3
Posted 07 February 2013 - 09:58 PM
Yeah, you need to be more specific.
People wouldn't want to debug a code that's over 400 lines
AnthonyD98™ #4
Posted 07 February 2013 - 09:59 PM
These Errors…

Spoiler[attachment=994:Errors.JPG][attachment=995:Error2.JPG]

Everything was kinda working before, but now its just bugging out.
Edited on 07 February 2013 - 08:59 PM
AnthonyD98™ #5
Posted 07 February 2013 - 10:02 PM
Its also not displaying 'Checking for Updates . . .' anymore

EDIT: It seems to be displaying checking for updates sometimes and checking configs sometimes ??
Edited on 07 February 2013 - 09:04 PM
theoriginalbit #6
Posted 07 February 2013 - 10:02 PM
Well the pastebin error is on this logic:


local file = fs.open( sPath, "w" )
file.write( sResponse ) <-- this is line 92
file.close()
So this indicates to me that the file path that is being passed in is trying to open a file that can't be, normal cause of this is bad formatted paths. so try printing out the path and see what your getting.
AnthonyD98™ #7
Posted 07 February 2013 - 10:06 PM
Well the pastebin error is on this logic:


local file = fs.open( sPath, "w" )
file.write( sResponse ) <-- this is line 92
file.close()
So this indicates to me that the file path that is being passed in is trying to open a file that can't be, normal cause of this is bad formatted paths. so try printing out the path and see what your getting.

Some of this code wasn't even written by me - Some by skullblade who is helping with the OS now so I wouldn't have a clue.

So its trying to open a file but cannot?
theoriginalbit #8
Posted 07 February 2013 - 10:09 PM
You know I would just like to say that sometimes its a good thing to figure out your own errors, it gives a sense of pride knowing you did it on your own. I say this because I look at the code and IMMEDIATELY see the paths that are causing the problem.

Print out the paths in line 44 and 49 and see what they come up with.
AnthonyD98™ #9
Posted 07 February 2013 - 10:13 PM
I do try to figure out my own errors, You see them immediatly because your more experianced than me. When I see the error, I don't know what is causing the problem. Thats why I come here to ask and then I learn from that so I am better prepared for it in the future.
theoriginalbit #10
Posted 07 February 2013 - 10:14 PM
You see them immediatly because your more experianced than me.
Its not all about experience. All I do is read the error. It tells you a line number, and when it doesn't, well then I'm as lost as.

In any case what does it print out?

EDIT: Also just a little side note, a good technique for file editing is to avoid how the pastebin program does it, do it something like this

local file = fs.open(<path>, <mode>)
if file then
  -- do operations on the file here, its open and ready to use
else
  print("Unable to open file for read/write")
  error()
end
AnthonyD98™ #11
Posted 07 February 2013 - 10:17 PM
You see them immediatly because your more experianced than me.
Its not all about experience. All I do is read the error. It tells you a line number, and when it doesn't, well then I'm as lost as.

In any case what does it print out?

I don't even know how to print it out, I'm tired I think I'm going to call it a night and try again tomorrow thanks for all your help.
theoriginalbit #12
Posted 07 February 2013 - 10:18 PM
I don't even know how to print it out, I'm tired I think I'm going to call it a night and try again tomorrow thanks for all your help.
On the line before line 44 put this
print(getPath().."/.Config")
and on the line before line 49 put this
getPath().."/.temp"
AnthonyD98™ #13
Posted 07 February 2013 - 10:19 PM
You see them immediatly because your more experianced than me.
Its not all about experience. All I do is read the error. It tells you a line number, and when it doesn't, well then I'm as lost as.

In any case what does it print out?

I don't even know how to print it out, I'm tired I think I'm going to call it a night and try again tomorrow thanks for all your help.
On the line before line 44 put this
print(getPath().."/.Config")
and on the line before line 49 put this
getPath().."/.temp"

Okay I'll try this before I go . . . .
AnthonyD98™ #14
Posted 07 February 2013 - 10:22 PM
I see the problem now

EDIT: progs//.Config

I need to remove the / from every file thingy.
theoriginalbit #15
Posted 07 February 2013 - 10:22 PM
I see the problem now

EDIT: progs//.Config

I need to remove the / from every file thingy.
Yep :)/> the getPath leaves the last / if its there, for the root directory the string is "" but thats ok because the root dir's / doesn't have to be there
AnthonyD98™ #16
Posted 07 February 2013 - 10:24 PM
I see the problem now

EDIT: progs//.Config

I need to remove the / from every file thingy.
Yep :)/> the getPath leaves the last / if its there, for the root directory the string is "" but thats ok because the root dir's / doesn't have to be there

Thank you, so much for your help

Goodnight :)/>
I shall be releasing an update for SelectOS tomorrow due to your help.
AnthonyD98™ #17
Posted 07 February 2013 - 10:26 PM
I see the problem now

EDIT: progs//.Config

I need to remove the / from every file thingy.
Yep :)/> the getPath leaves the last / if its there, for the root directory the string is "" but thats ok because the root dir's / doesn't have to be there


This has taught me a valuable lesson.

I'm off

– /me AnthonyD98 turns off the computer.
AnthonyD98™ #18
Posted 08 February 2013 - 09:12 AM
Even though I have removed the extra '/' the errors are still appearing ??!

EDIT: What it says is this:

Checking Configs . . .

progs/.Config
No such program
Checking for Updates . . .

pastebin:92 attempt to index ? ( a nil value )
No such program
Checking for Missing Files . . .

Missing Directory detected - Reinstalling!

pastebin:92 attempt to index ? ( a nil value )

. . . Pess any key to continue . . .

– Presses any key
– Continues onto SelectOS - No crashes
– The os works perfectly.
– So why am I still getting the errors?


EDIT: You can see here I have removed the extra '/'
http://pastebin.com/8DFL9Nem
Edited on 08 February 2013 - 09:15 AM
AnthonyD98™ #19
Posted 08 February 2013 - 10:45 AM
I don't know how to fix this.
Lyqyd #20
Posted 08 February 2013 - 11:15 AM
What is line 92 of pastebin? I suspect you have http disabled.
AnthonyD98™ #21
Posted 08 February 2013 - 11:18 AM
What is line 92 of pastebin? I suspect you have http disabled.

Line 92 wasn't written by me it was written by skullblade ( we are working together ) So I don't know whats happening there
I do know that line 92 is part of the auto updater / installer

I'm using CC-Emulator and http is enabled.
Lyqyd #22
Posted 08 February 2013 - 11:20 AM
No, not in your code. Your code runs the built-in pastebin program. I can't remember which line that is, but the http API not being present generally results in an attempt to index nil error. Are you sure you have http enabled?
AnthonyD98™ #23
Posted 08 February 2013 - 11:23 AM
How can I check if it is enabled?
ChunLing #24
Posted 08 February 2013 - 11:47 AM
Usually running pastebin is enough, the program has a bit that checks to make sure the http API is present:
if not http then
    print( "Pastebin requires http API" )
    print( "Set enableAPI_http to 1 in mod_ComputerCraft.cfg" )
    return
end
Line 92 is:
   	 file.write( sResponse )
It would produce an attempt to index nil if file were nil, which would be the case if you passed in an argument that couldn't be resolved as a valid filepath.
AnthonyD98™ #25
Posted 08 February 2013 - 12:01 PM
So what do I do?
ChunLing #26
Posted 08 February 2013 - 12:11 PM
Put a debug print in front of your shell.run() calls, with the exact same arguments. See what you get.
AnthonyD98™ #27
Posted 08 February 2013 - 01:09 PM
Thank you guys!

Solved!