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

directory problem on Windows #62

Closed
keesvp opened this issue Oct 30, 2013 · 4 comments
Closed

directory problem on Windows #62

keesvp opened this issue Oct 30, 2013 · 4 comments

Comments

@keesvp
Copy link

keesvp commented Oct 30, 2013

running tests.jl
img = Image(Pkg.dir("Tk", "examples", "weather-overcast.gif"))
ERROR: TclError("couldn't open "C:UsersKees.juliaTkexamplesweather-overcast.gif": no such file or directory")
in tcl_eval at C:\Users\Kees.julia\Tk\src\tkwidget.jl:97
in tcl_eval at C:\Users\Kees.julia\Tk\src\tkwidget.jl:91
in tcl at C:\Users\Kees.julia\Tk\src\core.jl:48
in Image at C:\Users\Kees.julia\Tk\src\widgets.jl:321

Pkg.dir returns:
"C:\Users\Kees.julia\Tk\examples\weather-overcast.gif"
the backslashes disappear.

@pfitzseb
Copy link

Image() does work if the supplied string is formated like

"C:/Users/.../julia/v0.3/Tk/examples/weather-overcast.gif"

as opposed to

"C:\\Users\\...\\julia\\v0.3\\Tk\\examples\\weather-overcast.gif"

so the easiest (certainly not prettiest) way would be to special case windows and change the path in widgets.jl.
Something like replacing this with img = Image(replace(Pkg.dir("Tk", "examples", "weather-overcast.gif"), "\\", "/")) lets the test run as intended. At least on my system.

What would - as far as I can tell - work also (and be much cleaner) is changing the behaviour of all methods that return paths (e.g. Pkg.dir(), joinpath() etc) to use / instead of \\ since that doesn't appear to break anything...

@tkelman
Copy link
Contributor

tkelman commented Oct 25, 2014

@Varanas it looks like the only place filenames are really used in this package is the Image(fname::String) function in src/widgets.jl. In my testing I can fix the failure either by replacing \\ with /, or double-escaping it to \\\\, for file names only on Windows, in that function. The question of whether base Julia should prefer backslashes or forward slashes for joinpath and the like on Windows is an interesting one. Most Windows functionality works fine with either, but I can imagine there might be external Windows-only programs that might not handle forward slashes well. Or in this case, interacting with Tcl does not handle backslashes well unless they are escaped one more time.

@hustf
Copy link

hustf commented Oct 20, 2015

Notice how just some of the backslashes disappear in the original post. I did what @Varanas and @tkelman have probably done and traced this strange behaviour to tkwidget.jl:91
function tcl_eval(cmd,tclinterp) code = ccall((:Tcl_Eval,libtcl), Int32, (Ptr{Void}, Ptr{UInt8}), tclinterp, cmd)

Using 0.3.11 and the very oldest version of the package, the same problem seems to have been present on Windows since .... 32 bit to 64 bit perhaps?

Placing format checks inside of the image function should work if there is no filesystem where \ may be part of the long filename. Perhaps this bad behaviour is an acceptable one, or perhaps additional checks in Image would cover that.

...but can't such unexpected behaviour from a core function easily lead to erratic behaviour from tk in other cases too? Is the fault really with tk, or in the called library?

@aviks
Copy link
Collaborator

aviks commented Feb 5, 2020

Fixed by #147 I guess.

@aviks aviks closed this as completed Feb 5, 2020
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

5 participants