224 posts
Location
Auckland, New Zealand
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/3LHYK5MdCould someone help solve this?Thanks, AnthonyD98EDIT: Moved the EDIT to the latest post.
7508 posts
Location
Australia
Posted 07 February 2013 - 09:54 PM
What errors is it displaying?
2088 posts
Location
South Africa
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
224 posts
Location
Auckland, New Zealand
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
224 posts
Location
Auckland, New Zealand
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
7508 posts
Location
Australia
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.
224 posts
Location
Auckland, New Zealand
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?
7508 posts
Location
Australia
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.
224 posts
Location
Auckland, New Zealand
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.
7508 posts
Location
Australia
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
224 posts
Location
Auckland, New Zealand
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.
7508 posts
Location
Australia
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"
224 posts
Location
Auckland, New Zealand
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 . . . .
224 posts
Location
Auckland, New Zealand
Posted 07 February 2013 - 10:22 PM
I see the problem now
EDIT: progs//.Config
I need to remove the / from every file thingy.
7508 posts
Location
Australia
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
224 posts
Location
Auckland, New Zealand
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.
224 posts
Location
Auckland, New Zealand
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.
224 posts
Location
Auckland, New Zealand
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/.ConfigNo such programChecking for Updates . . .pastebin:92 attempt to index ? ( a nil value )No such programChecking 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
224 posts
Location
Auckland, New Zealand
Posted 08 February 2013 - 10:45 AM
I don't know how to fix this.
8543 posts
Posted 08 February 2013 - 11:15 AM
What is line 92 of pastebin? I suspect you have http disabled.
224 posts
Location
Auckland, New Zealand
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.
8543 posts
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?
224 posts
Location
Auckland, New Zealand
Posted 08 February 2013 - 11:23 AM
How can I check if it is enabled?
2005 posts
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.
224 posts
Location
Auckland, New Zealand
Posted 08 February 2013 - 12:01 PM
So what do I do?
2005 posts
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.
224 posts
Location
Auckland, New Zealand
Posted 08 February 2013 - 01:09 PM
Thank you guys!
Solved!