I have developed a plugin, but in some environments, it popups the following error.
The .rb file loads well on some computers, and also we all use the SketchUp version 2020 on Windows 10.
Could anyone help to solve this problem? Thanks in advance.
I have developed a plugin, but in some environments, it popups the following error.
The .rb file loads well on some computers, and also we all use the SketchUp version 2020 on Windows 10.
Could anyone help to solve this problem? Thanks in advance.
Post the message including the first few lines.
Theyāll contain more useful infoā¦
I see āSystemStack Errorā - ā¦too deepā¦
What are you trying to pass ?
A āstack level too deepā error suggests that you have an infinite recursion loop in your code. Based on the chain of error messages I would guess you are retrying an open uri call that fails.
require 'open-uri'
stringsfile = "C:/Users/Administrator/Desktop/test.txt"
open(stringsfile) {|f|
string = f.read # This returns a string even if the file is empty.
}
If the input parameter is a local file path, then the SketchUp will popup the error.
And I try to use weblink such as āhttp://www.google.com/ā, it will work well and return the right result.
Yes, I try to use open() function in open-uri to open and read a local file.
And I have tested the above simple code segment with the ruby console in SketchUp, it also popups the same error.
The weird thing is that the open() function could open a weblink but not a local file.
There are many alternative ways to read local files that sidestep the limitations of open-uri - e.g. File.read_all(stringsfile)
or perhaps the IO
methodsā¦
I donāt know why the stack overflow is happening, but I notice that your āstringsfileā variable is not a valid URI for a local file. It ought to start with file:// not just with the C: drive. Possibly there is a bug in open-uri in this situation?
I agree with TIG, use File.open
or File.each
or IO.readlines
.
There is no real good reason do deal with open-uri
quirks for local files.
Appreciate for all the professional suggestion, and I have used File.open as an alternate.
And it works well in any Windows environment.
FYI - I have experienced this issue but in a Mac environment.
With open
creating a stack-overflowing recursion?
correct
Did you find an alternative to open
in your case? Or did you have to use open
?
We switched to using File.open. I donāt recall why we were using open-uri open prior.